svyglm
Survey-weighted generalised linear models.
Fit a generalised linear model to data from a complex survey design, with inverse-probability weighting and design-based standard errors.
- Keywords
- regression, survey
Usage
## S3 method for class 'survey.design':
svyglm(formula, design, subset=NULL, ...)
## S3 method for class 'svyrep.design':
svyglm(formula, design, subset=NULL, ..., rho=NULL,
return.replicates=FALSE, na.action)
## S3 method for class 'svyglm':
summary(object, correlation = FALSE, df.resid=NULL,
...)
## S3 method for class 'svyglm':
predict(object,newdata,total=NULL,
type=c("link","response"),se=TRUE,vcov=TRUE,...)
Arguments
- formula
- Model formula
- design
- Survey design from
svydesign
orsvrepdesign
. Must contain all variables in the formula - subset
- Expression to select a subpopulation
- ...
- Other arguments passed to
glm
orsummary.glm
- rho
- For replicate BRR designs, to specify the parameter for
Fay's variance method, giving weights of
rho
and2-rho
- return.replicates
- Return the replicates as a component of the result?
- object
- A
svyglm
object - correlation
- Include the correlation matrix of parameters?
- na.action
- Handling of NAs
- df.resid
- Optional denominator degrees of freedom for Wald tests
- newdata
- new data frame for prediction
- total
- population size when predicting population total
- type
- linear predictor (
link
) or response - se
- if
TRUE
, return variances of predictions - vcov
- if
TRUE
andse=TRUE
return variance-covariance matrix of predictions
Details
There is no anova
method for svyglm
as the models are not
fitted by maximum likelihood. The function regTermTest
may
be useful for testing sets of regression terms.
If df.resid
is not specified the df for the null model is
computed by degf
and the residual df computed by
subtraction. It's not that these are particularly good approximations
in a regression model but they are relatively standard. To get tests
based on a Normal distribution use df.resid=Inf
.
predict
gives fitted values and sampling variability for specific new
values of covariates. When newdata
are the population mean it
gives the regression estimator of the mean, and when newdata
are
the population totals and total
is specified it gives the
regression estimator of the population total. Regression estimators of
mean and total can also be obtained with calibrate
.
By default the variance-covariance matrix of the predictions is
returned. If newdata
has many rows this may be very large.
Value
svyglm
returns an object of classsvyglm
. Thepredict
method returns an object of classsvystat
See Also
Examples
data(api)
glm(api00~ell+meals+mobility, data=apipop)
dstrat<-svydesign(id=~1,strata=~stype, weights=~pw, data=apistrat, fpc=~fpc)
dclus2<-svydesign(id=~dnum+snum, weights=~pw, data=apiclus2)
rstrat<-as.svrepdesign(dstrat)
rclus2<-as.svrepdesign(dclus2)
summary(svyglm(api00~ell+meals+mobility, design=dstrat))
summary(svyglm(api00~ell+meals+mobility, design=dclus2))
summary(svyglm(api00~ell+meals+mobility, design=rstrat))
summary(svyglm(api00~ell+meals+mobility, design=rclus2))
## use quasibinomial, quasipoisson to avoid warning messages
summary(svyglm(sch.wide~ell+meals+mobility, design=dstrat,
family=quasibinomial()))
## Compare regression and ratio estimation of totals
api.ratio <- svyratio(~api.stu,~enroll, design=dstrat)
pop<-data.frame(enroll=sum(apipop$enroll, na.rm=TRUE))
npop <- nrow(apipop)
predict(api.ratio, pop$enroll)
## regression estimator is less efficient
api.reg <- svyglm(api.stu~enroll, design=dstrat)
predict(api.reg, newdata=pop, total=npop)
## same as calibration estimator
svytotal(~api.stu, calibrate(dstrat, ~enroll, pop=c(npop, pop$enroll)))
## svyglm can also reproduce the ratio estimator
api.reg2 <- svyglm(api.stu~enroll-1, design=dstrat,
family=quasi(link="identity",var="mu"))
predict(api.reg2, newdata=pop, total=npop)
## higher efficiency by modelling variance better
api.reg3 <- svyglm(api.stu~enroll-1, design=dstrat,
family=quasi(link="identity",var="mu^3"))
predict(api.reg3, newdata=pop, total=npop)
## true value
sum(apipop$api.stu)