0

I'm trying to perform interaction test on a dataset with 23 variables. Following is a loop for interaction terms test among all variables, but the code does not retain variable tested before. How to make the correction allowing summary to display interaction among all variable such as xyz rather than xy and yx separately?

vars=colnames(happiness_logper1)[-1] 
varHap <- rep(0,100)
for (i in vars)  {
for (j in vars) {
if (i != j) {
varHap= paste(i,j,sep='*')}
lm.fit <- lm(paste("Happiness.in.life ~", varHap), data=happiness_logper1)
     print(summary(lm.fit))
}
  }
lydias
  • 841
  • 1
  • 14
  • 32
  • Please include a reproducible [example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). – LyzandeR Dec 18 '17 at 19:15
  • 1
    This is statistically dangerous. Anyone giving an answer will be contributing to the delinquency of a statistical "minor". The degrees of freedom reported will not be correct. You are in "multiple comparisons" purgatory. – IRTFM Dec 18 '17 at 19:50

0 Answers0