[R] Package survey: Compute standard deviations from complex survey designs

Thomas Lumley tlumley at uw.edu
Tue Oct 16 22:45:26 CEST 2012


On Tue, Oct 16, 2012 at 10:40 PM, Sebastian Weirich
<sebastian.weirich at iqb.hu-berlin.de> wrote:
> Hello,
>
> svyvar from the survey package computes variances (with standard errors)
> from survey design objects. Is there any way to compute standard deviations
> and their standard errors in a similar manner?

Usually you can do this sort of transformation with svycontrast(), but
it doesn't work on the output of svyvar().  You need to use the delta
method directly.

#compute variances
> vv<-svyvar(~api00+api99,dclus1)
## variance
> coef(vv)	
         api00    api99
api00 11182.82 11516.33
api99 11516.33 12735.21
## variance of variance
> vcov(vv)
        api00   api00   api99   api99
api00 1922144 1920707 1920707 1851400
api00 1920707 1996169 1996169 2004475
api99 1920707 1996169 1996169 2004475
api99 1851400 2004475 2004475 2102736

## standard error is square root of variance
> sqrt(diag(coef(vv)))
   api00    api99
105.7489 112.8504
## delta method for standard error of square root of variance
> sqrt(vcov(vv)["api00","api00"]/(4*coef(vv)["api00","api00"]))
[1] 6.555219



  -thomas


-- 
Thomas Lumley
Professor of Biostatistics
University of Auckland




More information about the R-help mailing list