[R] Exactly Replicating Stata's Survey Data Confidence Intervals in R

Thomas Lumley tlumley at uw.edu
Sun Sep 23 22:30:51 CEST 2012


On Sat, Sep 22, 2012 at 2:51 AM, Anthony Damico <ajdamico at gmail.com> wrote:

> Survey: Mean estimation
>
> Number of strata =       1          Number of obs    =     183
> Number of PSUs   =      15          Population size  =  9235.4
>                                     Design df        =      14
>
> --------------------------------------------------------------
>              |             Linearized
>              |       Mean   Std. Err.     [95% Conf. Interval]
> -------------+------------------------------------------------
>         ell0 |   .0218579   .0226225     -.0266624    .0703783
> --------------------------------------------------------------

This matches

> svyciprop(~I(ell==0),dclus1,df=14,method="mean")
                             2.5%   97.5%
I(ell == 0)  0.0218579 -0.0266624 0.07038

as does this

> confint(svymean(~I(ell==0),dclus1),df=14)
                          2.5 %        97.5 %
I(ell == 0)FALSE  0.92962174505 1.02666240796
I(ell == 0)TRUE  -0.02666240796 0.07037825495

The df= argument is not explicitly documented in ?svyciprop, but it is
in ?confint.svystat and ?svymean

[I was slowed down a bit by the claim that the Stata intervals were
asymmetric, but in fact they aren't]

   -thomas

-- 
Thomas Lumley
Professor of Biostatistics
University of Auckland




More information about the R-help mailing list