[R] "vcov" error in svyby and svytable functions

Thomas Lumley tlumley at u.washington.edu
Mon Aug 21 20:44:46 CEST 2006

On Mon, 21 Aug 2006, Debarchana Ghosh wrote:

> Hi,
> I'm trying to compute survey svytable statistic on subsets by using the
> svyby function.
> Here is the code:
> b<-svyby(~V024+V751, by=~V025, design=strat2, svytable, round=TRUE)
> The vars, V024, V751 and V025 are factors. The by var has 2 levels, and
> hence there will be two subsets. strat2 is created by the svydesign function.

> It's giving me the following error:
>> b<-svyby(~V024+V751, by=~V025, design=strat2, svytable, round=TRUE)
> Error in vcov(object, ...) : no applicable method for "vcov"
> I can't understand what "vcov" is and why it is giving this error because
> both svyby and svytable functions do not have "vcov" as one of their
> arguements. I tried svytable without the svyby and it works fine.

The problem is that svytable() does not produce standard errors. As 
help(svyby) says


      Asking for a design effect ('deff=TRUE') from a function that does
      not produce one will cause an error or incorrect formatting of the
      output. The same will occur with 'keep.var=TRUE' if the function
      does not compute a standard error.

Adding  keep.var=FALSE to the svyby() call, which tells svyby() not to 
extract standard errors, should fix the problem.

If you want standard errors the easiest thing is to use svytotal() rather 
than svytable:
b<-svyby(~interaction(V024,V751), by=~V025, design=strat2, svytotal)


More information about the R-help mailing list