I have a data set read as follows
test<-read.csv("data.csv",sep=",",header=T)
There are 10 predictor variables. The first column is response variables
x<-test[,-c(1)]
y<-test[,1]
If I would like to test a model with the first three predictor variables including their interaction terms, here is what I did with lm
test.model<-lm(y~x[,1]*x[,2]*x[,3], data=test)
But it turns out that the the resulting model also includes the interaction term of x[, 1]:x[, 2]:x[, 3]
How can I limit the model with just two factor interactions, such as x[, 1]:x[, 2]
, x[, 2]:x[, 3]
and x[, 1]:x[, 3]
If I would like to consider all 10 predictor variables, instead of writing x[,1]*x[,2]*x[,3]*x[,4]*...x[,10]
, are there convienent ways to write this formula?