Jeromy Anglim's Blog: Psychology and Statistics


Thursday, May 20, 2010

Inverting a Logistic Function

I was recently talking to a researcher who had conducted a cognitive experiment that involved experimentally manipulating a variable x, a continuous property of a stimulus, looking at the effect on a variable p, the probability of giving a response. The function p(x) was assumed to be a logistic function. The researcher wanted to know how to calculate the point on x at which the fitted logistic regression function equalled 0.5.

Overview

Benjamin Bolker discusses function fitting in Chapter 3 of his book Ecological Models and Data in R. The logistic function is

p(x) = exp(a + b * x) / (1 + exp(a + b * x)).

Inverse of the logistic function

The logistic function is monotonically increasing. Thus, it has an inverse function. The following algebra shows how to find the inverse of the logistic function.
p = exp(a + b * x) / (1 + exp(a + b * x))   [the initial function]   

p + p * exp(a + b * x) = exp(a + b * x)     [multiply both sides by 
                                                (1 + exp(a + b * x))]
p + (p - 1) * exp(a + b * x) = 0            [subtract from both sides 
                                                (exp(a + b * x))]
(p - 1) * exp(a + b * x) = - p              [subtract from both sides 
                                                (p)]

exp(a + b * x) = (- p ) / (p - 1)           [divide both sides by 
                                                (p - 1)]

a + b * x = ln(-p / (p - 1))                [take the natural 
                                                log of both sides]

b * x = ln(-p / (p - 1)) - a                [subtract from both sides 
                                                (a)]

x = (ln(-p / (p - 1)) - a) / b              [divide both sides by (b)]
When p = .5, the function can be simplified to
x = (ln(-.5/(.5 - 1)) - a) / b
x = (ln(1) - a) / b
x = (0 - a) / b
x = -a / b

The Procedure

Thus, to estimate the the value of x where p = .5, the steps are:
  1. Estimate parameters a and b based on the data.
  2. Calculate the value of (-a / b).
For estimating parameters based on a nonlinear regression separately for a set of participants, see my earlier post on the topic.