Here I want to create a list of formula for a simple linear regression, 2nd and 3rd order polynomial models. I just did this. It could be ok for a few variables but my data is a quite lot variables. So how could I avoid overloading work using another way to do the same thing?
ind1.lm <- lm(dep ~ ind1, data = df)
ind1.qd <- lm(dep ~ poly(ind1, 2, raw = TRUE), data = df)
ind1.cb <- lm(dep ~ poly(ind1, 3, raw = TRUE), data = df)
ind2.lm <- lm(dep ~ ind2, data = datAll)
ind2.qd <- lm(dep ~ poly(ind2, 2, raw = TRUE), data = df)
ind2.cb <- lm(dep ~ poly(ind2, 3, raw = TRUE), data = df)
ind3.lm <- lm(dep ~ ind3, data = df)
ind3.qd <- lm(dep ~ poly(ind3, 2, raw = TRUE), data = df)
ind3.cb <- lm(dep ~ poly(ind3, 3, raw = TRUE), data = df)
formula.list <- list(as.formula(ind1.lm), as.formula(ind1.qd),
as.formula(ind1.cb), as.formula(ind2.lm), as.formula(ind2.qd),
as.formula(ind2.cb), as.formula(ind3.lm), as.formula(ind3.qd),
as.formula(ind3.cb))
formula.list
Thanks in advance!