> On 28 Mar 2015, at 00:32 , RiGui <raluca....@business.uzh.ch> wrote: > > 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 > Example not reproducible:
> y <- rnorm(n_obs, 10,2.89) Error in rnorm(n_obs, 10, 2.89) : object 'n_obs' not found > x1 <- rnorm(n_obs, 0.00000000000001235657,0.000000000000000045) Error in rnorm(n_obs, 1.235657e-14, 4.5e-17) : object 'n_obs' not found > x2 <- rnorm(n_obs, 10,3.21) Error in rnorm(n_obs, 10, 3.21) : object 'n_obs' not found > X <- cbind(x1,x2) Error in cbind(x1, x2) : object 'x1' not found > > bFE <- lm(y ~ x1 + x2) Error in eval(expr, envir, enclos) : object 'y' not found > bFE Error: object 'bFE' not found > > bOLS <- pseudoinverse(t(X) %*% X) %*% t(X) %*% y Error: could not find function "pseudoinverse" > bOLS Error: object 'bOLS' not found -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd....@cbs.dk Priv: pda...@gmail.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.