Lutz Ph. Breitling
2008-Aug-10 22:04 UTC
[R] (Un-)intentional change in drop1() "Chisq" behaviour?
Dear List, recently tried to reproduce the results of some custom model selection function after updating R, which unfortunately failed. However, I ultimately found the issue to be that testing with pchisq() in drop1() seems to have changed. In the below example, earlier versions (e.g. R 2.4.1) produce a missing P-value for the variable x, while newer versions (e.g. R 2.7.1) produce 0 (2.2e-16). I would assume that the former is more appropriate, so I was just curious if this is an intentional change. Kind regards- Lutz y<-rbinom(100,1,0.5) x<-rep(0,100) m<-glm(y~x, family=binomial) summary(m) drop1(m, test="Chisq") ################# R241> drop1(m, test="Chisq") Single term deletions Model: y ~ x Df Deviance AIC LRT Pr(Chi) <none> 138.59 140.59 x 0 138.59 140.59 0.00 Warning message: NaNs produced in: pchisq(q, df, lower.tail, log.p) ################## R271> drop1(m, test="Chisq") Single term deletions Model: y ~ x Df Deviance AIC LRT Pr(Chi) <none> 137.99 139.99 x 0 137.99 139.99 0.00 < 2.2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 ###################
Prof Brian Ripley
2008-Aug-11 07:40 UTC
[R] (Un-)intentional change in drop1() "Chisq" behaviour?
The change is in pchisq: 2.4.1:> pchisq(3, 0, lower=F)[1] NaN 2.7.1:> pchisq(3, 0, lower=F)[1] 0 And that is correct according to the definition. On Mon, 11 Aug 2008, Lutz Ph. Breitling wrote:> Dear List, > recently tried to reproduce the results of some custom model selection > function after updating R, which unfortunately failed. However, I > ultimately found the issue to be that testing with pchisq() in drop1() > seems to have changed. In the below example, earlier versions (e.g. R > 2.4.1) produce a missing P-value for the variable x,Are you sure it was not NaN?> while newer versions (e.g. R 2.7.1) produce 0 (2.2e-16). > > I would assume that the former is more appropriate, so I was just > curious if this is an intentional change.In this case the computed value ought to be zero, and hence> pchisq(0, 0, lower=F)[1] 0 Given that the computed value will be unreliable, NA would be more appropriate, so will change.> Kind regards- > Lutz > > y<-rbinom(100,1,0.5) > x<-rep(0,100) > m<-glm(y~x, family=binomial) > summary(m) > drop1(m, test="Chisq") > ################# > R241> drop1(m, test="Chisq") > Single term deletions > > Model: > y ~ x > Df Deviance AIC LRT Pr(Chi) > <none> 138.59 140.59 > x 0 138.59 140.59 0.00 > Warning message: > NaNs produced in: pchisq(q, df, lower.tail, log.p) > ################## > R271> drop1(m, test="Chisq") > Single term deletions > > Model: > y ~ x > Df Deviance AIC LRT Pr(Chi) > <none> 137.99 139.99 > x 0 137.99 139.99 0.00 < 2.2e-16 *** > --- > Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 > ################### > > ______________________________________________ > R-help at r-project.org mailing list > 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. >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595