Problem with svyvar in survey package
On Mon, Oct 24, 2011 at 4:21 AM, amitava <amtv.statpresi at gmail.com> wrote:
I am facing a problem with a function in survey package. The function svyvar gives the estimated population variance from a given sampling scheme. ?I am working with a data having more than four continuous variables. In order to have have population total for all those cont. variables I have written in the following format svyvar(~var1+var2+var3+var4+var5+var6,data) ; var1,var2,...,var6 are 6 cont. variables Now the problem is that,this function works properly when the number of cont. variables are less than or equal to three. But when the number of variables goes beyond three it gives a wrong answer,where we have two estimates for the 1st variable (here it is var1),and one of the variable is dropped,and also estimates differs. Sometimes it comes out to be a negative quantity.
You will have to give more information: what you describe does not happen when I use svyvar. For example, using one of the built-in data sets:
data(api) dclus1<-svydesign(id=~dnum, weights=~pw, data=apiclus1, fpc=~fpc) v
variance SE api00 11182.82 1386.414 api99 12735.21 1450.082 ell 285.01 54.081 mobility 127.11 55.790 meals 709.07 102.109
v<-svyvar(~api00+api99, dclus1) v<-svyvar(~api00+api99+ell+mobility+meals, dclus1) svyvar(~api00+api99, dclus1)
variance SE api00 11183 1386.4 api99 12735 1450.1
svyvar(~ell+mobility, dclus1)
variance SE ell 285.01 54.081 mobility 127.11 55.790
svyvar(~meals, dclus1)
variance SE meals 709.07 102.11 I assume you are using a current version of survey -- there was a bug in printing svyvar results (though not in calculating them), but that was fixed well over a year ago, as listed in the NEWS file.
Thomas Lumley Professor of Biostatistics University of Auckland