extractors.Rd
These functions extract standard errors (SE
), variances (VAR
), coefficients of variation (cv
) and design effects (deff
) from an object which has been returned by a survey statistic function (e.g. svystatTM
, svystatR
, svystatS
, svystatSR
, svystatB
, svystatQ
, svystatL
, svystat
, ...).
SE(object, ...) VAR(object, ...) cv(object, ...) deff(object, ...)
object | An object containing survey statistics. |
---|---|
... | Arguments for future expansion. |
With the exception of deff
, all extractor functions can be used on any object returned by a survey statistic function: the correct answer will be obtained whatever the call that generated the object. For getting the design effect, object
must have been built with option deff = TRUE
or deff = "replace"
.
A data structure (typically inheriting from classes matrix
or data.frame
) storing the requested information.
Package ReGenesees provides extensions of methods coef
and confint
(originally from package stats) that can be used to extract estimates and confidence intervals respectively.
Function coef
to extract estimates and function confint
to extract confidence intervals. Estimators of Totals and Means svystatTM
, Ratios between Totals svystatR
, Shares svystatS
, Ratios between Shares svystatSR
, Multiple Regression Coefficients svystatB
, Quantiles svystatQ
, Complex Analytic Functions of Totals and/or Means svystatL
, and all of the above svystat
.
# Creation of a design object: data(sbs) des<-e.svydesign(data=sbs,ids=~id,strata=~strata,weights=~weight, fpc=~fpc) # Estimation of the average value added at the # nation level (by default one gets the SE): VA.avg <- svystatTM(des,~va.imp2,estimator="Mean") VA.avg#> Mean SE #> va.imp2 3250.599 58.38824# Extractions of some variance statistics from the # object above: ## 1) SE SE(VA.avg)#> SE.va.imp2 #> 1 58.38824## 2) CV cv(VA.avg)#> CV.va.imp2 #> 1 0.0179623## 3) VAR VAR(VA.avg)#> VAR.va.imp2 #> 1 3409.186# Design effects have to be requested in advance, # i.e. the following invocation produces an error: if (FALSE) { deff(VA.avg) } # ...while the following works: VA.avg <- svystatTM(des,~va.imp2,estimator="Mean",deff=TRUE) deff(VA.avg)#> DEff.va.imp2 #> 1 0.4426832#> va.imp2 #> 3250.599## Extract the confidence interval at 90% ## confidence level (the default would be 95%): confint(VA.avg, level=0.9)#> 5 % 95 % #> va.imp2 3154.559 3346.639## note the argument 'level', which comes from confint function in package stats