[R] Error in lm() with very small (close to zero) regressor
RiGui
raluca.gui at business.uzh.ch
Sat Mar 28 00:32:26 CET 2015
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.
More information about the R-help
mailing list