[R] Help with GLM please!

Peter Ehlers ehlers at ucalgary.ca
Thu Sep 3 22:23:04 CEST 2009


(I haven't seen a response to this - might have missed it.)

see inline

Lars Bishop wrote:
> Dear experts,
> 
> I have a few quick questions related to GLMs:
> 
> 1) Suppose my response is of the type Yes/No, How can I control which
> response I'm modelling?
By selecting the appropriate reference level. As ?glm tells you,
the first level of a factor response denotes 'failure'.

> 
> 2) How can I perform Type III tests?  Is it with -> drop1(mymodel,
> test="Chisq") ?
If you really want type III tests, you could have a look at
the 'car' package.

> 
> 3) I have a numerical variable which I converted to an ordered factor as
> shown below, but in the summary results of the logistic regression I get
> labels for this variable which are not the ones I specified (I get labels I
> even don't know where they are coming from)?
Actually, you're getting exactly the labels that you specified.
Try labels 'A', 'B', 'C' to see how the printout works.

Cheers,
Peter Ehlers

> 
> set.seed(12345)
> dv <- gl(n=2, k=1, length=20, label=c("Yes", "No"))
> x1 <- rnorm(n=20, mean=100, sd=10)
> x2 <- gl(n=3, k=1, length=20, label=c("x2_1", "x2_2", "x2_3"))
> mydata <- data.frame(dv,x1,x2)
> mydata$f.x1  <- cut(x1, breaks=c(80,90,100,120))
> mydata$f.x1 <- ordered(mydata$f.x1, labels=c("L1", "L2", "L3") ,
> levels(mydata$f.x1)) #Specify desired labels
> mydata$f.x1
> attach(mydata)
> mymodel <- glm(dv ~ f.x1 + x2, family=binomial)
> summary(mymodel)
> drop1(mymodel, test="Chisq") #Type 3 test?
> 
> lastly,
> 
> 4) how can I test statistical significance between levels of a factor?
> 
> Thanks a lot for your help!
> 
> Lars.
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
>




More information about the R-help mailing list