Discussion:
[R] psychometric functions
Mario Maiworm
2008-08-21 11:05:22 UTC
Permalink
Hi,
I want to fit some psychophysical data with cumulative gaussians. There is
quite a convenient toolbox for matlab called 'psignifit' (formerly known as
'psychofit'). It allows the lower bound of the sigmoid to vary slightly from
zero, aswell as the upper bound to vary from one. with these two free
parameters, the fitted function is less sensitive to noisy data and
outliers.
Apart from advertising this toolbox I want to ask for possibilities in R to
fit psychometric functions, as I would rather use R than matlab. Is there a
comparable package specific for psychophysics in R? otherwise: which
function would be a good choice? Can I have functionality equal to
'psignifit' with glm() from MASS. I would be grateful for some suggestions
of people who have experience in sigmoid-fitting in R.
Best,
Mario.


__________________________________________________________________

Mario Maiworm
Biological Psychology and Neuropsychology
University of Hamburg
Von-Melle-Park 11
D-20146 Hamburg

Phone: +49 40 42838 8265
Fax: +49 40 42838 6591

http://bpn.uni-hamburg.de/Maiworm_e.html
http://cinacs.org
Doran, Harold
2008-08-21 12:40:27 UTC
Permalink
I am pretty certain a function for this model does not exist. Jan
Deleeuw or Dimitris Rizopolous may suggest otherwise. There is a package
for a model that would allow for the lower asymptote of the function to
be > 0; it does not however, allow the upper asymptote to vary from 1
(well, it tends to 1) and this is in the ltm package.
-----Original Message-----
From: r-help-bounces at r-project.org
[mailto:r-help-bounces at r-project.org] On Behalf Of Mario Maiworm
Sent: Thursday, August 21, 2008 7:05 AM
To: r-help at r-project.org
Subject: [R] psychometric functions
Hi,
I want to fit some psychophysical data with cumulative
gaussians. There is quite a convenient toolbox for matlab
called 'psignifit' (formerly known as 'psychofit'). It allows
the lower bound of the sigmoid to vary slightly from zero,
aswell as the upper bound to vary from one. with these two
free parameters, the fitted function is less sensitive to
noisy data and outliers.
Apart from advertising this toolbox I want to ask for
possibilities in R to fit psychometric functions, as I would
rather use R than matlab. Is there a comparable package
specific for psychophysics in R? otherwise: which function
would be a good choice? Can I have functionality equal to
'psignifit' with glm() from MASS. I would be grateful for
some suggestions of people who have experience in
sigmoid-fitting in R.
Best,
Mario.
__________________________________________________________________
Mario Maiworm
Biological Psychology and Neuropsychology University of
Hamburg Von-Melle-Park 11
D-20146 Hamburg
Phone: +49 40 42838 8265
Fax: +49 40 42838 6591
http://bpn.uni-hamburg.de/Maiworm_e.html
http://cinacs.org
______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Dimitris Rizopoulos
2008-08-21 13:08:55 UTC
Permalink
Yes, indeed, the ltm package has the function tpm() that can fit
Birnbaum's three parameter model that allows for a guessing parameter
(i.e., when the ability levels \theta -> -Inf, the probability for
correct response is allowed to be nonzero) but it does not have a
function to incorporate an upper asymptote. I am not aware of any
other R package that can fit this model.

According to my experience, the models with asymptotes are not
particularly numerically stable, especially when the guessing
parameters are practically zero (i.e., the maximum is on the boundary
of the parameter space). In such cases, the 'constraint' of tpm() can
be used to set the guessing parameters for some items to zero and
investigate data set at hand.

I hope it helps.

