Skip to content
Back to formatted view

Raw Message

Message-ID: <CAJ55+d+GD92YUgiDQiZq7WVV9+p+YwGi-SiP6UXnMXX4_BvtKg@mail.gmail.com>
Date: 2012-10-16T20:45:26Z
From: Thomas Lumley
Subject: Package survey: Compute standard deviations from complex survey designs
In-Reply-To: <507D2B85.6040505@iqb.hu-berlin.de>

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