svygnm {logmult}R Documentation

Fitting Generalized Nonlinear Models With Complex Survey Data

Description

Fit association models to data from a complex survey design, with inverse-probability weighting and (optionally) standard errors based on replicate weights.

Usage

svygnm(formula, design, ...) 
## S3 method for class 'svyrep.design'
svygnm(formula, design,
    subset = NULL, data.fun = NULL, rescale = NULL, rho = NULL,
    return.replicates = FALSE, keep.weights = FALSE, na.action, 
    eliminate, ncpus = getOption("boot.ncpus"), ...)

Arguments

formula

a symbolic description of the nonlinear predictor.

design

a survey object; if se == "replicate", must be of class svrepdesign (see “Details” below). Must contain all variables in the formula

subset

expression to select a subpopulation

data.fun

function called on each replicate to generate the data argument passed to gnm. If not NULL, it will be passed design and ... as arguments, and must return a data.frame object. This is primarily useful to compute a frequency table and fit log-linear models.

rescale

Rescaling of weights, to improve numerical stability. The default rescales weights to sum to the sample size. Use FALSE to not rescale weights. For replicate-weight designs, use TRUE to rescale weights to sum to 1, as was the case before version 0.7.0.

rho

For replicate BRR designs, to specify the parameter for Fay's variance method, giving weights of rho and 2-rho

return.replicates

return the replicates as a component of the result?

keep.weights

whether to save the weights in the survey.design$pweights component of the result; note this typically uses a lot of memory.

na.action

handling of NAs

eliminate

a factor to be included as the first term in the model. gnm will exploit the structure of this factor to improve computational efficiency. See details.

ncpus

the number of CPU cores to use to run replicates. Pass NULL to use the actual number of cores with an upper limit of 5.

...

more arguments to be passed to gnm

Details

This function can be used in a similar way as svyglm, but for generalized nonlinear models. It computes standard errors using replicates only (i.e. no asymptotic standard errors). If your data does not come with replicate weights, use as.svrepdesign to create them first, and pass the resulting svrepdesign object via the design argument.

Value

An svygnm object.

Note

Note that printed fit statistics and degrees of freedom rely on the iid assumption. This is also the case of the variance-covariance matrix returned by the vcov.gnm function.

Author(s)

Milan Bouchet-Valat, based on the svyglm function by Thomas Lumley

References

Rao, J.N.K., Scott, A.J. (1984). On Chi-squared Tests For Multiway Contingency Tables with Proportions Estimated From Survey Data. Annals of Statistics 12, 46-60.

See Also

gnm, svyglm, as.svrepdesign

Examples

  library(survey)
  data(api)
  dstrat<-svydesign(id=~1,strata=~stype, weights=~pw, data=apistrat, fpc=~fpc)
  rstrat<-as.svrepdesign(dstrat)
  glm.mod <- svyglm(api00~ell+meals+mobility, design=rstrat)
  gnm.mod <- svygnm(api00~ell+meals+mobility, design=rstrat, ncpus=1)
  # Both functions give the same result for GLMs
  summary(glm.mod)
  summary(gnm.mod)
  

  # GNM, can only be fitted with svygnm()
  summary(svygnm(api00~ell+meals+mobility, design=rstrat, family=poisson, ncpus=1))

[Package logmult version 0.7.4 Index]