svyglm.nb {sjstats} | R Documentation |
Survey-weighted negative binomial generalised linear model
Description
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).
Usage
svyglm.nb(formula, design, ...)
Arguments
formula |
An object of class |
design |
An object of class |
... |
Other arguments passed down to |
Details
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 underlyingglm.nb
-model.The
predict()
-method just re-fits thesvyglm.nb
-model withglm.nb
, overwrites the$coefficients
from this model-object with the coefficients from the returnedsvymle
-object and finally callspredict.glm
to compute the predicted values.residuals()
re-fits thesvyglm.nb
-model withglm.nb
and then computes the Pearson-residuals from theglm.nb
-object.
Value
An object of class svymle
and svyglm.nb
,
with some additional information about the model.
References
Lumley T (2010). Complex Surveys: a guide to analysis using R. Wiley
Examples
# ------------------------------------------
# This example reproduces the results from
# Lumley 2010, figure E.7 (Appendix E, p256)
# ------------------------------------------
if (require("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
}