sjstats (version 0.17.5)

svyglm.nb: 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 formula, i.e. a symbolic description of the model to be fitted. See 'Details' in glm.

design

An object of class svydesign, providing a specification of the survey design.

...

Other arguments passed down to glm.nb.

Value

An object of class svymle and svyglm.nb, with some additional information about the model.

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 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.

References

Lumley T (2010). Complex Surveys: a guide to analysis using R. Wiley

Examples

Run this code
# NOT RUN {
# ------------------------------------------
# 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

# }

Run the code above in your browser using DataLab