Skip to content
Prev 165557 / 398506 Next

lm() with same formula but different column/factor combinations in data frame

Thanks for replying Gabor.

I checked the leaps() function and i think it is intended to find the
best combination of predictors in the linear model.
Does leaps have a way to combine different factor columns in my data
frame as follows :

I have the regression model fixed. The combination of predictor
variables used always remains the same.
UncDmd ~ M1 + M2 + M3 + M4 + M5 + M6 + M7 + M8 + M9 + M10 + M11

I want to get the coefficients in this linear model  when different
combinations of factors (select a combination from first four columns
of the data frame) and their levels are taken from a data frame(apply
lm model for a each combination of levels within the selected factor
columns). Thus corresponding to each combination, the data used to
determine the model coefficients will be different.

I am attaching the data and R files (long method using loops) that I
use to get the result. Currently, I modify keys to get different
combinations. Also, note in the script, the data frame is named LRO1.

Thanks again,
Murtaza


On Fri, Dec 26, 2008 at 12:58 PM, Gabor Grothendieck
<ggrothendieck at gmail.com> wrote: