[R] add1 in glm

Murray Jorgensen maj at stats.waikato.ac.nz
Tue Nov 5 01:47:39 CET 2002


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

-- 
Dr Murray Jorgensen      http://www.stats.waikato.ac.nz/Staff/maj.html
Department of Statistics, University of Waikato, Hamilton, New Zealand
Email: maj at waikato.ac.nz                                Fax 7 838 4155
Phone  +64 7 838 4773 wk    +64 7 849 6486 home     Mobile 021 395 862

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list