1
$\begingroup$

I ran an experiment where participants had to perform perceptual tasks and were assigned to 1 of 3 experimental conditions. In two of the three conditions, participants performed that task in groups of size 5. In the last condition, participants performed the task independently. I am trying to measure the effect of my experimental conditions on the performance of individuals.

I want to compare the performance difference-in-means between participants assigned to condition 1 versus participants assigned to condition 2 (both conditions are done in groups, with different settings).

#(treatment is binary indicating the experimental condition)
fit <- lm(performance ~ treatment , data=df)
tidy(fit)

How can I extend this code to account for dependencies between data points within groups? (I have a variable 'group_id' for each participant)

Also, how do I compare participants assigned to condition 2 versus participants assigned to condition 3 (participants in condition 3 did the task independently, while condition 2 did it in a group -- hence the within group dependency)

$\endgroup$
1
$\begingroup$

This looks like a classic situation for a random effects model (assuming you had a non-tiny number of groups in each treatment). Using R:

library('lme4')
lmer(performance ~ treatment + (1|group), data=df)
$\endgroup$
  • $\begingroup$ Thanks. But how can I obtain the P-value from this? (this provides the same effect size, as expected, as the difference-in-mean method .. I want to compute a P-value that accounts for the dependencies) $\endgroup$ – Alhayer Jun 1 '17 at 6:25
  • 1
    $\begingroup$ There are simple commands in R to get p-values... simple to execute, but difficult to understand! Understanding the challenges of getting p-values from random effects models is really crucial to knowing how to interpret your model. Therefore, rather than giving a "plug-and-chug" answer, I'll point you to this webpage, which is the canonical reference nowadays for random effects models in R. glmm.wikidot.com/faq#df $\endgroup$ – Jacob Socolar Jun 1 '17 at 6:28
  • 1
    $\begingroup$ Once you've digested that, you might check out either of the R packages mentioned here: mindingthebrain.blogspot.com/2014/02/… $\endgroup$ – Jacob Socolar Jun 1 '17 at 6:32
0
$\begingroup$

For p-values, use the package lmerTest. Load it BEFORE the model fitting.

library('lme4')
library('lmerTest')
mod <- lmer(performance ~ treatment + (1|group), data=df)
summary(mod)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.