Announcement

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

  • Multilevel dataset with crossover deisgn

    Hi,

    I am working on a dataset which has the multilevel data structure and a crossover design. Specifically, two groups of subject went through two sessions by following AB/BA sequence, respectively. Within each session, each subject completed rounds of rating tasks, which cannot be simply merged into one score. I am checking the pkcross command from the pk package but it seems like that this command can only handle the situation when one subject has only one observation from each single session.

    I am wondering if there any method that I can use to applied multilevel modeling approach to handle the crossover design dataset.

    Thank you very much!

    Tian

  • #2
    Originally posted by Tian Lin View Post
    . . .two groups of subject went through two sessions by following AB/BA sequence, respectively. Within each session, each subject completed rounds of rating tasks, which cannot be simply merged into one score. I am checking the pkcross command . . . but . . . this command can only handle the situation when one subject has only one observation from each single session.
    If you think of the design as of a multivariate set of scores instead of as a multilevel structure, then you can use manova to fit the direct multivariate analogue of the ANOVA model that pkcross fits.

    You can see that in the MANOVA table in the output of the example shown below—compare it to the ANOVA table that pkcross gives by default in its help file's example. (Begin at the "Begin here" comment; the stuff above is just to create a toy dataset for illustration. I've chosen a total of three rounds of rating task, labeled sco1, sco2 and sco3 below.)

    .ÿ
    .ÿversionÿ17.0

    .ÿ
    .ÿclearÿ*

    .ÿ
    .ÿ//ÿseedem
    .ÿsetÿseedÿ1629644126

    .ÿ
    .ÿquietlyÿsetÿobsÿ30

    .ÿgenerateÿbyteÿpidÿ=ÿ_n

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

    .ÿgenerateÿbyteÿseqÿ=ÿ!mod(_n,ÿ2)

    .ÿlabelÿdefineÿSequencesÿ0ÿABÿ1ÿBA

    .ÿlabelÿvaluesÿseqÿSequences

    .ÿ
    .ÿquietlyÿexpandÿ2

    .ÿbysortÿpid:ÿgenerateÿbyteÿperÿ=ÿ_nÿ-ÿ1

    .ÿlabelÿdefineÿPeriodsÿ0ÿFirstÿ1ÿSecond

    .ÿlabelÿvaluesÿperÿPeriods

    .ÿ
    .ÿquietlyÿdrawnormÿe1ÿe2ÿe3,ÿdoubleÿcorr(1ÿ0.5ÿ0.5ÿ\ÿ0.5ÿ1ÿ0.5ÿ\ÿ0.5ÿ0.5ÿ1)

    .ÿ
    .ÿforvaluesÿiÿ=ÿ1/3ÿ{
    ÿÿ2.ÿÿÿÿÿÿÿÿÿgenerateÿdoubleÿsco`i'ÿ=ÿpid_uÿ+ÿe`i'
    ÿÿ3.ÿ}

    .ÿ
    .ÿgenerateÿbyteÿtrtÿ=ÿcond(seq,ÿ!per,ÿper)

    .ÿlabelÿdefineÿTreatmentsÿ0ÿAÿ1ÿB

    .ÿlabelÿvaluesÿtrtÿTreatments

    .ÿ
    .ÿkeepÿpidÿseqÿperÿtrtÿsco?

    .ÿformatÿsco?ÿ%03.1f

    .ÿ
    .ÿ*
    .ÿ*ÿBeginÿhere
    .ÿ*
    .ÿlistÿpidÿseqÿperÿtrtÿsco?ÿifÿinlist(pid,ÿ1,ÿ2),ÿnoobsÿsepby(pid)

    ÿÿ+-----------------------------------------------+
    ÿÿ|ÿpidÿÿÿseqÿÿÿÿÿÿperÿÿÿtrtÿÿÿsco1ÿÿÿsco2ÿÿÿsco3ÿ|
    ÿÿ|-----------------------------------------------|
    ÿÿ|ÿÿÿ1ÿÿÿÿABÿÿÿÿFirstÿÿÿÿÿAÿÿÿÿ0.1ÿÿÿÿ0.1ÿÿÿÿ1.7ÿ|
    ÿÿ|ÿÿÿ1ÿÿÿÿABÿÿÿSecondÿÿÿÿÿBÿÿÿÿ0.5ÿÿÿÿ3.1ÿÿÿÿ2.4ÿ|
    ÿÿ|-----------------------------------------------|
    ÿÿ|ÿÿÿ2ÿÿÿÿBAÿÿÿÿFirstÿÿÿÿÿBÿÿÿÿ0.5ÿÿÿÿ0.9ÿÿÿÿ0.8ÿ|
    ÿÿ|ÿÿÿ2ÿÿÿÿBAÿÿÿSecondÿÿÿÿÿAÿÿÿ-1.4ÿÿÿ-0.5ÿÿÿ-0.8ÿ|
    ÿÿ+-----------------------------------------------+

    .ÿ
    .ÿmanovaÿsco?ÿ=ÿseqÿ/ÿpidÿtrtÿper

    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿobsÿ=ÿÿÿÿÿÿÿÿÿ60

    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿWÿ=ÿWilks'ÿlambdaÿÿÿÿÿÿLÿ=ÿLawley-Hotellingÿtrace
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿPÿ=ÿPillai'sÿtraceÿÿÿÿÿRÿ=ÿRoy'sÿlargestÿroot

    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿSourceÿ|ÿStatisticÿÿÿÿÿÿÿÿdfÿÿÿÿF(df1,ÿÿÿÿÿdf2)ÿ=ÿÿÿFÿÿÿProb>F
    ÿÿÿÿÿÿÿÿÿÿ-----------+-------------------------------------------------------
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿModelÿ|Wÿÿÿ0.0424ÿÿÿÿÿÿÿÿ31ÿÿÿÿÿ93.0ÿÿÿÿÿ78.7ÿÿÿÿÿ1.59ÿ0.0181ÿa
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|Pÿÿÿ1.7405ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ93.0ÿÿÿÿÿ84.0ÿÿÿÿÿ1.25ÿ0.1511ÿa
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|Lÿÿÿ7.9079ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ93.0ÿÿÿÿÿ74.0ÿÿÿÿÿ2.10ÿ0.0006ÿa
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|Rÿÿÿ6.2711ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ31.0ÿÿÿÿÿ28.0ÿÿÿÿÿ5.66ÿ0.0000ÿu
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|-------------------------------------------------------
    ÿÿÿÿÿÿÿÿÿÿÿÿResidualÿ|ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ28
    ÿÿÿÿÿÿÿÿÿÿ-----------+-------------------------------------------------------
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿseqÿ|Wÿÿÿ0.7713ÿÿÿÿÿÿÿÿÿ1ÿÿÿÿÿÿ3.0ÿÿÿÿÿ26.0ÿÿÿÿÿ2.57ÿ0.0759ÿe
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|Pÿÿÿ0.2287ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ3.0ÿÿÿÿÿ26.0ÿÿÿÿÿ2.57ÿ0.0759ÿe
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|Lÿÿÿ0.2965ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ3.0ÿÿÿÿÿ26.0ÿÿÿÿÿ2.57ÿ0.0759ÿe
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|Rÿÿÿ0.2965ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ3.0ÿÿÿÿÿ26.0ÿÿÿÿÿ2.57ÿ0.0759ÿe
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|-------------------------------------------------------
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿpidÿ|ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ28
    ÿÿÿÿÿÿÿÿÿÿ-----------+-------------------------------------------------------
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿtrtÿ|Wÿÿÿ0.7361ÿÿÿÿÿÿÿÿÿ1ÿÿÿÿÿÿ3.0ÿÿÿÿÿ26.0ÿÿÿÿÿ3.11ÿ0.0437ÿe
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|Pÿÿÿ0.2639ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ3.0ÿÿÿÿÿ26.0ÿÿÿÿÿ3.11ÿ0.0437ÿe
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|Lÿÿÿ0.3586ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ3.0ÿÿÿÿÿ26.0ÿÿÿÿÿ3.11ÿ0.0437ÿe
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|Rÿÿÿ0.3586ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ3.0ÿÿÿÿÿ26.0ÿÿÿÿÿ3.11ÿ0.0437ÿe
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|-------------------------------------------------------
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿperÿ|Wÿÿÿ0.9613ÿÿÿÿÿÿÿÿÿ1ÿÿÿÿÿÿ3.0ÿÿÿÿÿ26.0ÿÿÿÿÿ0.35ÿ0.7905ÿe
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|Pÿÿÿ0.0387ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ3.0ÿÿÿÿÿ26.0ÿÿÿÿÿ0.35ÿ0.7905ÿe
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|Lÿÿÿ0.0402ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ3.0ÿÿÿÿÿ26.0ÿÿÿÿÿ0.35ÿ0.7905ÿe
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|Rÿÿÿ0.0402ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ3.0ÿÿÿÿÿ26.0ÿÿÿÿÿ0.35ÿ0.7905ÿe
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|-------------------------------------------------------
    ÿÿÿÿÿÿÿÿÿÿÿÿResidualÿ|ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ28
    ÿÿÿÿÿÿÿÿÿÿ-----------+-------------------------------------------------------
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿTotalÿ|ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ59
    ÿÿÿÿÿÿÿÿÿÿ-------------------------------------------------------------------
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿeÿ=ÿexact,ÿaÿ=ÿapproximate,ÿuÿ=ÿupperÿboundÿonÿF

    .ÿmarginsÿ,ÿdydx(trt)

    AverageÿmarginalÿeffectsÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿobsÿ=ÿ60

    dy/dxÿwrt:ÿ1.trt

    1._predict:ÿLinearÿprediction,ÿpredict(xbÿequation(sco1))
    2._predict:ÿLinearÿprediction,ÿpredict(xbÿequation(sco2))
    3._predict:ÿLinearÿprediction,ÿpredict(xbÿequation(sco3))

    ------------------------------------------------------------------------------
    ÿÿÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿÿÿÿÿÿÿÿÿÿDelta-method
    ÿÿÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿÿÿÿdy/dxÿÿÿstd.ÿerr.ÿÿÿÿÿÿtÿÿÿÿP>|t|ÿÿÿÿÿ[95%ÿconf.ÿinterval]
    -------------+----------------------------------------------------------------
    0.trtÿÿÿÿÿÿÿÿ|ÿÿ(baseÿoutcome)
    -------------+----------------------------------------------------------------
    1.trtÿÿÿÿÿÿÿÿ|
    ÿÿÿÿ_predictÿ|
    ÿÿÿÿÿÿÿÿÿÿ1ÿÿ|ÿÿÿ.6018323ÿÿÿ.2672773ÿÿÿÿÿ2.25ÿÿÿ0.032ÿÿÿÿÿ.0543395ÿÿÿÿ1.149325
    ÿÿÿÿÿÿÿÿÿÿ2ÿÿ|ÿÿÿ.4109652ÿÿÿ.2927855ÿÿÿÿÿ1.40ÿÿÿ0.171ÿÿÿÿ-.1887787ÿÿÿÿ1.010709
    ÿÿÿÿÿÿÿÿÿÿ3ÿÿ|ÿÿÿ.6183301ÿÿÿ.2221875ÿÿÿÿÿ2.78ÿÿÿ0.010ÿÿÿÿÿ.1631996ÿÿÿÿ1.073461
    ------------------------------------------------------------------------------
    Note:ÿdy/dxÿforÿfactorÿlevelsÿisÿtheÿdiscreteÿchangeÿfromÿtheÿbaseÿlevel.

    .ÿ
    .ÿexit

    endÿofÿdo-file


    .


    Based upon your reference to pkcross and your first looking into that approach, I'm assuming that a linear model is suitable for the scores on your rounds of rating tasks. MANOVA can be sensitive to violations of its assumptions.

    Comment


    • #3
      Hi Joseph,

      Thank you for your inputs. However, I am not sure if MANOVA is a proper approach for my dataset.

      My dataset is based on a task in which subjects conducted ratings for 160 trials. Those trials varied along with a dimension. My main research interests is to examine how the effect of this dimension of the stimuli on participants' ratings varied as a function of the treatment. Based on this task, the study employed a crossover design for treatment (experiment vs. control) and session (session1 vs. session2).

      The dimension of the stimuli is a continuous variable. So, I do not think I can apply MANOVA to convert this within-subject variable into a multivariate fashion. Is there anyway that I can handle this continuous within-subject variable with a crossover design?

      While I may categorize this variable, I believe the more levels I categorize this variable the better this categorized variable to grab the effects of the continuous version of this variable. Therefore, I may need to categorize it into 6 levels for example. However, I am not sure if there is a way to handle the crossover design with another categorical within-subject variable with six levels?

      Thank you very much.

      Tian

      Comment


      • #4
        Originally posted by Tian Lin View Post
        My dataset is based on a task in which subjects conducted ratings for 160 trials. Those trials varied along with a dimension. My main research interests is to examine how the effect of this dimension of the stimuli on participants' ratings varied as a function of the treatment. . . . The dimension of the stimuli is a continuous variable.
        I'm afraid that I don't follow what you've got there. Others on the list might be able to understand it and help you out more.

        It probably would've been better had you followed the forum's FAQ and provided a sample of your data for a representative handful of participants.

        Comment

        Working...
        X