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 |
subset |
expression to select a subpopulation |
data.fun |
function called on each replicate to generate the |
rescale |
Rescaling of weights, to improve numerical stability. The default rescales weights to sum to the sample size. Use |
rho |
For replicate BRR designs, to specify the parameter for
Fay's variance method, giving weights of |
return.replicates |
return the replicates as a component of the result? |
keep.weights |
whether to save the weights in the |
na.action |
handling of NAs |
eliminate |
a factor to be included as the first term in the model.
|
ncpus |
the number of CPU cores to use to run replicates. Pass |
... |
more arguments to be passed to |
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
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))