[R] svyby and vcov function problem (Survey Package)

Daniela Droguett daniela.droguett.leon at gmail.com
Wed Sep 17 22:45:57 CEST 2014


Hi all,

I would like to apply the vcov function from the survey package for the
variables api00 and api99 grouped by the stype variable which can assume H,
M and E categories (see below)

I have tried svyby but as far as I know covariant matrices don't work with
this function
​
In the code example (survey package manual) they apply the as.svrepdesign
and then svyby with svymean function but I need svyby with svytotal without
as.svrepdesign.

data(api)
dclus1<-svydesign(id=~dnum, weights=~pw, data=apiclus1, fpc=~fpc)
rclus1<-as.svrepdesign(dclus1)
mns<-svyby(~api00, ~stype, rclus1, svymean,covmat=TRUE)
vcov(mns)

how to mix the different stypes to obtain terms like:

api00:H api00:H
api00:H api00:M
api00:H api00:E
api00:H api99:H
api00:H api99:M
api00:H api99:E

api00:E api00:E
api00:E api00:M
api00:E api99:H
api00:E api99:E
api00:E api99:M

api00:M api00:M
api00:M api99:H
api00:M api99:E
api00:M api99:M

api99:H api99:H
api99:H api99:E
api99:H api99:M

api99:E api99:E
api99:E api99:M

api99:M api99:M

I have no clue on how to implement that.

Thanks a lot!
​

​Daniela.​

	[[alternative HTML version deleted]]



More information about the R-help mailing list