svyglm.nb | R Documentation |
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 |
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.
An object of class svymle
and svyglm.nb
,
with some additional information about the model.
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)
# ------------------------------------------
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
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.