Hi, thank you for taking the time and reading my question. My question is twofold:
1. I have several matrices with variables and one matrix with water levels. I want to predict the water level with the data in the other matrices. Basically, * mod<-lm(matrix1 ~ matrix2+matrix3)* ( What looks like a minus is meant to be the wiggly minus.) Of course I could dissemble the matrices and paste their columns into one long, long vector. But the method above gives reasonable results. Are there any methodological objections against doing this? 2. After having done the regression I now want to make a prediction. Thus given the coefficients of my regression mod and matrix2 and matrix3 I want to predict a new matrix. This is where the matrix approach becomes difficult. I made it work, but it is very unelegant: *pred<-rep(coef(mod)[1],2)+coef(mod)[2]*matrix2+coef(mod)[3]*matrix3 PRED<-matrix(pred, nrow=length(matrix1[,1]), ncol=length(matrix1[1,]), byrow=F)* Is there a more elegant way of doing this? Because I dont have two but six matrices as independent variables, so it becomes pretty lengthy. I could not make the command predict() work for this. Thank you! -- View this message in context: http://r.789695.n4.nabble.com/correlating-matrices-tp4643660.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.