You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have what seems a simple case that cannot properly fit.
I have a dependent variable that is measured 10 times per subject. However, the mediator is only once after the intervention (there are two groups: Control and Interventions)
To be sure: model_m is fit using lm because the mediator is only measured once (note that data=unique(df)), whereas model_dv is fitted using lmer because it is measured 10 times (within subject).
It triggers this error, which makes sense: one group has 10 times more rows.
Instead, I tried the following:
model_m <- lmer(mediator ~ group + (1|subj), data=df )
model_dv <- lmer(dv ~ group + mediator + (1 | subj), data = df)
mediate(model_m, model_dv, treat='group', mediator='mediator', boot=F)
This works except that model.m is incorrect because it is fitted in 10 times the measurements that actually were taken. As a consequence, there are several warnings displayed (e.g., model failed to converge which makes sense), *the estimates are the same as the ones obtained with lm but the the standard errors are smaller.
Is it OK to still the model_m (fitted with lmer) even though some of the statistics are wrong? In other words, which statistics of the lmerMod object are used inside the mediate function? (I can then check if they are all the same and it is just about the format of the data)
The text was updated successfully, but these errors were encountered:
I just made sure that my data looked as similar as possible to the example. It is difficult to say what change did the trick, but here are a few things that I noticed:
my group was not properly converted to an integer. I made sure that the values were 0 for the control and 1 for the intervention group
I was using the subset parameter of lm. In the example, I used unique() to make it clear, but subset parameter definitely does not work
I have what seems a simple case that cannot properly fit.
I have a dependent variable that is measured 10 times per subject. However, the mediator is only once after the intervention (there are two groups: Control and Interventions)
I thought that the following would work:
To be sure: model_m is fit using
lm
because the mediator is only measured once (note thatdata=unique(df)
), whereas model_dv is fitted usinglmer
because it is measured 10 times (within subject).It triggers this error, which makes sense: one group has 10 times more rows.
Instead, I tried the following:
This works except that
model.m
is incorrect because it is fitted in 10 times the measurements that actually were taken. As a consequence, there are several warnings displayed (e.g., model failed to converge which makes sense), *the estimates are the same as the ones obtained withlm
but the the standard errors are smaller.Is it OK to still the
model_m
(fitted withlmer
) even though some of the statistics are wrong? In other words, which statistics of the lmerMod object are used inside themediate
function? (I can then check if they are all the same and it is just about the format of the data)The text was updated successfully, but these errors were encountered: