I have a fairly complex linear mixed effect model in R and I believe that there are issues to do with repeated data when running my post hoc tests. The model formula is as follows:
IFI_ALL <-
lmer(IF_interact ~ cond_id*GoldMSI_MT*(HR + SC + ztime + IOS) +
(1|case_id:group_id)+
(1|stim_id)+
(1|instrument)+
(1|notasi),
data= comb_df)
There are theoretical reasons why all should be in the same model, and my model fit is good. Within the dataset, the fixed effects have different levels of repetitions, whereby GoldMSI_MT has one value per participant, ztime and IOS repeat across the 3 cond_ids per participant, and HR and SC are longer time series physiological correlation data, with some missing values.
Here is an example of a portion of my dataset:
> head(comb_df[,c(1,3,5,10,17,18,19,20)])
A tibble: 6 × 8
case_id ztime cond_id IF_interact IOS[,1] section HR SC
<fct> <dbl> <fct> <dbl> <dbl> <chr> <dbl> <dbl>
1 1 2.59 Notated 0.837 0.533 1 NA 0.256
2 1 2.59 Notated 0.837 0.533 2 NA 0.539
3 1 2.59 Notated 0.837 0.533 3 NA 0.378
4 1 2.59 Notated 0.837 0.533 4 NA 0.148
5 1 2.59 Notated 0.837 0.533 5 NA 0.117
6 1 2.59 Notated 0.837 0.533 6 NA 0.449
I'm trying to run posthocs for the three-way interactions using emtrends.
etsSC_C <-
emtrends(IFI_ALL, ~ cond_id|GoldMSI_MT, var = "SC",cov.reduce=meanpm1sd,
infer = c(T,T,T), adjust= "BH")
PH_SC_C<- as.data.frame(contrast(etsSC_C, "pairwise", adjust= "BH"))
I've realised that while the contrasts for SC and HR effects are perfectly fine, the p-values when I'm running contrasts for ztime and IOS are likely to be unreliable/inflated due to the amount of duplicated rows.
Is this correct, and is there a solution, without using distinct() and running separate models?
Thank you in advance!