1
$\begingroup$

I have the following model and have used the effects package to plot the predicted probabilities and the confidence interval lines. However, I was wondering how I'd go about spitting out a data frame in R which has the response value, the low and high ci values, and the predicted values. Kind of like the following

mod1 = glm(won_ping ~ our_bid, data=ndat, family=binomial(link="probit"))
summary(mod1)

library(effects)
plot(effect("our_bid", mod1), rescale.axis=FALSE, multiline=TRUE, xlim=c(0,2000), main="129- AH - Bid model")

Desired output with our response variable and the confidence intervals for the predicted probabilities:

our bid    low_ci     hi_ci      prob
1           0.15       0.21       0.17
2           0.18       0.23       0.20 
3           0.20       0.30       0.25   
4           0.21       0.25       0.23  
...

How would I go about getting the following result in R.

I tried the following but it doesn't work as I want the probabilities and not the log-odds values.

> as.data.frame(effect("our_bid", mod1))
   our_bid        fit         se       lower      upper
1       25 -2.3549908 0.04598536 -2.44512045 -2.2648612
2      238 -2.0297771 0.03794491 -2.10414781 -1.9554065
3      451 -1.7045635 0.03724233 -1.77755712 -1.6315699
4      664 -1.3793498 0.04422870 -1.46603649 -1.2926632
5      877 -1.0541362 0.05610148 -1.16409305 -0.9441793
6     1090 -0.7289225 0.07043143 -0.86696557 -0.5908795
7     1303 -0.4037089 0.08599888 -0.57226356 -0.2351541
8     1516 -0.0784952 0.10224011 -0.27888213  0.1218917
9     1729  0.2467185 0.11887929  0.01371934  0.4797176
10    1942  0.5719321 0.13577018  0.30582746  0.8380368
$\endgroup$

1 Answer 1

1
$\begingroup$

if $\hat{\eta}_i$ is the $i^\rm{th}$ fitted log-odds then $$ \hat{p}_i=\frac{\exp(\hat{\eta}_i)}{1+\exp(\hat{\eta}_i)} = \frac{1}{1+\exp(-\hat{\eta}_i)} $$

You can transform the limits of confidence intervals in similar fashion.

Transforming s.e.'s is trickier, but you can do it approximately via Taylor expansion.

You can get R to produce these directly, you don't have to calculate them yourself. See the help relating to the type argument of the predict.glm function.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.