[R] score test statistic in logistic regression

Greg Dropkin gregd at gn.apc.org
Tue Mar 3 23:56:39 CET 2009


re post from

bkelcey at umich.edu bkelcey at umich.edu
Wed Feb 27 15:09:48 CET 2008

If the response y is given as the proportion of successes out of n trials,
and y, n, p, x, and z are vectors of length M, and the model is logit(p) =
b0 + b1*x + b2*z then for the score test for the null hypothesis b1=0 use

des<-array(c(rep(1,M),x,z),dim=c(M,3))
m0<-glm(y~z,binomial,weights=n)
f<-fitted(m0)
efscor<-1:3
for (i in 1:3)
{
efscor[i]<-sum((y-f)*n*des[,i])
}
fim<-outer(1:3,1:3)
for (i in 1:3)
{
for (j in 1:3)
{
fim[i,j]<-sum(des[,i]*des[,j]*n*f*(1-f))
}
}
score<-crossprod(efscor,crossprod(solve(fim),efscor))
score


ok?

greg




More information about the R-help mailing list