I'm trying to test linear models with different interactions removed, e.g.
lmtest<-lm(out1~(.)^2 - var4:var5, data=dt1)
The interactions I'm testing for are stored in a character vector cvect = (var1:var2, var1:var3... etc), and I'm looking to use these to drop interactions. I've tried
lmtest<-lm(out1~(.)^2 - cvect[5], data=dt1)
lmtest<-lm(out1~(.)^2 - noquotes(cvect[5]), data=dt1)
lmtest<-lm(out1~(.)^2 - paste(cvect[5]), data=dt1)
But neither of these worked. Is there an alternative way of making this approach work?
question from:
https://stackoverflow.com/questions/65923317/using-character-as-an-object-for-linear-model-r 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…