[R] Package survey
Thomas Lumley
tlumley at u.washington.edu
Wed Oct 22 22:32:43 CEST 2008
I think this has already been fixed in version 3.9-1.
Also, you probably want to add na.rm=TRUE to the call
svyby(~p_igov,~div_a,desenho_nps,svytotal,drop.empty.groups=TRUE,vartype
=c("se","var","cvpct"), na.rm=TRUE)
otherwise the estimated total will be NA whenever any observation is NA.
-thomas
On Wed, 22 Oct 2008, Rita Sousa wrote:
> Hi,
>
> Iÿÿm using the svyby for total statistics, for example:
>
>
>
> svyby(~p_igov,~div_a,desenho_nps,svytotal,drop.empty.groups=TRUE,vartype
> =c("se","var","cvpct"))
>
>
>
> In the numerical variable p_igov (and others) I have many non responses
> but if I maintain the NA it doesnÿÿt work.
>
>
>
> summary(base_nps$p_igov)
>
> Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
>
> 1.0 9.0 51.0 208.7 185.0 19470.0 1687.0
>
>
>
> desenho_nps <-
> svydesign(id=~npc,strata=~estr_final,weights=~pond_nps,fpc=~nps_univ,nes
> t=T,data=base_nps)
>
> svyby(~p_igov,~div_a,desenho_nps,svytotal,drop.empty.groups=TRUE,vartype
> =c("se","var","cvpct"))
>
> Error in if (any(coef(object) < 0)) warning("CV may not be useful for
> negative statistics") :
>
> missing value where TRUE/FALSE needed
>
>
>
> If I replace the NA by zero it works without problem, but the doubt
> still remains because the cv estimated can be not real. Isnÿÿt it?
>
>
>
> base_nps[is.na(base_nps)]<-0
>
> svyby(~p_igov,~div_a,desenho_nps,svytotal,drop.empty.groups=TRUE,vartype
> =c("se","var","cvpct"))
>
> div_a statistics.p_igov se.p_igov var.p_igov cv%.p_igov
>
> 1 1 261791.2 9306.518 86611275 3.554940
>
> 2 2 1634590.5 45330.366 2054842079 2.773194
>
>
>
> I beg for a reply.
>
> Thanks.
>
> ---------------------------------------------------
> Rita Sousa
> Departamento de Metodologia e Sistemas de Informaÿÿÿÿo
>
> INE - DP: Instituto Nacional de Estatÿÿstica - Delegaÿÿÿÿo do Porto
>
> Tel.: 22 6072016 (Extensÿÿo: 4116)
> ---------------------------------------------------
>
>
>
>
>
Thomas Lumley Assoc. Professor, Biostatistics
tlumley at u.washington.edu University of Washington, Seattle
More information about the R-help
mailing list