Possible Duplicate:
short formula call for many variables when building a model
I have a data frame that has 22,000 rows and 2,000 columns. The columns are samples and the rows are genes.
Of these 22,000 genes, 1,000 of them are predictor/independent variables. The remaining 21,000 genes are response/dependent variables.
I would like to write a model where ALL 1,000of the independent variables predict the outcome of the dependent variables, so the model would look something like this for each dependent variable:
y ~ x1 + x2 + x3 + ... + x1000
I know in R the way to write a multiple regression model is like this:
example <- lm( y ~ x1 + x2 + x3, data=test)
Right now, the data frame is such that all the variables are in rows, but I could easily transform the data set. So I have three questions:
How do I write the above example code so I can incorporate all 1000 dependent variables without having to type out x1 + ... + x1000?
Is it possible to write this equation such all 1000 dependent variables can be extracted from the data frame as ROWS? If so, how?
How can we save all the coefficient values for each of the dependent variables from the lm output automatically?