[R] vcov function and cross terms

Daniela Droguett daniela.droguett.leon at gmail.com
Wed Oct 15 15:27:05 CEST 2014


Hi,

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.

​From the code in the survey package manual:​

​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)

I have tried the following changes in order to get the variance matrix
estimation (as part of Taylor Linearization).

> data(api)
> dclus1<-svydesign(id=~dnum, weights=~pw, data=apiclus1, fpc=~fpc)

​> mns<-svyby(~api00+api99, ~stype, dclus1, svytotal)
> mns
  stype     api00     api99 se.api00 se.api99
E     E 3162561.8 2962356.8 842713.7 796474.0
H     H  293115.0  282283.9 104059.8 101492.9
M     M  534308.7  514982.0 108710.7 105036.6
> vcov(mns)
             E:api00     H:api00     M:api00      E:api99     H:api99
M:api99
E:api00 710166313660           0           0            0           0
    0
H:api00            0 10828434454           0            0           0
    0
M:api00            0           0 11818006832            0           0
    0
E:api99            0           0           0 634370797647           0
    0
H:api99            0           0           0            0 10300818294
    0
M:api99            0           0           0            0           0
11032691751
Warning message:
In vcov.svyby(mns) : Only diagonal elements of vcov() available

How to obtain the cross terms in the matrix above?

I have no clue on how to implement that.

Thanks a lot!

	[[alternative HTML version deleted]]



More information about the R-help mailing list