Hey, all.  I had a quick question about fitting new glm values and  
then looking at the error around them.  I'm working with a glm using a  
Gamma distribution and a log link with two types of treatments.   
However, when I then look at the predicted values for each category, I  
find for the one that is close to 0, the error (using se.fit=T with  
predicted) actually makes it overlap 0.  This is not possible, as  
non-0 values have no meaning.

Am I missing something in the interpretation?  I'm sure I am.  Is  
there are better way to plot this that is accurate?  Below is some  
sample code for an example problem.  Note that the error for the value  
for category a (plotted at the end) does cross 0.

Note: this is a simple example.  The model I'm using has covariates,  
etc, but, I wanted to work out the correct method for the simple  
example so that I could take it back to my more complex model.  Thanks!

#data
x<-as.factor(c(rep("a",4),rep("b",4)))
y<-c(0.5,2,0.3,1.2,32.6,43,23.8,2.92)

#plot the raw data
plot(y ~ as.factor(x))

#fit a glm
my.glm<-glm(y ~ x, family=Gamma(link=log))

#get predicted values and their error
a.fit<-predict(my.glm, data.frame(x="a"), se.fit=T)
b.fit<-predict(my.glm, data.frame(x="b"), se.fit=T)

#visualize it and see the SE cross 0
plot(1:2,c(a.fit$fit,b.fit$fit), pch=19, ylim=c(-2,4))
segments(1:2, c(a.fit$fit-a.fit$se.fit, b.fit$fit-b.fit$se.fit),
                1:2, c(a.fit$fit+a.fit$se.fit, b.fit$fit+b.fit$se.fit))
lines(0:3,rep(0,4), lty=2)
                

-Jarrett




----------------------------------------
Jarrett Byrnes
Population Biology Graduate Group, UC Davis
Bodega Marine Lab
707-875-1969
http://www-eve.ucdavis.edu/stachowicz/byrnes.shtml


        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to