[R] logistic regression for data with repeated measures

Mitchell Maltenfort mmalten at gmail.com
Tue Jul 1 17:13:53 CEST 2014


http://stats.stackexchange.com/questions/62225/conditional-logistic-regression-vs-glmm-in-r
might be a good start
____________________________
Ersatzistician and Chutzpahthologist
I can answer any question.  "I don't know" is an answer. "I don't know
yet" is a better answer.


On Tue, Jul 1, 2014 at 10:24 AM, Suzon Sepp <suzon.sepp at gmail.com> wrote:
> Hi,
>
> It seems that I'm quite lost in this wide and powerful R's universe, so I
> permit myself to ask your help about issues with which I'm struggling.
> Thank you,
>
> I would like to know if the answer’s accuracy (correct = 1; incorrect = 0)
> varies depending on 2 categorical variables which are the group (A and B)
> and the condition (a, b and c) knowing that I’ve got n subjects and 12
> trials by conditions for each subject (i.e. 12 repetitions).
>
> To do that, I’m focusing on logistic regression analysis. I’ve got no
> problem with this kind of analysis until now (logistic regression with
> numeric predictor variables and/or categorical predictor with 2 levels
> only) but, in this new context, I think I have to focus more specifically
> on logistic regression including *nested (or random?) factors* in a*repeated
> measures design* (because of the variables “Subject” and “Trial”) with a
> categorical predictor variable with *more than 2 levels* (the variable
> “Condition”) and I never did such a thing…yet.
>
> mydata =
> mydata$Subject: Factor w/38 levels: "i01", "i02", "i03", "i04"
> mydata$Group: Factor w/2 levels: "A", "B"
> mydata$Condition: Factor w/3 levels: "a", "b", "c"
> mydata$Trial: Factor w/12 levels: "t01", "t02", ..."t12"
> mydata$Accuracy: Factor w/2 levels: "0", "1"
>
> Subject      Group      Trial      Condition      Accuracy
>    i01              A           t01             a                   0
>    i01              A           t02             a                   1
> ...
>    i01              A           t12             a                   1
>    i01              A           t01             b                   1
>    i01              A           t02             b                   1
> ...
>    i01              A           t12             b                   0
>    i01              A           t01             c                   0
>    i01              A           t02             c                   1
> ...
>    i01              A           t12             c                   1
>    i02              B           t01             a                   1
> ...
>
> First, I’m wondering if I have to calculate a % of accuracy for each
> subject and each condition and thus “remove” the variable “Trial” but
> “lose” data (power?) in the same time… or to take into account this
> variable in the analysis and in this case, how to do that?
>
> Second, I don’t know which function I’ve to choose (lmer, glm, glmer…)?
>
> Third, I’m not sure I proceed correctly to specify in this analysis that
> the responses all come from the same subject: within-subject design =
> …+(1|Subject) as I can do for a repeated measures ANOVA to analyze the
> effect of my different variables on a numeric one such as the response
> time: test=aov(Int~Group*Condition+*Error(Subject/(Group*Condition)*),data=mydata)
> and here again how can I add the variable "Trial" if I don't work on an
> average reaction time for each subject in the different conditions?
>
> Below, examples of models I can write with glmer(),
>
> fit.1=glmer(Accuracy~Group* Condition
> +(1|Subject),data=mydata,family=binomial)
>
> fit.2=glmer(Accuracy~Group* Condition
> +(1|Subject)-1,data=mydata,family=binomial)   (“without intercept”)
>
> fit.3=glmer(Accuracy~Group* Condition +(1|Subject)+(1|Trial)...??
>
>
> I believed the analysis I've to conduct will be in the range of my
> qualifications then I realize it could be more complicated than that of
> course (ex GLMMs), I can hear "do it as we do usually" (=repeated measures
> ANOVA on a percentage of correct answers for each subject ??) as if there's
> only one way to follow but I think there's a lot, which one's revelant for
> my data, that's I want to find.
>
> Hope you can put me on the track,
>
> Best
>
> Suzon
>
>         [[alternative HTML version deleted]]
>
>
> ______________________________________________
> 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.
>



More information about the R-help mailing list