justin jarvis
2011-Oct-05 19:32 UTC
[R] calling a variable which in turn calls many more variables
Hi all, I am running regressions with many covariates, most of which remain the same each time (control variables). Instead of writing 30 demographic variables every regression, is there a way I could call them all at once using a variable called, perhaps "demog"? I have tried:> demog <- list(age1, age2, age3) but I get an error when I try to call alist in a regression. I also tried:> demog <- cbind(age1, age2, age3) which allows me to run a regression, butthis is not practical because when I subset the original data set and run a regression, this new matrix demog doesn't get subsetted as well, so the variables are of differing length. I'm thinking there is an easy way to do this. Thanks for any help guys/gals. Justin PhD student, University of California, Irvine [[alternative HTML version deleted]]
Ista Zahn
2011-Oct-05 19:37 UTC
[R] calling a variable which in turn calls many more variables
Hi Justin, On Wed, Oct 5, 2011 at 3:32 PM, justin jarvis <littledude.jarvis at gmail.com> wrote:> Hi all, > I am running regressions with many covariates, most of which remain the same > each time (control variables). ?Instead of writing 30 demographic variables > every regression, is there a way I could call them all at once using a > variable called, perhaps "demog"?I would create a base model with just the covariates, and then use update() to add other variables. Best, Ista> > I have tried: >> demog <- list(age1, age2, age3) but I get an error when I try to call a > list in a regression. > > I also tried: >> demog <- cbind(age1, age2, age3) which allows me to run a regression, but > this is not practical because when I subset the original data set and run a > regression, this new matrix demog doesn't get subsetted as well, so the > variables are of differing length. > > I'm thinking there is an easy way to do this. ?Thanks for any help > guys/gals. > > Justin > PhD student, > University of California, Irvine > > ? ? ? ?[[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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. >-- Ista Zahn Graduate student University of Rochester Department of Clinical and Social Psychology http://yourpsyche.org