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
[EMAIL PROTECTED]       University of Washington, Seattle
______________________________________________
R-help@r-project.org 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.

Reply via email to