Skip to content
Prev 24952 / 398502 Next

add1 in glm

I'm having a bit of difficulty using the stepwise model-building tools 
in a glm context. Here, for example is one problem I have had using 
add1, where the abbreviation "." does not work as I expected it to do. I 
someone could point me towards some examples involving the interactive 
building of glm models I would be grateful.

The data set that I am using is the "Student's Goals" dataset from DASL.

 > goals.df <-read.table("C:\\Data\\DASL\\goals.txt", header = TRUE)
 > goals.df <- goals.df[,2:8]
 > goals.df[1:3,]
   Gender Grade Res Goals MOST LEAST Count
1      1     4   1     1    2     1     1
2      1     4   1     1    2     3     1
3      1     4   1     2    1     3     1
 > const <-glm(formula=Count~1,family = poisson(link = "log"), 
data=goals.df)
 > add1(const, Count ~ .)
Error in if (ncol(add) > 1) { : missing value where logical needed
 > add1(const, ~ Gender+Grade+Res+Goals+MOST+LEAST)
Single term additions

Model:
Count ~ 1
        Df Deviance    AIC
<none>      214.03 770.85
Gender  1   212.72 771.55
Grade   1   206.96 765.79
Res     1   213.25 772.08
Goals   1   208.33 767.16
MOST    1   211.30 770.13
LEAST   1   208.71 767.54