Re: [R] stats::lm has inconsistent output when adding constant to dependent variable

2019-10-03 Thread Aleš Žiberna
In one case they are exactly 0 and in the other they are almost zero. This is the reason for different results. Of course, they should be exactly the same, but this is due to some integer values not being exactly represented as real values on binary computers. Best, Aleš Žiberna On Fri, Sep 27,

Re: [R] stats::lm has inconsistent output when adding constant to dependent variable

2019-09-28 Thread Mark Leeds
Hi Berwin: Yes, that's it. Donsker is famous for a functional CLT so I was mixing up statistics and stochastic processes I better stick to statistics. It's safer. ! Thanks for correction. I'm ccing R-help since it may be useful to someone there. See below for Berwin's comment. Mark On Sat,

Re: [R] stats::lm has inconsistent output when adding constant to dependent variable

2019-09-27 Thread Rui Barradas
Hello, Maybe FAQ 7.31? Check the residuals, they are all "zero" in both cases: fit0 <- lm(y~x) fit1 <- lm(1+y~x) # residuals table(resid(fit0)) # # 0 #30 table(resid(fit1)) # #-5.21223595241838e-16 -4.93038065763132e-31 3.12734157145103e-15 #623

Re: [R] stats::lm has inconsistent output when adding constant to dependent variable

2019-09-27 Thread Mark Leeds
correction to my previous answer. I looked around and I don't think it's called the donsker effect. It seems to jbe referred to as just a case of "perfect separability.". if you google for" perfect separation in glms", you'll get a lot of information. On Fri, Sep 27, 2019 at 2:35 PM Mark Lee

Re: [R] stats::lm has inconsistent output when adding constant to dependent variable

2019-09-27 Thread Mark Leeds
Hi: In your example, you made the response zero in every case which is going to cause problems. In glm's, I think they call it the donsker effect. I'm not sure what it's called in OLS. probably a lack of identifiability. Note that you probably shouldn't be using zeros and 1's as the response in a

[R] stats::lm has inconsistent output when adding constant to dependent variable

2019-09-27 Thread David J. Birke
Dear R community, I just stumbled upon the following behavior in R version 3.6.0: set.seed(42) y <- rep(0, 30) x <- rbinom(30, 1, prob = 0.91) # The following will not show any t-statistic or p-value summary(lm(y~x)) # The following will show t-statistic and p-value summary(lm(1+y~x)) My expec