# [R] psychometric functions

Mario Maiworm mario.maiworm at uni-hamburg.de
Thu Aug 21 17:48:31 CEST 2008

```>>> Two comments.  First, it isn't clear to me why you want the upper
>>> bound to differ from 1.  Apparently you have some theoretical reason
>>> for using a cumulative gaussian.  Wouldn't the same theory tell you
>>> that the upper bound should be 1?

the reason why I use cumulative gaussians is that I am interested in the
sigma values of the underlying gaussian, which is a measure of perceptual
uncertainty. In my experiments, people are supposed to judge a stimulus
feature (in a 2AFC task). In theory, if subjects are presented with a
stimulus that has the maximum value for that feature (and the experiment ist
properly designed), there is a probability of 1 that people respond with
"yes". In practice, subjects do make unspecific errors due to a whole bunch
of reasons even at high stimulus intensities. If I let the computational
routine that is supposed to fit my data sets assume that the probability for
response is 1 at high stimulus intensities (i.e. fix the asymptote at 1),
the estimated parameters are very sensitive to those outliers and I get a
strongly biased result if the subject only made one or very few mistakes at
high stimulus intesities.

>>>
>>> Second, putting that aside, one of the very first things I did when I
>>> started using R (in 2000, way before the ltm package) was to fit
>>> item-characteristic curves to some test data using nls(), and these
>>> allowed both upper and lower bound to vary.  I used a logit function
>>> rather than what you are using.  The code is probably useless now - I
>>> didn't worry about many things and just wanted to get something crude
>>> and descriptive - but here are the main parts:
>>>
>>> logit <- function(x) {exp(x)/(1+exp(x))}
>>>
>>> astart <- c(.5,.8,.8,.8,.65,.8,.8,.5,.5,.5,.5,
>>>             NA,NA,.5,.5,.5,.5,.5,.5,.5,.5,.5,
>>>             .5,.5,.5,.5,.5,.5,.5,.5,.5,.5,.5)
>>>
>>> icc <- matrix(NA,nitems,4) # A,B,C,D coefficients
>>>
>>> # the loop is over the items
>>> for (i in 1:ns) {
>>>   icc.tmp<-nls(score[,i]~pmin(1,pmax(0,C*logit((mscore-A)/B)+D)),
>>>                start=list(A=astart[i],B=.1,C=.5,D=.5),
>>>                control=nls.control(tol=.025)
>>>   icc[i,] <- coef(icc.tmp)}
>>>
>>> # mscore is the mean score for each item

Unfortunately, I cannot make this code run. You mean the 'lower' and 'upper'
parameters of nls()?

>>>
>>> --
>>> Jonathan Baron, Professor of Psychology, University of Pennsylvania