# Getting accurate interpolated probability from logistic regression equation

I have to ascertain what specific rasch item a student needs to attain to have a 70% probability of passing a future criterion test (the tests are correlated, the results below are output from the logistic regression equation).

I ran a logistic regression equation on a series of rasch items. Because the rasch items represent discrete ability scores, and the number of items was not very large (15-items per student) I have to interpolate what rasch item would be needed to have a 70% probability of passing a criterion. Below is the output and code I have tried to use to create the probability.

intercept = -0.8392
slope = 0.4120


Finding probability of 0.70 given the above intercept/slope:

#Eq1
exp((log(0.70) - intercept)/slope)
#Output: 3.225788


This output would indicate a rasch score of 3.225788 would represent a probability of 0.70. But when I use that output to assess the probability of 3.225788, it comes out to a probability of 0.62.

#Eq2
exp(-0.8392+0.4120*(3.225788)) / (1 + exp(-0.8392 + 0.4120*(3.22578)))
#Output: 0.62


I also tried repeating equation 1 by first assigning the log(0.7) to an object (p) in the hopes that this could solve a rounding error that I read about in McElreath's "Statistical Rethinking" but it didn't appear to help.

Please do let me know if you need a reproducible dataset. I thought perhaps the intercept/slope would be enough, but can put together more if needed.

## migrated from stackoverflow.comNov 25 '18 at 10:18

This question came from our site for professional and enthusiast programmers.

I think your arithmetic is wrong ...

• back-transform 0.7 to the log-odds (logit) scale: log(x/(1-x)) or plogis() in R:
p <- 0.7
log(p/(1-p))  ## 0.847
logit.p <- qlogis(p)   ## same

• Solve for the desired value (a+b*x=p -> x = (p-a)/b):
int <- -0.8392
slope <- 0.4120
val <- (logit.p-int)/slope  ## 4.093

• Checking: the logistic function (exp(x)/(1+exp(x)), or 1/(1+exp(-x))) is also available as plogis() in R:
plogis(int+slope*val)  ## 0.7


There's a dose.p function in the MASS package that will do this automatically (and compute approximate standard errors) when provided with a glm object:

• Thank you! I’m a bit embarrassed that I didn’t notice I wasn’t properly transforming the probability into odds before trying to solve the equation. – aleksis.paul Nov 25 '18 at 1:19