[R] 95% confidence intercal with glm

Ben Bolker bbolker at gmail.com
Tue Sep 28 15:50:09 CEST 2010


zozio32 <remy.pascal <at> gmail.com> writes:

> 
> 
> Hi
> 
> I had to use a glm instead of my basic lm on some data due to unconstant
> variance.
> 
> now, when I plot the model over the data, how can I easily get the 95%
> confidence interval that sormally coming from:
> 
>           > yv <- predict(modelVar,list(aveLength=xv),int="c")
>           > matlines(xv,yv,lty=c(1,2,2))
> 
> There is no "interval" argument to pass to the predict function when using a
> glm, so I was wondering if I had to use an other function
> 

  You need to use predict with se=TRUE; construct the confidence
intervals by computing predicted values +- 1.96 times the standard
error returned; and apply the inverse link function for your model.

  If heteroscedasticity is your main problem, and not a specific
(known) non-normal distribution, you might consider using the gls
function from the nlme package with an appropriate 'weights' argument.



More information about the R-help mailing list