I'm trying to regress each column of a matrix (dependent variable) against a single column vector (independent variable), and store the coefficients and residuals. Here's a sample data and my code so far:
gwthRatesAllCities06To08 <- matrix(1:60, nrow = 4, ncol = 15)
natGwthRates06To08 <- c(2,1,3,5)
for (i in 1 : ncol(gwthRatesAllCities06To08)) {
OLSEst[[i]]<- lm(formula = gwthRatesAllCities06To08[,i] ~ natGwthRates06To08)
}
However, the code above does not give me what I want, could you please help me figure out the reason? Many thanks in advance!