Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Between subjects error term for three-way repeated measures anova

    I have been having some difficulties trying to run a three-way, repeated measures anova. I have made several attempts to try and run this successfully, have read the FAQ on repeated measures, past forum posts, the Stata manual, and the 'help' responses within Stata, but continually get an error message stating "could not determine between-subject basic unit; use bseunit() option r(422)"

    The syntax I have predominately use is as follows:

    Code:
     anova responsetime id congruency / congruency|id cue / cue|id bias / bias|id congruency#cue /
    congruency|cue|id congruency#bias / congruency|bias|id cue#bias /
    cue|bias|id congruency#cue#bias, repeated(congruency cue)
    I have also used the click/point method of running the analysis through the Stata menu's, and have also tried to alter the syntax based on readings/research and still receive the same error.

    As an overview on my data: I have 99 subjects who have each completed 816 trials (split between 2 sessions, with each session having 408 trials each), coming to a total of 80784 trials. In both sessions the subjects response time is recorded (m/s) (DV), and subjects are measured on three independent variables. The first is a categorical, within-subjects variable ('Congruency'), where subjects in both sessions are exposed to an equal number of 'congruent' and 'incongruent' trials. The second is a categorical, within subjects variable ('Cue'), where subjects in both sessions are asked to make judgements on either the 'top' or 'bottom' half of the face. The third variable is a categorical variable ('Bias'). This variable has three levels, 'Top Bias', 'Bottom Bias' or 'No Bias'. In 1 of the 2 sessions (either the first or second), all participants are exposed to the 'No Bias' level of this variable. However, in the remaining sessions (either the first or second, depending on which session they experienced 'No Bias'), participants are exposed to either a 'Top Bias' or 'Bottom Bias', but not both.

    How these variables exist in the data set:
    DV (Response Time): Numeric Variable (m/s)
    IV1 (Congruency): Categorical Variable coded as 0 (incongruent) and 1 (congruent)
    IV2 (Cue): Categorical Variable coded as 1 (top half) and 2 (bottom half)
    IV3 (Bias): Categorical Variable coded as 0 (no bias), 1 (top bias) or 2 (bottom bias).
    ID: Participant ID (1, 2, 3 etc.)

    The data is in long format.

    I am using the most recent version of Stata, on a Macbook Pro if that impacts your suggestions.

    Does anyone have any advice on why this may be happening?
    Last edited by Chloe Pack; 31 Jul 2021, 22:23.

  • #2
    I can't follow your description completely, but it sounds like your between-subjects grouping variable is bias sequence assignment (with only two between-subject sequence-assignment groups: either "No Bias" in the first session then "Top bias" in the second or "No bias" then "Bottom bias"). So, instead three categories (top, bottom and no bias), you'll have only two, and the individual bias treatment at any given trial is the bias sequence-assignment group × session interaction term. If that's the case, then you'll need to include session in your model.

    If you want to include the interaction terms for congruence and cue, then your ANOVA model will get involved, maybe something like the following. (Begin at the "Begin here" comment; the first section of code is my attempt to emulate your dataset as I understand it. Forgive my three-letter abbreviations—they're explained in the first section.)

    .ÿ
    .ÿversionÿ17.0

    .ÿ
    .ÿclearÿ*

    .ÿ
    .ÿsetÿseedÿ`=strreverse("1621518")'

    .ÿ
    .ÿ//ÿParticipants
    .ÿquietlyÿsetÿobsÿ99

    .ÿgenerateÿbyteÿpidÿ=ÿ_n

    .ÿgenerateÿdoubleÿpid_uÿ=ÿrnormal()

    .ÿ
    .ÿ//ÿBiasÿ(between-subjects)
    .ÿgenerateÿbyteÿbiaÿ=ÿmod(_n,ÿ2)

    .ÿ
    .ÿ//ÿSessions
    .ÿquietlyÿexpandÿ2

    .ÿbysortÿpid:ÿgenerateÿsesÿ=ÿ_n

    .ÿ
    .ÿ//ÿIndividualÿtrials
    .ÿquietlyÿexpandÿ408

    .ÿbysortÿpidÿses:ÿgenerateÿintÿtrlÿ=ÿ_n

    .ÿ
    .ÿ//ÿCongruence
    .ÿbysortÿpidÿsesÿ(trl):ÿgenerateÿbyteÿcngÿ=ÿmod(_n,ÿ2)

    .ÿ
    .ÿ//ÿCue
    .ÿbysortÿpidÿsesÿ(cngÿtrl):ÿgenerateÿbyteÿcueÿ=ÿmod(_n,ÿ2)

    .ÿ
    .ÿgenerateÿdoubleÿrspÿ=ÿpid_uÿ+ÿrnormal()

    .ÿ
    .ÿ*
    .ÿ*ÿBeginÿhere
    .ÿ*
    .ÿanovaÿrspÿ///
    >ÿÿÿÿÿÿÿÿÿbiaÿ/ÿpid|biaÿ///
    >ÿÿÿÿÿÿÿÿÿsesÿbia#sesÿ/ÿses#pid|biaÿ///
    >ÿÿÿÿÿÿÿÿÿcngÿbia#cngÿ/ÿcng#pid|biaÿ///
    >ÿÿÿÿÿÿÿÿÿses#cngÿbia#ses#cngÿ/ÿses#cng#pid|biaÿ///
    >ÿÿÿÿÿÿÿÿÿcueÿbia#cueÿ/ÿcue#pid|biaÿ///
    >ÿÿÿÿÿÿÿÿÿses#cueÿbia#ses#cueÿ/ÿses#cue#pid|biaÿ///
    >ÿÿÿÿÿÿÿÿÿses#cng#cueÿbia#ses#cng#cueÿ/ÿses#cng#cue#pid|bia

    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿobsÿ=ÿÿÿÿÿ80,784ÿÿÿÿR-squaredÿÿÿÿÿ=ÿÿ0.5472
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿRootÿMSEÿÿÿÿÿÿ=ÿÿÿÿ1.00353ÿÿÿÿAdjÿR-squaredÿ=ÿÿ0.5427

    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿSourceÿ|ÿPartialÿSSÿÿÿÿÿÿÿÿÿdfÿÿÿÿÿÿÿÿÿMSÿÿÿÿÿÿÿÿFÿÿÿÿProb>F
    ÿÿÿÿÿ--------------------+----------------------------------------------------
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿModelÿ|ÿÿ97335.281ÿÿÿÿÿÿÿÿ791ÿÿÿ123.05345ÿÿÿÿ122.19ÿÿ0.0000
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿbiaÿ|ÿÿ1933.8915ÿÿÿÿÿÿÿÿÿÿ1ÿÿÿ1933.8915ÿÿÿÿÿÿ1.98ÿÿ0.1627
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿpid|biaÿ|ÿÿ94790.057ÿÿÿÿÿÿÿÿÿ97ÿÿÿ977.21708ÿÿ
    ÿÿÿÿÿ--------------------+----------------------------------------------------
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿsesÿ|ÿÿ.17939089ÿÿÿÿÿÿÿÿÿÿ1ÿÿÿ.17939089ÿÿÿÿÿÿ0.17ÿÿ0.6841
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿbia#sesÿ|ÿÿ.31998294ÿÿÿÿÿÿÿÿÿÿ1ÿÿÿ.31998294ÿÿÿÿÿÿ0.30ÿÿ0.5870
    ÿÿÿÿÿÿÿÿÿÿÿÿÿses#pid|biaÿ|ÿÿ104.50739ÿÿÿÿÿÿÿÿÿ97ÿÿÿ1.0773957ÿÿ
    ÿÿÿÿÿ--------------------+----------------------------------------------------
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿcngÿ|ÿÿ.88074717ÿÿÿÿÿÿÿÿÿÿ1ÿÿÿ.88074717ÿÿÿÿÿÿ1.02ÿÿ0.3157
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿbia#cngÿ|ÿÿ.00370131ÿÿÿÿÿÿÿÿÿÿ1ÿÿÿ.00370131ÿÿÿÿÿÿ0.00ÿÿ0.9480
    ÿÿÿÿÿÿÿÿÿÿÿÿÿcng#pid|biaÿ|ÿÿ83.972909ÿÿÿÿÿÿÿÿÿ97ÿÿÿ.86570009ÿÿ
    ÿÿÿÿÿ--------------------+----------------------------------------------------
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿses#cngÿ|ÿÿ.21428233ÿÿÿÿÿÿÿÿÿÿ1ÿÿÿ.21428233ÿÿÿÿÿÿ0.29ÿÿ0.5895
    ÿÿÿÿÿÿÿÿÿÿÿÿÿbia#ses#cngÿ|ÿÿ.03671587ÿÿÿÿÿÿÿÿÿÿ1ÿÿÿ.03671587ÿÿÿÿÿÿ0.05ÿÿ0.8231
    ÿÿÿÿÿÿÿÿÿses#cng#pid|biaÿ|ÿÿ70.907145ÿÿÿÿÿÿÿÿÿ97ÿÿÿ.73100149ÿÿ
    ÿÿÿÿÿ--------------------+----------------------------------------------------
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿcueÿ|ÿÿ.13167178ÿÿÿÿÿÿÿÿÿÿ1ÿÿÿ.13167178ÿÿÿÿÿÿ0.20ÿÿ0.6592
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿbia#cueÿ|ÿÿ.16347827ÿÿÿÿÿÿÿÿÿÿ1ÿÿÿ.16347827ÿÿÿÿÿÿ0.24ÿÿ0.6232
    ÿÿÿÿÿÿÿÿÿÿÿÿÿcue#pid|biaÿ|ÿÿÿ65.26874ÿÿÿÿÿÿÿÿÿ97ÿÿÿ.67287361ÿÿ
    ÿÿÿÿÿ--------------------+----------------------------------------------------
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿses#cueÿ|ÿÿ.13897529ÿÿÿÿÿÿÿÿÿÿ1ÿÿÿ.13897529ÿÿÿÿÿÿ0.15ÿÿ0.6989
    ÿÿÿÿÿÿÿÿÿÿÿÿÿbia#ses#cueÿ|ÿÿÿ.0419194ÿÿÿÿÿÿÿÿÿÿ1ÿÿÿÿ.0419194ÿÿÿÿÿÿ0.05ÿÿ0.8317
    ÿÿÿÿÿÿÿÿÿses#cue#pid|biaÿ|ÿÿ89.595708ÿÿÿÿÿÿÿÿÿ97ÿÿÿ.92366709ÿÿ
    ÿÿÿÿÿ--------------------+----------------------------------------------------
    ÿÿÿÿÿÿÿÿÿÿÿÿÿses#cng#cueÿ|ÿÿ.52986904ÿÿÿÿÿÿÿÿÿÿ2ÿÿÿ.26493452ÿÿÿÿÿÿ0.26ÿÿ0.7676
    ÿÿÿÿÿÿÿÿÿbia#ses#cng#cueÿ|ÿÿ.40489154ÿÿÿÿÿÿÿÿÿÿ2ÿÿÿ.20244577ÿÿÿÿÿÿ0.20ÿÿ0.8169
    ÿÿÿÿÿses#cng#cue#pid|biaÿ|ÿÿ194.03308ÿÿÿÿÿÿÿÿ194ÿÿÿ1.0001705ÿÿ
    ÿÿÿÿÿ--------------------+----------------------------------------------------
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿResidualÿ|ÿÿ80558.158ÿÿÿÿÿ79,992ÿÿÿ1.0070777ÿÿ
    ÿÿÿÿÿ--------------------+----------------------------------------------------
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿTotalÿ|ÿÿ177893.44ÿÿÿÿÿ80,783ÿÿÿ2.2021148ÿÿ

    .ÿ
    .ÿexit

    endÿofÿdo-file


    .


    As far as your error message, the model might be too complicated to be able to determine what to pool the covariance matrixes over despite adding in all of the relevant factors and their interaction terms.

    Also, given that your response is a latency (reaction time) that might be very skew, you might want to consider a generalized linear mixed model, e.g., with meglm, instead of ANOVA.

    Comment


    • #3
      Whoops, it looks like I overlooked a couple of choice interaction terms, included below. I hope that I've got them all, now.

      You can see how involved things have become. It might not make sense to include the repeated() option—which is giving rise to your error message—inasmuch as you've got eight random effects in the model. The question as to which serves as the between-subject basic unit might not have an unambiguous answer for the various factors and their interaction terms, which don't share a common (random effects) error term.

      .ÿanovaÿrspÿ///
      >ÿÿÿÿÿÿÿÿÿbiaÿ/ÿpid|biaÿ///
      >ÿÿÿÿÿÿÿÿÿsesÿbia#sesÿ/ÿses#pid|biaÿ///
      >ÿÿÿÿÿÿÿÿÿcngÿbia#cngÿ/ÿcng#pid|biaÿ///
      >ÿÿÿÿÿÿÿÿÿses#cngÿbia#ses#cngÿ/ÿses#cng#pid|biaÿ///
      >ÿÿÿÿÿÿÿÿÿcueÿbia#cueÿ/ÿcue#pid|biaÿ///
      >ÿÿÿÿÿÿÿÿÿses#cueÿbia#ses#cueÿ/ÿses#cue#pid|biaÿ///
      >ÿÿÿÿÿÿÿÿÿcng#cueÿbia#cng#cueÿ/ÿcng#cue#pid|biaÿ///
      >ÿÿÿÿÿÿÿÿÿses#cng#cueÿbia#ses#cng#cueÿ/ÿses#cng#cue#pid|biaÿ//,ÿrepeated(sesÿcngÿcue)

      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿobsÿ=ÿÿÿÿÿ80,784ÿÿÿÿR-squaredÿÿÿÿÿ=ÿÿ0.5472
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿRootÿMSEÿÿÿÿÿÿ=ÿÿÿÿ1.00353ÿÿÿÿAdjÿR-squaredÿ=ÿÿ0.5427

      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿSourceÿ|ÿPartialÿSSÿÿÿÿÿÿÿÿÿdfÿÿÿÿÿÿÿÿÿMSÿÿÿÿÿÿÿÿFÿÿÿÿProb>F
      ÿÿÿÿÿ--------------------+----------------------------------------------------
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿModelÿ|ÿÿ97335.281ÿÿÿÿÿÿÿÿ791ÿÿÿ123.05345ÿÿÿÿ122.19ÿÿ0.0000
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿbiaÿ|ÿÿ1933.8915ÿÿÿÿÿÿÿÿÿÿ1ÿÿÿ1933.8915ÿÿÿÿÿÿ1.98ÿÿ0.1627
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿpid|biaÿ|ÿÿ94790.057ÿÿÿÿÿÿÿÿÿ97ÿÿÿ977.21708ÿÿ
      ÿÿÿÿÿ--------------------+----------------------------------------------------
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿsesÿ|ÿÿ.17939089ÿÿÿÿÿÿÿÿÿÿ1ÿÿÿ.17939089ÿÿÿÿÿÿ0.17ÿÿ0.6841
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿbia#sesÿ|ÿÿ.31998294ÿÿÿÿÿÿÿÿÿÿ1ÿÿÿ.31998294ÿÿÿÿÿÿ0.30ÿÿ0.5870
      ÿÿÿÿÿÿÿÿÿÿÿÿÿses#pid|biaÿ|ÿÿ104.50739ÿÿÿÿÿÿÿÿÿ97ÿÿÿ1.0773957ÿÿ
      ÿÿÿÿÿ--------------------+----------------------------------------------------
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿcngÿ|ÿÿ.88074717ÿÿÿÿÿÿÿÿÿÿ1ÿÿÿ.88074717ÿÿÿÿÿÿ1.02ÿÿ0.3157
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿbia#cngÿ|ÿÿ.00370131ÿÿÿÿÿÿÿÿÿÿ1ÿÿÿ.00370131ÿÿÿÿÿÿ0.00ÿÿ0.9480
      ÿÿÿÿÿÿÿÿÿÿÿÿÿcng#pid|biaÿ|ÿÿ83.972909ÿÿÿÿÿÿÿÿÿ97ÿÿÿ.86570009ÿÿ
      ÿÿÿÿÿ--------------------+----------------------------------------------------
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿses#cngÿ|ÿÿ.21428233ÿÿÿÿÿÿÿÿÿÿ1ÿÿÿ.21428233ÿÿÿÿÿÿ0.29ÿÿ0.5895
      ÿÿÿÿÿÿÿÿÿÿÿÿÿbia#ses#cngÿ|ÿÿ.03671587ÿÿÿÿÿÿÿÿÿÿ1ÿÿÿ.03671587ÿÿÿÿÿÿ0.05ÿÿ0.8231
      ÿÿÿÿÿÿÿÿÿses#cng#pid|biaÿ|ÿÿ70.907145ÿÿÿÿÿÿÿÿÿ97ÿÿÿ.73100149ÿÿ
      ÿÿÿÿÿ--------------------+----------------------------------------------------
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿcueÿ|ÿÿ.13167178ÿÿÿÿÿÿÿÿÿÿ1ÿÿÿ.13167178ÿÿÿÿÿÿ0.20ÿÿ0.6592
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿbia#cueÿ|ÿÿ.16347827ÿÿÿÿÿÿÿÿÿÿ1ÿÿÿ.16347827ÿÿÿÿÿÿ0.24ÿÿ0.6232
      ÿÿÿÿÿÿÿÿÿÿÿÿÿcue#pid|biaÿ|ÿÿÿ65.26874ÿÿÿÿÿÿÿÿÿ97ÿÿÿ.67287361ÿÿ
      ÿÿÿÿÿ--------------------+----------------------------------------------------
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿses#cueÿ|ÿÿ.13897529ÿÿÿÿÿÿÿÿÿÿ1ÿÿÿ.13897529ÿÿÿÿÿÿ0.15ÿÿ0.6989
      ÿÿÿÿÿÿÿÿÿÿÿÿÿbia#ses#cueÿ|ÿÿÿ.0419194ÿÿÿÿÿÿÿÿÿÿ1ÿÿÿÿ.0419194ÿÿÿÿÿÿ0.05ÿÿ0.8317
      ÿÿÿÿÿÿÿÿÿses#cue#pid|biaÿ|ÿÿ89.595708ÿÿÿÿÿÿÿÿÿ97ÿÿÿ.92366709ÿÿ
      ÿÿÿÿÿ--------------------+----------------------------------------------------
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿcng#cueÿ|ÿÿ.23060249ÿÿÿÿÿÿÿÿÿÿ1ÿÿÿ.23060249ÿÿÿÿÿÿ0.21ÿÿ0.6508
      ÿÿÿÿÿÿÿÿÿÿÿÿÿbia#cng#cueÿ|ÿÿ.37669776ÿÿÿÿÿÿÿÿÿÿ1ÿÿÿ.37669776ÿÿÿÿÿÿ0.34ÿÿ0.5630
      ÿÿÿÿÿÿÿÿÿcng#cue#pid|biaÿ|ÿÿ108.47319ÿÿÿÿÿÿÿÿÿ97ÿÿÿ1.1182803ÿÿ
      ÿÿÿÿÿ--------------------+----------------------------------------------------
      ÿÿÿÿÿÿÿÿÿÿÿÿÿses#cng#cueÿ|ÿÿ.29926655ÿÿÿÿÿÿÿÿÿÿ1ÿÿÿ.29926655ÿÿÿÿÿÿ0.34ÿÿ0.5616
      ÿÿÿÿÿÿÿÿÿbia#ses#cng#cueÿ|ÿÿ.02819379ÿÿÿÿÿÿÿÿÿÿ1ÿÿÿ.02819379ÿÿÿÿÿÿ0.03ÿÿ0.8585
      ÿÿÿÿÿses#cng#cue#pid|biaÿ|ÿÿ85.559886ÿÿÿÿÿÿÿÿÿ97ÿÿÿ.88206068ÿÿ
      ÿÿÿÿÿ--------------------+----------------------------------------------------
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿResidualÿ|ÿÿ80558.158ÿÿÿÿÿ79,992ÿÿÿ1.0070777ÿÿ
      ÿÿÿÿÿ--------------------+----------------------------------------------------
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿTotalÿ|ÿÿ177893.44ÿÿÿÿÿ80,783ÿÿÿ2.2021148ÿÿ


      Comment

      Working...
      X