Skip to content

survey package svystat objects from predict()

2 messages · Kieran Healy, Thomas Lumley

#
Hello, 

I'm running R 2.14.1 on OS X (x86_64-apple-darwin9.8.0/x86_64 (64-bit)), with version 3.28 of Thomas Lumley's survey package. I was using predict() from svyglm(). E.g.:

data(api)
dstrat<-svydesign(id=~1,strata=~stype, weights=~pw, data=apistrat, fpc=~fpc)
out <- svyglm(sch.wide~ell+mobility, design=dstrat,
        family=quasibinomial())
pred.df <- expand.grid(ell=c(20,50,80), mobility=20)
out.pred <- predict(out, pred.df)
#
On Tue, Feb 14, 2012 at 11:45 AM, Kieran Healy <kjhealy at gmail.com> wrote:
Mostly correct, but the relevant SE method is actually SE.default
survey:::SE.default
function (object, ...)
{
    sqrt(diag(vcov(object, ...)))
}

It can't be SE.svrepstat, because the class is wrong.

If you define
SE.svystat<-function(object,...){
   v<-vcov(object)
   if (!is.matrix(v) || NCOL(v)==1) sqrt(v) else sqrt(diag(v))
 }

it should work.

    -thomas