Re: [R] psychometric functions
Hi, 2008/8/21 Mario Maiworm [EMAIL PROTECTED] 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. you might also check the function psyfun.2asym from the psyphy package http://cran.r-project.org/web/packages/psyphy/index.html best VĂctor H 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@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. [[alternative HTML version deleted]] __ R-help@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.
Re: [R] psychometric functions
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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] project.org] On Behalf Of Paul Artes Sent: Thursday, August 21, 2008 5:37 PM To: r-help@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 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. __ R-help@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@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.
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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Mario Maiworm Sent: Thursday, August 21, 2008 7:05 AM To: r-help@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@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@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.
Re: [R] psychometric functions
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 Quoting Doran, Harold [EMAIL PROTECTED]: 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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Mario Maiworm Sent: Thursday, August 21, 2008 7:05 AM To: r-help@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@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@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 __ R-help@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.
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:[EMAIL PROTECTED] Sent: Thursday, August 21, 2008 2:40 PM To: Mario Maiworm; r-help@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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Mario Maiworm Sent: Thursday, August 21, 2008 7:05 AM To: r-help@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@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@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.
Re: [R] psychometric functions
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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Mario Maiworm Sent: Thursday, August 21, 2008 9:16 AM To: r-help@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:[EMAIL PROTECTED] Sent: Thursday, August 21, 2008 2:40 PM To: Mario Maiworm; r-help@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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Mario Maiworm Sent: Thursday, August 21, 2008 7:05 AM To: r-help@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@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@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@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.
Re: [R] psychometric functions
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Mario Maiworm Sent: Thursday, August 21, 2008 7:05 AM To: r-help@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 __ R-help@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.
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 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. __ R-help@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.
Re: [R] psychometric functions
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 Home page: http://www.sas.upenn.edu/~baron __ R-help@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.
Re: [R] psychometric functions
On 08/21/08 17:48, Mario Maiworm wrote: 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. 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 __ R-help@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.