# [S] update glm: why aren't these nested?

David Maxwell SS CEFAS (D.L.MAXWELL@cefas.co.uk)
Wed, 18 Mar 1998 17:09:00 +0000

My thanks to Bill Venables, Terry Elrod and Brian Ripley for quickly responding and pointing out that the fitting may not have converged using the default settings in glm.control (as stated in V&R 2 pg228).

Unfortunately tightening up the convergence criteria didn't solve the problem, see below.

I also tried the fudge of replacing the ten y values of 0 with a small positive value to see what effect it had. The smallest non zero value of y is 0.001364. Replacing 0 with 0.001 gives an anova without negative deviances, replacing 0 with 0.00001 causes problems again (although in a different place in the table), see below for anyone who's interested.

Any solutions? Anyone from MathSoft got an explanation?

Cheers, David.
d.l.maxwell@cefas.co.uk

######################

GLM linear loop 1: deviance = 144.3042
...
GLM linear loop 16: deviance = 74.2373

> anova(sp3.glm)
Analysis of Deviance Table
Gamma model
Response: y

Terms added sequentially (first to last)
Df Deviance Resid. Df Resid. Dev
NULL 72 137.4406
log(x) 1 8.28890 71 129.1517
dose.val 1 55.10674 70 74.0449
factor(dose.val) 2 -0.19241 68 74.2373

###############

sp.001<-sp.dat
sp.001\$y[sp.001\$y==0]<-0.001

GLM linear loop 1: deviance = 395.5469
..
GLM linear loop 13: deviance = 185.3129

> anova(sp4.glm)
Analysis of Deviance Table
Gamma model
Response: y

Terms added sequentially (first to last)
Df Deviance Resid. Df Resid. Dev
NULL 72 270.2704
log(x) 1 11.32972 71 258.9407
dose.val 1 72.52934 70 186.4114
factor(dose.val) 2 1.09843 68 185.3129

##############

sp.00001<-sp.dat
sp.00001\$y[sp.00001\$y==0]<-0.00001

GLM linear loop 1: deviance = 1000.557
....
GLM linear loop 20: deviance = 277.2427

> anova(sp5.glm)
Analysis of Deviance Table
Gamma model
Response: y

Terms added sequentially (first to last)
Df Deviance Resid. Df Resid. Dev
NULL 72 362.3479
log(x) 1 -128.5120 71 490.8600
dose.val 1 207.2757 70 283.5843
factor(dose.val) 2 6.3416 68 277.2427

#####################################################################################
David Maxwell wrote:
>
> I have a numeric variable, dose.val, with 4 different values. I fitted two models using glm:
>
> 1.
>
> 2.
>
>
> I intuitively expected model 2 to be nested in model 1, i.e. that the deviance due to factor(dose.val) could be split into the deviance due to linear dose.val and the remaining deviance.
>
> But fitting dose.val as a number gives a slightly lower residual deviance than when it is fitted as a factor, see the anovas below.
>
> Please can someone explain this to me or provide a suitable reference.
>
>Other info:
>10 of the 73 values for y are zero
>SPlus v3.3 windows 3.11

-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news