baud-bovy.gabriel at hsr.it
2006-Dec-16 00:57 UTC
[R] how to adjust link function in logistic regression to predict the proportion of correct responses in 2AFC task?
I have would like to use logistic regression to analyze the percentage of correct responses in a 2 alternative forced choice task. The question is whether one needs to take into account the fact expected probabilities for the percentage of correct responses ranges between 0.5 and 1 in this case and how to adjust the link function accordingly in R (see details below). Gabriel Subjects were asked to match a tactile stimulus (shape A or B) with a visual template (response a or b). The exact stimulus properties depended on the experimental factors ecc (3 levels: 0.4, 0.7 and 1.0) and kappa (also 3 levels: 0.75, 1, 1.25), which yielded nine experimental conditions. Five subjects participated to the experiment and each stimulus was presented 10 times in each experimental condition. The following table reports the pooled responses of the 5 subjects. | | kappa | | | 0.75 1.0 1.25 | ecc | shape +--------+--------+--------+ | | resp | resp | resp | | | a b | a b | a b | ----+-------+--------+--------+--------+ 0.4 | A | 41 9 | 38 12 | 35 15 | | B | 3 47 | 7 43 | 11 39 | ----+-------+--------+--------+--------+ 0.7 | A | 22 28 | 33 17 | 39 11 | | B | 10 40 | 21 29 | 24 26 | ----+-------+--------+--------+--------+ 1.0 | A | 26 24 | 26 24 | 28 22 | | B | 20 30 | 18 32 | 25 25 | ----+-------+--------+--------+--------+ For this analysis, I define "correct response" as the resp=a for shape=A and resp=b for shape=B. The proportions of correct responses are therefore: | | kappa | ecc | shape | 0.75 1.0 1.25 | ----+-------+--------+--------+--------+ 0.4 | A | 0.82 | 0.76 | 0.70 | | B | 0.94 | 0.86 | 0.78 | ----+-------+--------+--------+--------+ 0.7 | A | 0.44 | 0.66 | 0.78 | | B | 0.80 | 0.58 | 0.52 | ----+-------+--------+--------+--------+ 1.0 | A | 0.52 | 0.52 | 0.56 | | B | 0.60 | 0.62 | 0.50 | ----+-------+--------+--------+--------+ The proportion of correct response is the largest for ecc=0.4 and, in general, smallest for ecc=1 as expected. It was expected that proportions of correct response would be close to 0.5 when ecc=1 because shapes A and B were the same in this condition. I would like to use the logistic regression to assess the effect of the shape, ecc and kappa on the proportion of correct responses. For example, glm(resp~shape*ecc*kappa,data=data,link=binomial) or, better, gee(resp~shape*ecc*kappa,id=subject,data=data,family=binomial, corstr = "exchangeable") given the fact that data that are correlated because the 50 responses come from five subjects. My first question is rather statistical: do I need to take into account the fact that the values of these proportions are expected to range in the interval [0.5-1] (0.5 corresponding to a random response) ? It seems to me that some sort of correction is needed as it is the case when one fits a psychometric function to this type of data (e.g. probit is rescaled to fit inside the [0.5-1] interval and the absolute threshold is defined as the point where the probit reaches the 0.75 probability level). Second, how can one implement a link function of the type f(x) = (1+exp(x)/(1+exp(x)))/2 in R? Third, can it be also done with gee and/or glmm? --------------------------------------------------------------------- Gabriel Baud-Bovy tel.: (+39) 02 2643 4839 (office) UHSR University (+39) 02 2643 3429 (laboratory) via Olgettina, 58 (+39) 02 2643 4891 (secretary) 20132 Milan, Italy fax: (+39) 02 2643 4892
Prof Brian Ripley
2006-Dec-16 06:01 UTC
[R] how to adjust link function in logistic regression to predict the proportion of correct responses in 2AFC task?
On Sat, 16 Dec 2006, baud-bovy.gabriel at hsr.it wrote:> I have would like to use logistic regression to analyze the > percentage of correct responses in a 2 alternative forced > choice task. The question is whether one needs to take into > account the fact expected probabilities for the percentage of > correct responses ranges between 0.5 and 1 in this case.Yes.> Second, how can one implement a link function of the > type f(x) = (1+exp(x)/(1+exp(x)))/2 in R?Looking at make.link() should give you enough to go on.> Third, can it be also done with gee and/or glmm?For gee, you need to change the C-level internals. (I've done this in the far past for S-PLUS but not for R.) It would be easier to use yags (but I think you still need to dive into the internals). What 'glmm' did you have in mind? Looks like e.g. glmmML and glmmPQL will work with the new link. [...] Someone may have been here already: e.g. http://www.pubmedcentral.nih.gov/articlerender.fcgi?artid=1434755 -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Ken Knoblauch
2006-Dec-16 07:36 UTC
[R] how to adjust link function in logistic regression to predict the proportion of correct responses in 2AFC task?
In theory, the probability of correct responses ranges between 0.5 and 1 here, but in practice it is frequent to find cases where the observed proportion of correct responses is a little less. The number of trials is limited, after all. The inverse of this link function generates a Nan when this occurs. Is that a problem? and if so, how can it be dealt with here? Thank you. I have used the gnlr function in Lindsey's gnlm package for this problem in the past, but glm would be simpler, it seems to me. @Article{pmid16817511, Author="Yssaad-Fesselier, Rosa and Knoblauch, Kenneth", Title="{{M}odeling psychometric functions in {R}}", Journal="Behav Res Methods", Year="2006", Volume="38", Number="1", Pages="28--41", Month="Feb" }> On Sat, 16 Dec 2006, baud-bovy.gabriel at hsr.it wrote: > > > I have would like to use logistic regression to analyze the > > percentage of correct responses in a 2 alternative forced > > choice task. The question is whether one needs to take into > > account the fact expected probabilities for the percentage of > > correct responses ranges between 0.5 and 1 in this case. > > Yes. > > > Second, how can one implement a link function of the > > type f(x) = (1+exp(x)/(1+exp(x)))/2 in R? > > Looking at make.link() should give you enough to go on. > > > Third, can it be also done with gee and/or glmm? > > For gee, you need to change the C-level internals. (I've done this > in the > far past for S-PLUS but not for R.) It would be easier to use yags > (but I > think you still need to dive into the internals). > > What 'glmm' did you have in mind? Looks like e.g. glmmML and > glmmPQL will > work with the new link. > > [...] > > Someone may have been here already: e.g. > http://www.pubmedcentral.nih.gov/articlerender.fcgi?artid=1434755 > > -- > Brian D. Ripley, ripley at stats.ox.ac.uk > Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ > University of Oxford, Tel: +44 1865 272861 (self) > 1 South Parks Road, +44 1865 272866 (PA) > Oxford OX1 3TG, UK Fax: +44 1865 272595-- Ken Knoblauch Inserm U371 Institut Cellule Souche et Cerveau Département Neurosciences Intégratives 18 avenue du Doyen Lépine 69500 Bron France tel: +33 (0)4 72 91 34 77 fax: +33 (0)4 72 91 34 61 portable: +33 (0)6 84 10 64 10 http://www.lyon.inserm.fr/371/ [[alternative HTML version deleted]]