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#> term irr std.error conf.low conf.high #> 2 (Intercept) 9.8463 0.1557 7.2573 13.3589 #> 3 factor(RIAGENDR)2 0.4511 0.1805 0.3167 0.6427 #> 4 log(age) 2.9163 0.2331 1.8467 4.6056 #> 5 factor(RIDRETH1)2 1.0859 0.1477 0.8129 1.4505 #> 6 factor(RIDRETH1)3 1.0977 0.1778 0.7746 1.5555 #> 7 factor(RIDRETH1)4 2.2686 0.2974 1.2664 4.0637 #> 8 factor(RIDRETH1)5 1.0589 0.3789 0.5039 2.2250 #> 9 factor(RIAGENDR)2:log(age) 0.2947 0.2651 0.1753 0.4955 #> 10 factor(RIAGENDR)2:factor(RIDRETH1)2 0.8314 0.2612 0.4983 1.3871 #> 11 factor(RIAGENDR)2:factor(RIDRETH1)3 1.8285 0.1932 1.2522 2.6700 #> 12 factor(RIAGENDR)2:factor(RIDRETH1)4 1.0668 0.3747 0.5118 2.2235 #> 13 factor(RIAGENDR)2:factor(RIDRETH1)5 1.4564 0.4427 0.6116 3.4681 #> p.value #> 2 <0.001 *** #> 3 <0.001 *** #> 4 <0.001 *** #> 5 0.5769 #> 6 0.6002 #> 7 0.0059 ** #> 8 0.8800 #> 9 <0.001 *** #> 10 0.4796 #> 11 0.0018 ** #> 12 0.8631 #> 13 0.3957 #> #> Dispersion parameter Theta: 0.8062 #> Standard Error of Theta: 0.0216#> #>