[R] Score Test Function

peter dalgaard pdalgd at gmail.com
Sun Jun 12 10:22:41 CEST 2011


On Jun 12, 2011, at 07:54 , <Bill.Venables at csiro.au> <Bill.Venables at csiro.au> wrote:

> The score test looks at the effect of adding extra columns to the model matrix.  The function glm.scoretest takes the fitted model object as the first argument and the extra column, or columns, as the second argument.  Your x2 argument has length only 3.  Is this really what you want?  I would have expected you need to specify a vector of length nrow(DF), [as in the help information for glm.scoretest itself].
> 

glm.scoretest will only do single-df tests, so it's not going to help here. 

Notice that the test requested is a whole-model test, i.e. a comparison of the fitted model with an intercept-only model (AKA a null model). It is not a goodness of fit test (which is a good thing as those are often dubious with binary responses). In R-devel, we can do score tests for such model comparisons as follows:

> mod2<-glm(reading.recommendation~1,family=binomial,data=DF)
> anova(mod1,mod2,test="Rao")
Analysis of Deviance Table

Model 1: reading.recommendation ~ reading.score + gender
Model 2: reading.recommendation ~ 1
  Resid. Df Resid. Dev Df Deviance   Rao Pr(>Chi)   
1       186     224.64                              
2       188     234.67 -2  -10.033 -9.53 0.008523 **
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

This is pretty close to the cited SAS result. I cannot tell where the .01 discrepancy creeps in, but the GLM algorithm is not 1-step convergent for the null model, even though the solution can be written down explicitly.  (I don't have SAS to hand, but if anyone does, it would be interesting to see if it still says 9.5177 with the same data). 


With the current R, the closest you get is the asymptotically equivalent LRT:

> anova(mod1,mod2,test="Chisq")
Analysis of Deviance Table

Model 1: reading.recommendation ~ reading.score + gender
Model 2: reading.recommendation ~ 1
  Resid. Df Resid. Dev Df Deviance Pr(>Chi)   
1       186     224.64                        
2       188     234.67 -2  -10.033 0.006626 **
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 


-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



More information about the R-help mailing list