Best,
Dimitris
Post by Doran, Harold
I am pretty certain a function for this model does not exist. Jan
Deleeuw or Dimitris Rizopolous may suggest otherwise. There is a package
for a model that would allow for the lower asymptote of the function to
be > 0; it does not however, allow the upper asymptote to vary from 1
(well, it tends to 1) and this is in the ltm package.
-----Original Message-----
From: r-help-bounces at r-project.org
[mailto:r-help-bounces at r-project.org] On Behalf Of Mario Maiworm
Sent: Thursday, August 21, 2008 7:05 AM
To: r-help at r-project.org
Subject: [R] psychometric functions
Hi,
I want to fit some psychophysical data with cumulative
gaussians. There is quite a convenient toolbox for matlab
called 'psignifit' (formerly known as 'psychofit'). It allows
the lower bound of the sigmoid to vary slightly from zero,
aswell as the upper bound to vary from one. with these two
free parameters, the fitted function is less sensitive to
noisy data and outliers.
Apart from advertising this toolbox I want to ask for
possibilities in R to fit psychometric functions, as I would
rather use R than matlab. Is there a comparable package
specific for psychophysics in R? otherwise: which function
would be a good choice? Can I have functionality equal to
'psignifit' with glm() from MASS. I would be grateful for
some suggestions of people who have experience in
sigmoid-fitting in R.
Best,
Mario.
__________________________________________________________________
Mario Maiworm
Biological Psychology and Neuropsychology University of
Hamburg Von-Melle-Park 11
D-20146 Hamburg
Phone: +49 40 42838 8265
Fax: +49 40 42838 6591
http://bpn.uni-hamburg.de/Maiworm_e.html
http://cinacs.org
______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
--
Dimitris Rizopoulos
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
http://perswww.kuleuven.be/dimitris_rizopoulos/

Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
Mario Maiworm
2008-08-21 13:16:28 UTC
Permalink
Thank you harold. Hmm thats bad news. I will have a look at the LTM package
but right now I feel like I should lean back and use matlab, and then get
the fit results into R for further analyses...
mario


__________________________________________________________________

Mario Maiworm
Biological Psychology and Neuropsychology
University of Hamburg
Von-Melle-Park 11
D-20146 Hamburg

Phone: +49 40 42838 8265
Fax: +49 40 42838 6591

