# How to Conduct Binary Logistic Regression with Repeated Measures

I have a data set in which the response variable ("Binary_Response") is binary.

The explanatory variables I am hoping to include with my model are categorical and also binary ("Stimulus_Order" & "Stimulus_Type").

I have made repeated measurements of individuals' sequential responses to two stimuli (A, B) five times each (AAAAABBBBB or BBBBBAAAAA). Sometimes I presented A first; sometimes B first ("Stimulus_Order"=1 if first). Their likelihood to produce a "1" in the response variable typically decays with time, but individuals vary in the rate of decay and some may rarely exhibit the opposite pattern.

>str(x)
'data.frame':   310 obs. of  6 variables:
$Individual : int 1 1 1 1 1 1 1 1 1 1 ...$ Stimulus_Number      : int  1 2 3 4 5 6 7 8 9 10 ...
$Stimulus_Order : Factor w/ 2 levels "1","2": 1 1 1 1 1 2 2 2 2 2 ...$ Stimulus_Type        : Factor w/ 2 levels "A","B": 1 1 1 1 1 2 2 2 2 2 ...
$Binary_Response : Factor w/ 2 levels "0","1": 2 2 1 1 1 2 2 2 1 1 ...$ Stim_Order_Type_Combo: Factor w/ 4 levels "A1","A2","B1",..: 1 1 1 1 1 4 4 4 4 4 ...


My questions are:

1. Is binary logistic regression suitable for determining whether and how strongly "Stimulus_Order" or "Stimulus_Type" are affecting "Binary_Response"?
2. If so, how do you encode the repeated measures aspect of this problem into the model to ensure the model doesn't treat each data point as independent?

Ultimately, I'd like to show that the presentation order of the stimuli didn't influence the "Binary_Response" for both stimuli. Based on that (if true) I'd like to lump the data and ignore "Stimuli_Order". Then I'd like to show that "Stimuli_Type"=A had a higher probability of exhibiting "Binary_Response"=1 and that it also maintained a higher probability throughout sequential trials (lower decay rate). If there is a method that can do that in one step, that'd be great. I've only just entered the world of these crazy general/ized linear models.

Any answers or suitable references/examples would be much appreciated. Maybe suitable references more so, as I've got a lot to learn! I haven't found any examples of glm's dealing with binary response and explanatory variables with repeated measures.

Data are provided here. "Stimulus_Order" and "Binary_Response" should be factors.

Thank you much!

• If you want to examine the decay within a run of either 5 As or 5 Bs in a row, it might be better to recode your "Stimulus_Number" slightly, so that the range 1...5 represents the order within a particular run of As or Bs regardless of whether the As or Bs were presented first. Since you also have your "Stimulus_Order" factor, you don't lose any information but that will allow a straightforward interpretation of changes in response with Stimulus_Number within a set of As or Bs. – EdM Jun 10 '15 at 14:41
• This page has examples of repeated-measures/mixed-effects situations with binary outcomes. – EdM Jun 10 '15 at 15:02