svyglm.nb()
is an extension to the survey-package
to fit survey-weighted negative binomial models. It uses
svymle
to fit sampling-weighted
maximum likelihood estimates, based on starting values provided
by glm.nb
, as proposed by Lumley
(2010, pp249).
svyglm.nb(formula, design, ...)
formula | An object of class |
---|---|
design | An object of class |
... | Other arguments passed down to |
An object of class svymle
and svyglm.nb
,
with some additional information about the model.
For details on the computation method, see Lumley (2010), Appendix E
(especially 254ff.)
sjstats implements following S3-methods for svyglm.nb
-objects:
family()
, model.frame()
, formula()
, print()
,
predict()
and residuals()
. However, these functions have some
limitations:
family()
simply returns the family-object from the
underlying glm.nb
-model.
The predict()
-method just re-fits the svyglm.nb
-model
with glm.nb
, overwrites the $coefficients
from this model-object with the coefficients from the returned
svymle
-object and finally calls
predict.glm
to compute the predicted values.
residuals()
re-fits the svyglm.nb
-model with
glm.nb
and then computes the Pearson-residuals
from the glm.nb
-object.
Lumley T (2010). Complex Surveys: a guide to analysis using R. Wiley
# ------------------------------------------ # This example reproduces the results from # Lumley 2010, figure E.7 (Appendix E, p256) # ------------------------------------------ library(survey)#>#>#> #>#>#> #>#>#> #>data(nhanes_sample) # create survey design des <- svydesign( id = ~SDMVPSU, strat = ~SDMVSTRA, weights = ~WTINT2YR, nest = TRUE, data = nhanes_sample ) # fit negative binomial regression fit <- svyglm.nb(total ~ factor(RIAGENDR) * (log(age) + factor(RIDRETH1)), des) # print coefficients and standard errors fit#> # A tibble: 12 x 6 #> term irr std.error conf.low conf.high p.value #> <chr> <dbl> <dbl> <dbl> <dbl> <chr> #> 1 (Intercept) 9.85 0.156 7.26 13.4 <0.001 *** #> 2 factor(RIAGENDR)2 0.451 0.180 0.317 0.643 <0.001 *** #> 3 log(age) 2.92 0.233 1.85 4.61 <0.001 *** #> 4 factor(RIDRETH1)2 1.09 0.148 0.813 1.45 "0.5769 ~ #> 5 factor(RIDRETH1)3 1.10 0.178 0.775 1.56 "0.6002 ~ #> 6 factor(RIDRETH1)4 2.27 0.297 1.27 4.06 "0.0059 **~ #> 7 factor(RIDRETH1)5 1.06 0.379 0.504 2.22 "0.8800 ~ #> 8 factor(RIAGENDR)2:log(age) 0.295 0.265 0.175 0.496 <0.001 *** #> 9 factor(RIAGENDR)2:factor(RID~ 0.831 0.261 0.498 1.39 "0.4796 ~ #> 10 factor(RIAGENDR)2:factor(RID~ 1.83 0.193 1.25 2.67 "0.0018 **~ #> 11 factor(RIAGENDR)2:factor(RID~ 1.07 0.375 0.512 2.22 "0.8631 ~ #> 12 factor(RIAGENDR)2:factor(RID~ 1.46 0.443 0.612 3.47 "0.3957 ~ #> #> Dispersion parameter Theta: 0.8062 #> Standard Error of Theta: 0.0216#> #>