http://bpn.uni-hamburg.de/Maiworm_e.html
http://cinacs.org
__________________________________________________________________
-----Original Message-----
From: Doran, Harold [mailto:HDoran at air.org]
Sent: Thursday, August 21, 2008 2:40 PM
To: Mario Maiworm; r-help at r-project.org
Subject: RE: [R] psychometric functions
I am pretty certain a function for this model does not exist. Jan
Deleeuw or Dimitris Rizopolous may suggest otherwise. There is a package
for a model that would allow for the lower asymptote of the function to
be > 0; it does not however, allow the upper asymptote to vary from 1
(well, it tends to 1) and this is in the ltm package.
-----Original Message-----
From: r-help-bounces at r-project.org
[mailto:r-help-bounces at r-project.org] On Behalf Of Mario Maiworm
Sent: Thursday, August 21, 2008 7:05 AM
To: r-help at r-project.org
Subject: [R] psychometric functions
Hi,
I want to fit some psychophysical data with cumulative
gaussians. There is quite a convenient toolbox for matlab
called 'psignifit' (formerly known as 'psychofit'). It allows
the lower bound of the sigmoid to vary slightly from zero,
aswell as the upper bound to vary from one. with these two
free parameters, the fitted function is less sensitive to
noisy data and outliers.
Apart from advertising this toolbox I want to ask for
possibilities in R to fit psychometric functions, as I would
rather use R than matlab. Is there a comparable package
specific for psychophysics in R? otherwise: which function
would be a good choice? Can I have functionality equal to
'psignifit' with glm() from MASS. I would be grateful for
some suggestions of people who have experience in
sigmoid-fitting in R.
Best,
Mario.
__________________________________________________________________
Mario Maiworm
Biological Psychology and Neuropsychology University of
Hamburg Von-Melle-Park 11
D-20146 Hamburg
Phone: +49 40 42838 8265
Fax: +49 40 42838 6591
http://bpn.uni-hamburg.de/Maiworm_e.html
http://cinacs.org
______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Doran, Harold
2008-08-21 13:35:32 UTC
Permalink
I don't know that you would be too far away from being able to use R
from doing this. I haven't thought about this model, but if you could
write out the likelihood, you *might* be able to use the MML procedures
that is used for similar psychometric functions in ltm, which I think
uses optim()
-----Original Message-----
From: r-help-bounces at r-project.org
[mailto:r-help-bounces at r-project.org] On Behalf Of Mario Maiworm
Sent: Thursday, August 21, 2008 9:16 AM
To: r-help at r-project.org
Subject: Re: [R] psychometric functions
Thank you harold. Hmm thats bad news. I will have a look at
the LTM package but right now I feel like I should lean back
and use matlab, and then get the fit results into R for
further analyses...
mario
__________________________________________________________________
Mario Maiworm
Biological Psychology and Neuropsychology University of
Hamburg Von-Melle-Park 11
D-20146 Hamburg
Phone: +49 40 42838 8265
Fax: +49 40 42838 6591
http://bpn.uni-hamburg.de/Maiworm_e.html
http://cinacs.org
__________________________________________________________________
-----Original Message-----
From: Doran, Harold [mailto:HDoran at air.org]
Sent: Thursday, August 21, 2008 2:40 PM
To: Mario Maiworm; r-help at r-project.org
Subject: RE: [R] psychometric functions
I am pretty certain a function for this model does not exist. Jan
Deleeuw or Dimitris Rizopolous may suggest otherwise. There is a
package for a model that would allow for the lower
asymptote of the
function to be > 0; it does not however, allow the upper
asymptote
to vary from 1 (well, it tends to 1) and this is in the
ltm package.
-----Original Message-----
From: r-help-bounces at r-project.org
[mailto:r-help-bounces at r-project.org] On Behalf Of Mario Maiworm
Sent: Thursday, August 21, 2008 7:05 AM
To: r-help at r-project.org
Subject: [R] psychometric functions
Hi,
I want to fit some psychophysical data with cumulative
gaussians.
There is quite a convenient toolbox for matlab called
'psignifit'
(formerly known as 'psychofit'). It allows the lower
bound of the
sigmoid to vary slightly from zero, aswell as the upper
bound to
vary from one. with these two free parameters, the
fitted function
is less sensitive to noisy data and outliers.
Apart from advertising this toolbox I want to ask for
possibilities in R to fit psychometric functions, as I would
rather use R than matlab. Is there a comparable package
specific
for psychophysics in R? otherwise: which function would
be a good
choice? Can I have functionality equal to 'psignifit'
with glm()
from MASS. I would be grateful for some suggestions of
people who
have experience in sigmoid-fitting in R.
Best,
Mario.
__________________________________________________________________
Mario Maiworm
Biological Psychology and Neuropsychology University of Hamburg
Von-Melle-Park 11
D-20146 Hamburg
Phone: +49 40 42838 8265
Fax: +49 40 42838 6591
http://bpn.uni-hamburg.de/Maiworm_e.html
http://cinacs.org
______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained,
reproducible code.
______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Jonathan Baron
2008-08-21 14:48:00 UTC
Permalink
Post by Mario Maiworm
-----Original Message-----
From: r-help-bounces at r-project.org
[mailto:r-help-bounces at r-project.org] On Behalf Of Mario Maiworm
Sent: Thursday, August 21, 2008 7:05 AM
To: r-help at r-project.org
Subject: [R] psychometric functions
Hi,
I want to fit some psychophysical data with cumulative
gaussians.
There is quite a convenient toolbox for matlab called
'psignifit'
(formerly known as 'psychofit'). It allows the lower
bound of the
sigmoid to vary slightly from zero, aswell as the upper
bound to
vary from one. with these two free parameters, the
fitted function
is less sensitive to noisy data and outliers.
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?

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
--
Jonathan Baron, Professor of Psychology, University of Pennsylvania
Home page: http://www.sas.upenn.edu/~baron
Mario Maiworm
2008-08-21 15:48:31 UTC
Permalink
Post by Jonathan Baron
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.
Post by Jonathan Baron
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
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()?
Post by Jonathan Baron
--
Jonathan Baron, Professor of Psychology, University of Pennsylvania
Home page: http://www.sas.upenn.edu/~baron
Jonathan Baron
2008-08-21 15:57:04 UTC
Permalink
Post by Mario Maiworm
Post by Jonathan Baron
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.
This makes sense. Sorry I didn't think of it.
Post by Mario Maiworm
Unfortunately, I cannot make this code run. You mean the 'lower' and 'upper'
parameters of nls()?
Given all the other comments, I don't think you should bother with my
code. My point was simply that there are many tools in R for doing
the kind of model fitting you want to do. Probably optim() itself is
better for this, but it seems that there are many other options.

