[R] dynamically specifying regressors/RHS variables in a regression
bennett at haas.berkeley.edu
Sat May 5 07:24:20 CEST 2007
Does anyone know if there is a way to specify regressors dynamically
rather than explicitly?
More specifically, I have a data set in "long format" that details a
number of individuals and their responses to a question (which can be
positive, negative, or no answer). Each individual answers as many
questions as they want, so there are a different number of rows per
For each number of questions, I want to run a logit on all the
individuals who saw that many questions, predicting whether they
choose to answer anymore afterwards by their choices on the earlier
the second logit would look like
This will result in over 100 regressions, with different numbers of
RHS variables. I'd like to iterate over the sequence of numbers and
run a logit for each, but I can't find any means for dynamically
generating the RHS variable from an array, or vector. The only way I
can think of to write the function would still require the same number
of RHS variables in each regression.
Is there a way to dynamically generate the right hand side?
More information about the R-help