Skip to main content
deleted 256 characters in body
Source Link
Isabella Ghement
  • 20.9k
  • 2
  • 37
  • 60

To use individual trials, you will first need to set up your data properly. For example, if your factors A and B have two levels each, then:

Subject    Trial   A    B     C

   1         1     A1   B1   24
   1         1     A1   B2   20
   1         1     A2   B1   18
   1         1     A2   B2   21
   1         2     A1   B1   17
   1         2     A1   B2   23
   1         2     A2   B1   25
   1         2     A2   B2   19
 Etc.

This layout assumes that a trial is a repetition which involves the same participant going through all possible combinations of levels of A (i.e., A1 and A2) and levels of B (i.e., B1 and B2) to generate a set of C values. (In the above, I used some toy values for C.)

Once the data are set up properly, you can convert Subject and Trial to factors in R and then fit a model like this:

lmer(C ~ A + B + (1|Subject/Trial)  

or, equivalently:

lmer(C ~ A + B + (1|Subject) + (1|Subject:Trial)

This model formulation uses TrialSubject as a random grouping factor nested within the random grouping factor Subject and allows you to capture the variance (a) due to Subject and (b) the variance of the grouping of Subject with Trial.

To use individual trials, you will first need to set up your data properly. For example, if your factors A and B have two levels each, then:

Subject    Trial   A    B     C

   1         1     A1   B1   24
   1         1     A1   B2   20
   1         1     A2   B1   18
   1         1     A2   B2   21
   1         2     A1   B1   17
   1         2     A1   B2   23
   1         2     A2   B1   25
   1         2     A2   B2   19
 Etc.

This layout assumes that a trial is a repetition which involves the same participant going through all possible combinations of levels of A (i.e., A1 and A2) and levels of B (i.e., B1 and B2) to generate a set of C values. (In the above, I used some toy values for C.)

Once the data are set up properly, you can convert Subject and Trial to factors in R and then fit a model like this:

lmer(C ~ A + B + (1|Subject/Trial)  

or, equivalently:

lmer(C ~ A + B + (1|Subject) + (1|Subject:Trial)

This model formulation uses Trial as a random grouping factor nested within the random grouping factor Subject and allows you to capture the variance (a) due to Subject and (b) the variance of the grouping of Subject with Trial.

To use individual trials, you will first need to set up your data properly. For example, if your factors A and B have two levels each, then:

Subject    Trial   A    B     C

   1         1     A1   B1   24
   1         1     A1   B2   20
   1         1     A2   B1   18
   1         1     A2   B2   21
   1         2     A1   B1   17
   1         2     A1   B2   23
   1         2     A2   B1   25
   1         2     A2   B2   19
 Etc.

This layout assumes that a trial is a repetition which involves the same participant going through all possible combinations of levels of A (i.e., A1 and A2) and levels of B (i.e., B1 and B2) to generate a set of C values. (In the above, I used some toy values for C.)

Once the data are set up properly, you can convert Subject and Trial to factors in R and then fit a model like this:

lmer(C ~ A + B + (1|Subject)

This model formulation uses Subject as a random grouping factor.

Source Link
Isabella Ghement
  • 20.9k
  • 2
  • 37
  • 60

To use individual trials, you will first need to set up your data properly. For example, if your factors A and B have two levels each, then:

Subject    Trial   A    B     C

   1         1     A1   B1   24
   1         1     A1   B2   20
   1         1     A2   B1   18
   1         1     A2   B2   21
   1         2     A1   B1   17
   1         2     A1   B2   23
   1         2     A2   B1   25
   1         2     A2   B2   19
 Etc.

This layout assumes that a trial is a repetition which involves the same participant going through all possible combinations of levels of A (i.e., A1 and A2) and levels of B (i.e., B1 and B2) to generate a set of C values. (In the above, I used some toy values for C.)

Once the data are set up properly, you can convert Subject and Trial to factors in R and then fit a model like this:

lmer(C ~ A + B + (1|Subject/Trial)  

or, equivalently:

lmer(C ~ A + B + (1|Subject) + (1|Subject:Trial)

This model formulation uses Trial as a random grouping factor nested within the random grouping factor Subject and allows you to capture the variance (a) due to Subject and (b) the variance of the grouping of Subject with Trial.