Abraham Mathew
2013-Jan-29 23:08 UTC
[R] Finding predicted probabilities and their confidence intervals for a logit model
I want to construct a logit model, plot the probability curve with the confidence intervals, and then I want to print out a data frame with the predictor, response value, predicted value, the low ci predicted value, and the high ci predicted value. So it should look something like: value low_ci prob hi_ci 5 0.10 0.12 0.13 6 0.11 0.13 0.16 7 0.13 0.15 0.17 .... Here's some sample data, the glm model, and a plot using the effects. I have the plot, I just need the presided data. dt <- data.frame(won=c(rep(1,50),rep(0,50)), value=c(rnorm(100))) mod <- glm(won ~ value, data=dt, family="binomial") mod library(effects) plot(effect("value", mod), rescale.axis=FALSE, multiline=TRUE) Help! Thank You! [[alternative HTML version deleted]]
Ista Zahn
2013-Feb-04 15:55 UTC
[R] Finding predicted probabilities and their confidence intervals for a logit model
Hi, I think you are looking for as.data.frame(effect("value", mod)) Best, Ista On Tue, Jan 29, 2013 at 6:08 PM, Abraham Mathew <abmathewks at gmail.com> wrote:> I want to construct a logit model, plot the probability curve with the > confidence intervals, and then I want to > print out a data frame with the predictor, response value, predicted value, > the low ci predicted value, and the > high ci predicted value. So it should look something like: > > value low_ci prob hi_ci > 5 0.10 0.12 0.13 > 6 0.11 0.13 0.16 > 7 0.13 0.15 0.17 > .... > > Here's some sample data, the glm model, and a plot using the effects. I > have the plot, I > just need the presided data. > > dt <- data.frame(won=c(rep(1,50),rep(0,50)), value=c(rnorm(100))) > > mod <- glm(won ~ value, data=dt, family="binomial") > mod > > library(effects) > plot(effect("value", mod), rescale.axis=FALSE, multiline=TRUE) > > > Help! > > Thank You! > > [[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.