[R] R: Confidence Intervals for logistic regression

Guazzetti Stefano Stefano.Guazzetti at ausl.re.it
Sat Aug 7 07:25:05 CEST 2010


a closer look to the help on predict.glm will reveal that the function 
accepts a 'type' argument.
In you case 'type = response' will give you the results in probabilities
(that it seems to be what you are looking for).
There also is an example on use of the 'type' argument at the end of the
page.

Stefano

-----Messaggio originale-----
Da: r-help-bounces at r-project.org
[mailto:r-help-bounces at r-project.org]Per conto di Troy S
Inviato: Friday, August 06, 2010 6:31 PM
A: Michael Bedward
Cc: r-help at r-project.org
Oggetto: Re: [R] Confidence Intervals for logistic regression


Michael,

Thanks for the reply.  I believe Aline was sgiving me CI's on coefficients
as well.

So c(pred$fit + 1.96 * pred$se.fit, pred$fit - 1.96 *
pred$se.fit) gives me the CI on the logits if I understand correctly?  Maybe
the help on predict.glm can be updated.

Thanks!

On 6 August 2010 01:46, Michael Bedward <michael.bedward at gmail.com> wrote:

> Sorry about earlier reply - didn't read your email properly (obviously :)
>
> You're suggestion was right, so as well as method for Aline below,
> another way of doing the same thing is:
>
> pred <- predict(y.glm, newdata= something, se.fit=TRUE)
> ci <- matrix( c(pred$fit + 1.96 * pred$se.fit, pred$fit - 1.96 *
> pred$se.fit), ncol=2 )
>
> lines( something, plogis( ci[,1] ) )
> lines( something, plogis( ci[,2] ) )
>
>
>
> On 6 August 2010 18:39, aline uwimana <rwanuza at gmail.com> wrote:
> > Dear Troy,
> > use this commend, your will get IC95% and OR.
> >
> >  logistic.model <- glm(formula =y~ x1+x2, family = binomial)
> > summary(logistic.model)
> >
> > sum.coef<-summary(logistic.model)$coef
> >
> > est<-exp(sum.coef[,1])
> > upper.ci<-exp(sum.coef[,1]+1.96*sum.coef[,2])
> > lower.ci<-exp(sum.coef[,1]-1.96*sum.coef[,2])
> >
> > cbind(est,upper.ci,lower.ci)
> >
> > regards.
> >
> > 2010/8/6 Troy S <troysocks-twigs at yahoo.com>
> >
> >> Dear UseRs,
> >>
> >> I have fitted a logistic regression using glm and want a 95% confidence
> >> interval on a response probability.  Can I use
> >>
> >> predict(model, newdata, se.fit=T)
> >>
> >> Will fit +/- 1.96se give me a 95% of the logit?  And then
> >> exp(fit +/- 1.96se) / (exp(fit +/- 1.96se) +1) to get the probabilities?
> >>
> >> Troy
> >>
> >>        [[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.
> >>
> >
> >        [[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.
> >
>

	[[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.

Rispetta l'ambiente: Se non ti è necessario, non stampare questa mail.


"Le informazioni contenute nel presente messaggio di posta elettronica e in ogni suo allegato sono da considerarsi riservate e il destinatario della email è l'unico autorizzato
ad usarle, copiarle e, sotto la propria responsabilità, divulgarle. Chiunque riceva questo messaggio per errore senza esserne il destinatario deve immediatamente rinviarlo
al mittente cancellando l'originale. Eventuali dati personali e sensibili contenuti nel presente messaggio e/o suoi allegati vanno trattati nel rispetto della normativa 
in materia di privacy ( DLGS n.196/'03)".




More information about the R-help mailing list