sjstats (version 0.17.9)

svyglm.zip: Survey-weighted zero-inflated Poisson model

Description

svyglm.zip() is an extension to the survey-package to fit survey-weighted zero-inflated Poisson models. It uses svymle to fit sampling-weighted maximum likelihood estimates, based on starting values provided by zeroinfl.

Usage

svyglm.zip(formula, design, ...)

Arguments

formula

An object of class formula, i.e. a symbolic description of the model to be fitted. See 'Details' in zeroinfl.

design

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

...

Other arguments passed down to zeroinfl.

Value

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

Details

Code modified from https://notstatschat.rbind.io/2015/05/26/zero-inflated-poisson-from-complex-samples/.

Examples

Run this code
# NOT RUN {
if (require("survey")) {
  data(nhanes_sample)
  set.seed(123)
  nhanes_sample$malepartners <- rpois(nrow(nhanes_sample), 2)
  nhanes_sample$malepartners[sample(1:2992, 400)] <- 0

  # create survey design
  des <- svydesign(
    id = ~SDMVPSU,
    strat = ~SDMVSTRA,
    weights = ~WTINT2YR,
    nest = TRUE,
    data = nhanes_sample
  )

  # fit negative binomial regression
  fit <- svyglm.zip(
    malepartners ~ age + factor(RIDRETH1) | age + factor(RIDRETH1),
    des
  )

  # print coefficients and standard errors
  fit
}
# }

Run the code above in your browser using DataCamp Workspace