Hello,

I’m having a weird issue with the function “svychisq” in package “survey", 
which would be very helpful for me in this case.

I’m tabulating age categories (a factor variable subdivided into 4 categories: 
[18,25), [25, 45), [45,65), [65, 85) ) with respect to ethnicity/race (another 
factor variable subdivided into “hispanic white”, “non hispanic black”, 
“hispanic black”).

I’m perfectly able to get to the “svytable" object, which looks like this

> svytable(~age+ETN, design=sv1)
         ETN
age       hisp black hispanic white non hisp black
  [18,25)   26.97019      798.87444      183.61834
  [25,45)  145.19650     4783.47678      854.82748
  [45,65)  104.83682     2537.15021      595.04924
  [65,85]    0.00000        0.00000        0.00000

 Since it has last row equal to 0 (which would give me troubles with the 
corresponding chi-square p-value), I try to get rid of it by using

> svytable(~factor(age)+ETN, design=sv1)
           ETN
factor(age) hisp black hispanic white non hisp black
    [18,25)   26.97019      798.87444      183.61834
    [25,45)  145.19650     4783.47678      854.82748
    [45,65)  104.83682     2537.15021      595.04924

which exactly responds to what I’m looking for and to what I’m expecting.

The design is built by using

sv1 = svydesign(ids=~factor(age)+ETN, weights=~WTFA.n, data=totfor)

Now, if I would like to evaluate the corresponding weighted chi squared test, I 
use

svychisq(~factor(age)+ETN, design=sv1)

but here’s what I get from R: 

> svychisq(~factor(age)+ETN, design=sv1)
Error in `[.data.frame`(design$variables, , as.character(rows)) : 
  undefined columns selected

Maybe it is a stupid question but I really can’t figure out where the error is.

Could you please help me with this?
Thanks in advance for any information you will provide me with!

Emanuele

***********************************************************************
Emanuele Mazzola, Ph.D.
Department of Biostatistics & Computational Biology
Dana-Farber Cancer Institute
450 Brookline Ave 
Mail Location: LC1056 
Office Location: Longwood Center, Room 1056
Boston, MA 02215
Office phone 617-582-7614
Fax 617-632-2516


        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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