Hi,

I have two datasets, x and y. Simplified x and y denote:

 X

Y

 A B C A B C  . . . . . .  . . . . . .  . . . . . .
I want to implement all possible models such as lm(X$A~Y$A), lm(X$B~Y$B),
lm(X$C~Y$C)... I have tried the following:

fun<- function(x,y){
            for(i in 1:length(colnames(x))){
              for(j in 1:length(colnames(y))){
               if(colnames(x)[i]==colnames(y)[j]){
               models=list(lm(ts(x[i])~ts(y[j])))
               }
               else{}
            }
          }
           return(models)
}

The problem is that this returns only one of the three models, namely the
last one. What am I doing wrong? Thank you very much in advance.

Regards

	[[alternative HTML version deleted]]