The model I fit made exactly the same assumption you describe, namely,
that the upper asymptote was less than 1, because (for example) some
of the best students understand the question differently from what the
test makers intended. And the lower asymptote depends on what the
worst students tend to guess.

I think ltm should allow a flexible upper bound, for these reasons.
(I haven't tried it.)

Jon
--
Jonathan Baron, Professor of Psychology, University of Pennsylvania
Home page: http://www.sas.upenn.edu/~baron
Christian Ritz
2008-08-21 14:55:33 UTC
Permalink
Hi Mario,

in many applications there is not much difference between logistic and Gaussian
distributions (just as logit and probit models often produce similar fits)...

Moreover it's possible to fit sigmoidal curves using models such as the (log-)logistic
where the lower and/upper limits are estimated rather than fixed at 0 and 1, respectively.
Have a look at the package 'drc' to see how!

Also the following talk at the recent user! 2008 conference might be of interest to you:

http://www.statistik.uni-dortmund.de/useR-2008//slides/Haubo.pdf


Best wishes
Christian
Paul Artes
2008-08-21 15:36:31 UTC
Permalink
There is a nice paper by Yssaad-Fesselier and Knoblauch on "Modelling
Psychometric Functions in R".
http://hal.archives-ouvertes.fr/docs/00/13/17/99/PDF/B125.pdf

You might also be interested in this:
http://www.journalofvision.org/5/5/8/article.aspx
which comes from the same group as the psignifit toolbox for matlab
(methinks), but is a step ahead.

Best wishes

Paul
--
View this message in context: http://www.nabble.com/psychometric-functions-tp19086590p19091317.html
Sent from the R help mailing list archive at Nabble.com.
Mario Maiworm
2008-08-22 09:23:48 UTC
Permalink
Paul,
thanks a lot for your advice! I got that kuss et al. paper and started to
read, this is more than I had expected! Very cool paper, and an algorithm
implemented in R that seems to be even superior to psignifit in matlab. So
thanks again!
mario


__________________________________________________________________

Mario Maiworm
Biological Psychology and Neuropsychology
University of Hamburg
Von-Melle-Park 11
D-20146 Hamburg

Phone: +49 40 42838 8265
Fax: +49 40 42838 6591

http://bpn.uni-hamburg.de/Maiworm_e.html
http://cinacs.org
__________________________________________________________________
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
project.org] On Behalf Of Paul Artes
Sent: Thursday, August 21, 2008 5:37 PM
To: r-help at r-project.org
Subject: Re: [R] psychometric functions
There is a nice paper by Yssaad-Fesselier and Knoblauch on "Modelling
Psychometric Functions in R".
http://hal.archives-ouvertes.fr/docs/00/13/17/99/PDF/B125.pdf
http://www.journalofvision.org/5/5/8/article.aspx
which comes from the same group as the psignifit toolbox for matlab
(methinks), but is a step ahead.
Best wishes
Paul
--
View this message in context: http://www.nabble.com/psychometric-
functions-tp19086590p19091317.html
Sent from the R help mailing list archive at Nabble.com.
______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-
guide.html
and provide commented, minimal, self-contained, reproducible code.
Victor Hernando Cervantes Botero
2008-08-25 19:14:17 UTC
Permalink
An embedded and charset-unspecified text was scrubbed...
Name: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20080825/3789c87c/attachment.pl>
Loading...