On Thu, 20 May 2010, David Winsemius wrote:
Almost. Testing with the examples on svytable help page:
test <- function(Z){
fmla <- as.formula( paste(" ~ ", paste(c(Z, "stype"), collapse= "+")))
chisq <- svychisq( fmla, design=rclus1,
statistic="adjWald", round=4)
}
reslt <- test("sch.wide")
reslt
Design-based Wald test of association
data: svychisq(fmla, design = rclus1, statistic = "adjWald", round = 4)
F = 2.2296, ndf = 2, ddf = 13, p-value = 0.1471
The "con" object probably does not exist, so one needs to pass a character
name to the formula.
That works, but you can see why I prefer
test<-function(formula){
svychisq(update(formula, ~.+stype), dclus1)
}
test(~sch.wide)
Model formulas were invented for precisely this purpose. You can work around
them using character strings or using bare symbol names and substitute, but
it's really easier just to work with the formula.
-thomas
Thomas Lumley Assoc. Professor, Biostatistics
tlum...@u.washington.edu 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.