R: Negative binomial (NB1): generic synthetic linear negative...
nb1_syn
R Documentation
Negative binomial (NB1): generic synthetic linear negative binomial data and model
Description
nb1_syn is a generic function for developing synthetic NB1 data and a model given
user defined specifications.
Usage
nb1_syn(nobs=50000, delta=1, xv = c(1, 0.75, -1.25))
Arguments
nobs
number of observations in model, Default is 50000
delta
NB1 heterogeneity or ancillary parameter
xv
predictor coefficient values. First argument is intercept. Use as
xv = c(intercept , x1_coef, x2_coef, ...)
Details
Create a synthetic linear negative binomial (NB1) regression model using the
appropriate arguments. Model data with predictors indicated as a group with
a period (.). See examples.
Data can be modeled using the ml.nb1.r function in the COUNT package, or by using the
gamlss function in the gamlss package, using the "family=NBII" option.
Value
nb1y
Negative binomial (NB1) response; number of counts
sim.data
synthetic data set
Author(s)
Joseph M. Hilbe, Arizona State University, and
Jet Propulsion Laboratory, California Institute of Technology
Andrew Robinson, Universty of Melbourne, Australia.
References
Hilbe, J.M. (2011), Negative Binomial Regression, second edition, Cambridge University Press.
See Also
nb2_syn, nbc_syn
Examples
sim.data <- nb1_syn(nobs = 5000, delta = .5, xv = c(.5, 1.25, -1.5))
mynb1 <- ml.nb1(nb1y ~ . , data = sim.data)
mynb1
## Not run:
# use gamlss to model NB1 data
library(gamlss)
sim.data <- nb1_syn(nobs = 5000, delta = .5, xv = c(.5, 1.25, -1.5))
mynb1 <- gamlss( nb1y ~ . , family=NBII, data = sim.data)
mynb1
## End(Not run)
## Not run:
# default
sim.data <- nb1_syn()
dnb1 <- ml.nb1(nb1y ~ . , data = sim.data)
dnb1
## End(Not run)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(COUNT)
Loading required package: msme
Loading required package: MASS
Loading required package: lattice
Loading required package: sandwich
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/COUNT/nb1_syn.Rd_%03d_medium.png", width=480, height=480)
> ### Name: nb1_syn
> ### Title: Negative binomial (NB1): generic synthetic linear negative
> ### binomial data and model
> ### Aliases: nb1_syn
> ### Keywords: models negative binomial
>
> ### ** Examples
>
>
> sim.data <- nb1_syn(nobs = 5000, delta = .5, xv = c(.5, 1.25, -1.5))
> mynb1 <- ml.nb1(nb1y ~ . , data = sim.data)
> mynb1
Estimate SE Z LCL UCL
(Intercept) 0.4956615 0.011438133 43.33413 0.4732428 0.5180803
x1 1.2567946 0.005270121 238.47547 1.2464652 1.2671241
x2 -1.4983175 0.005125695 -292.31501 -1.5083639 -1.4882712
alpha 0.4587779 0.034287596 13.38029 0.3915742 0.5259816
>
> ## Not run:
> ##D # use gamlss to model NB1 data
> ##D library(gamlss)
> ##D sim.data <- nb1_syn(nobs = 5000, delta = .5, xv = c(.5, 1.25, -1.5))
> ##D mynb1 <- gamlss( nb1y ~ . , family=NBII, data = sim.data)
> ##D mynb1
> ## End(Not run)
>
> ## Not run:
> ##D # default
> ##D sim.data <- nb1_syn()
> ##D dnb1 <- ml.nb1(nb1y ~ . , data = sim.data)
> ##D dnb1
> ## End(Not run)
>
>
>
>
>
>
> dev.off()
null device
1
>