Hello everybody, I have encountered the following problem with lm():
When running lm() with a regressor close to zero - of the order e-10, the value of the estimate is of huge absolute value , of order millions. However, if I write the formula of the OLS estimator, in matrix notation: pseudoinverse(t(X)*X) * t(X) * y , the results are correct, meaning the estimate has value 0. here is the code: y <- rnorm(n_obs, 10,2.89) x1 <- rnorm(n_obs, 0.00000000000001235657,0.000000000000000045) x2 <- rnorm(n_obs, 10,3.21) X <- cbind(x1,x2) bFE <- lm(y ~ x1 + x2) bFE bOLS <- pseudoinverse(t(X) %*% X) %*% t(X) %*% y bOLS Note: I am applying a deviation from the mean projection to the data, that is why I have some regressors with such small values. Thank you for any help! Raluca -- View this message in context: http://r.789695.n4.nabble.com/Error-in-lm-with-very-small-close-to-zero-regressor-tp4705185.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.