I am trying to figure out how to make a for loop that does a regression 10 times and then puts it in an 10x11 matrix.
Here is the code I am using and for some reason it is not working...
for (i in 1:10) {
Pwdlm.list[[i]] =
lm(Pwd[,9+i]~logwprice1+logwprice2+logwprice3+logwprice4+
logwprice5+logwprice6+logwprice7+logwprice8+logwprice9+logwprice10+
Pwd$storeid, data=Pwd)
}
Pwdmat = matrix(Pwdlm.list[[i]]$coefficients, nrow = 10, ncol = 11)
I keep getting this warning:
Warning message: In matrix(Pwdlm.list[[i]]$coefficients, nrow = 10, ncol = 11) : data length [25] is not a sub-multiple or multiple of the number of rows [10]
But I need the data to fit in to 10 rows.
I understand it is hard without seeing the data but I am unsure if it has something to do with the [,9+i]