I am running a simple multivariate regression on a panel/time-series dataset, using lm()
and the underlying formula $(X'X)^{-1} X'Y$
expecting to get the same coefficient values from the two methods. However, I get completely different estimates.
Here is the R code:
return = matrix(ret.ff.zoo, ncol = 50) # y vector
data = cbind(df$EQ, df$EFF, df$SIZE, df$MOM, df$MSCR, df$SY, df$UMP) # x vector
#First method
BETA = solve(crossprod(data)) %*% crossprod(data, return)
#Second method
OLS <- lm(return ~ data)
I am not sure why the estimates are different between the two methods..
Any help is appreciated! Thank you.