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

From: Thomas Lumley <tlumley_at_u.washington.edu>
Date: Tue 22 Aug 2006 - 04:44:46 EST

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

Note:

      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)

         -thomas



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Tue Aug 22 04:51:16 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 22 Aug 2006 - 06:23:48 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.