So, I have a binomial glm function, with two predictors, the second (as factor) being with two levels (50, 250).
model <- glm(GetResp.RESP ~ speed + PadLen, family = binomial(link = "logit"), data = myData)
The plot for it looks like this:
My question: How can I find the covariate (ball speed) specific to the .5 probability for each level of the second predictor?
For example, I've tried using the function dose.p(), from the package 'MASS':
dose.p(model, p = 0.5)
and I get
p = 0.5: 36.9868
which, by just looking at the plot, it would be the value for the first (50) level. Now, how can I find it for the second (250) level as well?
Thank you.
dput(myData):
Since this is a logistic regression, you're fitting the function:
log(p/(1-p)) = b0 + b1*speed + b2*PadLen
where p is the probability of GetResp.RESP
being equal to 1, b0, b1, and b2 are the regression coefficients, and PadLen
is a dummy variable equal to zero when myData$PadLen
is 50 and equal to 1 when myData$PadLen
is 250.
So you can solve for the speed at p = 0.5:
log(1) = b0 + b1*speed + b2*PadLen
b1*speed = log(1) - b0 - b2*PadLen
speed = (log(1) - b0 - b2*PadLen)/b1
Since log(1) = 0, this reduces to:
speed = (-b0 - b2*c(0,1))/b1
Or, putting in the actual coefficient values:
speed = (-coef(model)[1] - coef(model)[3]*c(0,1))/coef(model)[2]
To solve for speed
at other probabilities, just keep the log-odds factor in the equation and enter whatever value of p you desire:
speed = (log(p/(1-p)) - coef(model)[1] - coef(model)[3]*c(0,1))/coef(model)[2]