[R] logististic regression (GLM). How to get 95 pct. confidence limits?
Prof Brian Ripley
ripley at stats.ox.ac.uk
Sat Feb 28 09:17:22 CET 2004
On Sat, 28 Feb 2004, Niels Steen Krogh wrote:
> Dear R-list.
> I'm doing af logistic analyses using gml.
> The model explaines variations in Adverse events infections (0 og 1) using
> age as explanatory variable.
>
> model2d<-glm(formula=AEorSAEInfecBac~Age,family=binomial("logit"),data=emrisk)
>
> I want to get predictions with 95% confidence limits for age 30 and age 60.
> I've been reading the "google" and "search r-project" for suggestions but
> could only find solutions for lm: predict(model,data.frame(Age=30),level=.95
> ..............)
> ?predict.glm or ?glm did'nt give me hints either.
95% confidence limits for what? I guess you mean either the linear
predictor or the mean, and it is preferable to find CIs for the linear
predictor and transforms the CIs if needed.
preds <- predict(model2d, data.frame(Age=c(30, 60)), se.fit=TRUE)
will give a list with means and ses for the linear predictor. There is no
exact sampling theory, so you can use something like
cbind(lower=pred$fit-1.96*preds$se, upper=pred$fit+1.96*preds$se)
and transform by family(model2d)$linkinv() to response scale.
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list