cerman at u.washington.edu
2010-Mar-16 06:01 UTC
[R] Including entire dataframe in svyglm formula
Hello!
I am attempting to use svyglm {survey package} with a large set of predictors
and would like to be able to automatically use all the variables in my data as
the predictors without having to type out their names explicitly, similar to the
way one can do:
x1=c(1,2,3,4)
x2=c(3,5,4,1)
y = x1+x2+rnorm(4,0,1)
xdataframe = data.frame(x1,x2)
lm(y~., data=xdataframe)
#or
lm(y~xdataframe)
and the period or dataframe name will cause all predictors to be included. I
have been trying that with the following code (and all sorts of permutations
thereof):
svd = svydesign(id =~PSUSCID, weights=~GSWGT1, data=data.frame(cbind(y1,
xfull)))
model = svyglm(y1~., data=svd$variables[,-1], design=svd)
where y1 is a vector of my independent variable and xfull is a matrix of my
independent variables. I receive the following error:
Error in svyglm.survey.design(y1 ~ ., data = svd$variables, design = svd) :
all variables must be in design= argument
Is there any way I can avoid explicitly typing out the names of all the
predictors in my formula in svyglm? (I have 60+.) Thanks so much!
-nate cermak
student, university of washington