I have the following data:
## # A tibble: 525 × 8
## Subject Group Type ISI Label MeanEMG MeanRRA MeanRRA2
## <fct> <fct> <fct> <dbl> <fct> <dbl> <dbl> <dbl>
## 1 17 HC BL 0 HC BL 41.4 1 1.28
## 2 17 HC BL 4 HC BL 67.8 1.64 2.09
## 3 17 HC BL 5 HC BL 51.3 1.24 1.58
## 4 17 HC BL 8 HC BL 56.0 1.35 1.73
## 5 17 HC BL 10 HC BL 79.7 1.93 2.46
## 6 17 HC BL 15 HC BL 104. 2.51 3.21
## 7 17 HC BL 20 HC BL 129. 3.13 3.99
## 8 17 HC SWD 0 HC SWD 93.9 1 1.20
## 9 17 HC SWD 4 HC SWD 107. 1.14 1.36
## 10 17 HC SWD 5 HC SWD 142. 1.51 1.81
## # ℹ 515 more rows
I am attaching a summary plot of the variable of interest, MeanEMG
, across distinct ISIs. On each plot, we separately show the distribution of MeanEMG
for the two different levels of Group
and Type
.
I am interested in the effects of Group
and Type
on MeanEMG
. I expect the overall distribution of MeanEMG
to differ across ISI
levels. In particular, I expect that MeanEMG
is higher for higher values of ISI
.
I am having trouble defining what the correct model would be. We have a random effect in Subject
, evidently. But is ISI
a random effect as well or a fixed one? Each Subject
is exposed to the same number and same levels of ISI
. In particular, ISI
and Type
are within subject categories, while Group
is a between subject category.
Simple models, such as lmer(MeanEMG ~ Group * Type + (1|Subject) + (1|ISI), pdf)
don't fit the model very well. What formula would be sensible to explore the effects I have described?
EDIT: Meaning of the variables and description of experiment.
Descritpion: Healthy controls and MDDs (Depressed) were subjected to two types of sleep sessions, BL (Baseline) and SWD (Sleep deprivation). After each session, brain stimulations were given to them and their responses were measured using EMG (electromyography). Some, but not all stimulations were paired with another. In paired stimulations, a second stimulation was given $x$ miliseconds after the first. The value of $x$ is called ISI (inter-stimulus interval).
So, the variables are
Group: Factor with Healthy Control or MDD (Depressive)
Type: Type of Sleep Session underwent prior to the experiment. Can be Baseline or SWD (Sleep deprivation).
MeanEMG: Average response to brain stimulations as measured by electromyography.
ISI: The interstimulus interval used in paired stimulations. Unpaired stimulations (a unique stimulation given) is represented by 0.
So, we could "read" the second row as follows to illustrate:
In
Subject
17, a healthy control, after baseline (normal) sleep, the average response to those brain stimulations consisting of two paired-pulses separated by $4$ miliseconds, as measured by the electromyography, was $67.8$
ISI
to be a numeric variable while random effects need to be categorical. Perhaps the software automatically makes that conversion, but it's safest to do that conversion yourself. Please edit the question to describe what your variables mean, as @ShawnHemelstrand has asked, and to state the hypothesis about them that you want to test. Provide that information by editing the question itself, as comments are easy to overlook and can be deleted. $\endgroup$