Announcement

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

  • Crossover design analysis using mixed

    Dear Statalist,

    I am using -mixed- in Stata 15.1 to analyze a crossover trial.

    In this trial participants received 3 different treatments (0,1,2), after which blood glucose concentrations were measured every 15 mins for a total of 150 minutes.

    I am using the following code to analyze the data:

    Code:
    mixed glucose ib0.treatment##c.timepoint || pid:, covariance (id) || visit:timepoint, covariance (id)
    This produces the following output:

    Code:
    Performing EM optimization: 
    
    Performing gradient-based optimization: 
    
    Iteration 0:   log likelihood = -423.54287  
    Iteration 1:   log likelihood = -423.45032  
    Iteration 2:   log likelihood = -423.44899  
    Iteration 3:   log likelihood =  -423.4489  
    Iteration 4:   log likelihood =  -423.4489  
    
    Computing standard errors:
    
    Mixed-effects ML regression                     Number of obs     =        330
    
    -------------------------------------------------------------
                    |     No. of       Observations per Group
     Group Variable |     Groups    Minimum    Average    Maximum
    ----------------+--------------------------------------------
                pid |         11         30       30.0         30
              visit |         33         10       10.0         10
    -------------------------------------------------------------
    
                                                    Wald chi2(5)      =      30.02
    Log likelihood =  -423.4489                     Prob > chi2       =     0.0000
    
    ---------------------------------------------------------------------------------------
                  glucose |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    ----------------------+----------------------------------------------------------------
                treatment |
                       1  |   .0339427    .233476     0.15   0.884    -.4236618    .4915472
                       2  |   .5280048    .233476     2.26   0.024     .0704003    .9856093
                          |
                timepoint |   .0112455   .0024101     4.67   0.000     .0065217    .0159693
                          |
    treatment#c.timepoint |
                       1  |  -.0054439   .0034084    -1.60   0.110    -.0121244    .0012365
                       2  |  -.0107255   .0034084    -3.15   0.002    -.0174059   -.0040451
                          |
                    _cons |  -.2608308   .1650924    -1.58   0.114    -.5844061    .0627444
    ---------------------------------------------------------------------------------------
    
    ------------------------------------------------------------------------------
      Random-effects Parameters  |   Estimate   Std. Err.     [95% Conf. Interval]
    -----------------------------+------------------------------------------------
    pid: Identity                |
                      var(_cons) |   1.58e-12          .             .           .
    -----------------------------+------------------------------------------------
    visit: Identity              |
             var(timepo~t _cons) |    .000029   9.03e-06      .0000158    .0000534
    -----------------------------+------------------------------------------------
                   var(Residual) |   .6512137   .0534399      .5544625    .7648475
    ------------------------------------------------------------------------------
    LR test vs. linear model: chi2(2) = 54.95                 Prob > chi2 = 0.0000
    
    Note: LR test is conservative and provided only for reference.

    My understanding of the output is that the change in glucose over time for treatments 1 and 2 are significantly different from that of treatment 0 (this is based on the coefficients of the interaction terms).

    My questions are as follows:

    1.) what do the coefficients for treatment 1 (.0339427) and treatment 2 (5280048) and their associated P values represent? Do they represent differences between treatments at baseline (i.e. timepoint = 0)?

    2.) to identify specifically which timepoints are significantly different between treatments, I can use the marginal command as follows?

    Code:
    margins r.treatment, at(timepoint=(15 30 45 60 70 90 105 120 135 150)) asbalanced
    Thanks in advance for your help

  • #2
    Originally posted by James Frampton View Post
    what do the coefficients for treatment 1 (.0339427) and treatment 2 (5280048) and their associated P values represent? Do they represent differences between treatments at baseline (i.e. timepoint = 0)?
    No. They represent differences from treatment 0.

    2.) to identify specifically which timepoints are significantly different between treatments, I can use the marginal command as follows?

    Code:
    margins r.treatment, at(timepoint=(15 30 45 60 70 90 105 120 135 150)) asbalanced
    No. You've modeled time strictly linearly. It doesn't make sense to compare treatments at each of the time points.

    I'm curious as to the relationship between visit and treatment. For example, if your eleven patients were randomly allocated to treatment sequence, then your model is missing that predictor, and it's not clear how visit fits into the model then. It seems to be used there now solely as a marker to bestow a separate random slope value to time for each of a patient's sequential visits (not treatments), but I'm having difficulty conceptualizing a cogent data-generating process that you're trying to model by that.
    Last edited by Joseph Coveney; 06 Sep 2019, 01:33.

    Comment


    • #3
      Hi Joseph,

      Thank you for your response.

      Originally posted by Joseph Coveney View Post
      No. They represent differences from treatment 0.
      Just to clarify, they represent the differences of treatment 1 and 2 from treatment 0 at baseline (timepoint = 0) or overall?

      I'm curious as to the relationship between visit and treatment. For example, if your eleven patients were randomly allocated to treatment sequence, then your model is missing that predictor, and it's not clear how visit fits into the model then. It seems to be used there now solely as a marker to bestow a separate random slope value to time for each of a patient's sequential visits (not treatments), but I'm having difficulty conceptualizing a cogent data-generating process that you're trying to model by that.
      The variable 'visit' (which is coded as 1, 2 or 3) refers to the order in which the participants received the treatment (which I assume is directly related to treatment sequence). Would it therefore be better to code the model as following:

      Code:
       mixed glucose ib0.treatment##c.timepoint visit || pid:timepoint, covariance (id)
      I do have a follow up question:

      - what post-estimation tests would you perform? Should I be using
      Code:
      margins treatment, dydx(timepoint)
      instead?

      Many thanks
      Last edited by James Frampton; 06 Sep 2019, 07:52.

      Comment


      • #4
        Originally posted by James Frampton View Post
        Just to clarify, they represent the differences of treatment 1 and 2 from treatment 0 at baseline (timepoint = 0) or overall?
        In a sense. They are the differences in values that are extrapolated back to the regression intercept, which is zero. You don't actually have a baseline time point = 0 because, according to what you show in the Grouping Table at the top of your regression output, you never measured it.

        The variable 'visit' (which is coded as 1, 2 or 3) refers to the order in which the participants received the treatment (which I assume is directly related to treatment sequence).
        My point was that patients had to have been assigned this order, and in these kinds of study, this order or sequence is randomly assigned to participants. Because it's an essential component of the study's design, it belongs in the statistical model of the study's results.

        Would it therefore be better to code the model as following:

        Code:
        mixed glucose ib0.treatment##c.timepoint visit || pid:timepoint, covariance (id)
        I have a fundamental problem with your modeling change in glucose in a strict linear manner as this. It goes against physiology; blood glucose levels just won't behave in that way ad infinitum. For that reason (and because you have too limited a sample to estimate the second random effect well), I recommend that you abandon pursuing a random slope for time.

        If you're looking for a first-approximation of the time-course of response to the three treatments, then, in lieu of an unrealistic assumption of a linear course over time, consider just taking a summary measure, such as the integral and using that. That approach is fairly common among drug time-course crossover studies, such as those that assess therapeutic equivalence. As an alternative, if you're interested in examining the finer detail of the time-course, then use indicator variables for each time point. I illustrate both approaches in an example below. (Begin at the "Begin here" comment; the first part of the do-file just creates a fictional dataset for illustration that emulates essential features of yours.)

        One advantage that you have in your experimental setting is that you have balanced data (except with respect to sequence assignment). Because of that, you can take advantage of the small sample properties of ANOVA, which I also illustrate.

        I do have a follow up question:

        - what post-estimation tests would you perform? Should I be using
        Code:
        margins treatment, dydx(timepoint)
        instead?
        I would not do any postestimation tests. I would restrict testing to the omnibus assessment of the research question. If you want to look at the finer detail of the time-course, either plot the original values participantwise, or else use -marginsplot- after a model in which the time points are individually present as indicator variables ("factor variable" in Stata modeling parlance).

        .ÿ
        .ÿversionÿ16.0

        .ÿ
        .ÿclearÿ*

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

        .ÿ
        .ÿ//ÿPatients
        .ÿquietlyÿsetÿobsÿ11

        .ÿgenerateÿbyteÿpidÿ=ÿ_n

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

        .ÿ
        .ÿ//ÿSequencesÿ(Williams)
        .ÿgenerateÿdoubleÿranduÿ=ÿruniform()

        .ÿsortÿrandu

        .ÿgenerateÿbyteÿseqÿ=ÿmod(_n,ÿ6)ÿ+ÿ1

        .ÿ
        .ÿ#delimitÿ;
        delimiterÿnowÿ;
        .ÿlabelÿdefineÿLSÿ
        >ÿÿÿÿÿÿÿÿÿ1ÿ"AÿBÿC"ÿ
        >ÿÿÿÿÿÿÿÿÿ2ÿ"BÿCÿA"ÿ
        >ÿÿÿÿÿÿÿÿÿ3ÿ"CÿAÿB"ÿ
        >ÿÿÿÿÿÿÿÿÿ4ÿ"CÿBÿA"ÿ
        >ÿÿÿÿÿÿÿÿÿ5ÿ"AÿCÿB"ÿ
        >ÿÿÿÿÿÿÿÿÿ6ÿ"BÿAÿC";

        .ÿ#delimitÿcr
        delimiterÿnowÿcr
        .ÿlabelÿvaluesÿseqÿLS

        .ÿ
        .ÿ//ÿTreatmentsÿ&ÿvisits
        .ÿdecodeÿseq,ÿgenerate(sequence)

        .ÿquietlyÿsplitÿsequence,ÿgenerate(treatment)

        .ÿquietlyÿreshapeÿlongÿtreatment,ÿi(pid)ÿj(vis)

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

        .ÿencodeÿtreatment,ÿgenerate(trt)ÿlabel(Treatments)ÿnoextend

        .ÿ
        .ÿ//ÿRepeatedÿmeasurements
        .ÿquietlyÿexpandÿ10

        .ÿbysortÿpidÿvis:ÿgenerateÿintÿtimÿ=ÿ_nÿ*ÿ15

        .ÿ
        .ÿ//ÿGlucose
        .ÿgenerateÿdoubleÿgluÿ=ÿ100ÿ+ÿ///
        >ÿÿÿÿÿÿÿÿÿ0ÿ*ÿtrtÿ+ÿ0ÿ*ÿtimÿ+ÿ0ÿ*ÿtrtÿ*ÿtimÿ+ÿ0ÿ*ÿseqÿ+ÿ0ÿ*ÿvisÿ+ÿ0ÿ*ÿvisÿ*ÿtimÿ+ÿ///
        >ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿpid_uÿ+ÿ///
        >ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿrnormal(0,ÿ3)

        .ÿ*
        .ÿ*ÿBeginÿhere
        .ÿ*
        .ÿ
        .ÿ//ÿANOVA
        .ÿanovaÿgluÿseqÿ/ÿpid|seqÿtrtÿtimÿtrt#timÿvisÿtrt#visÿvis#timÿseq#tim

        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿobsÿ=ÿÿÿÿÿÿÿÿ330ÿÿÿÿR-squaredÿÿÿÿÿ=ÿÿ0.3538
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿRootÿMSEÿÿÿÿÿÿ=ÿÿÿÿ3.28094ÿÿÿÿAdjÿR-squaredÿ=ÿÿ0.0381

        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿSourceÿ|ÿPartialÿSSÿÿÿÿÿÿÿÿÿdfÿÿÿÿÿÿÿÿÿMSÿÿÿÿÿÿÿÿFÿÿÿÿProb>F
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿ-----------+----------------------------------------------------
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿModelÿ|ÿÿ1302.7233ÿÿÿÿÿÿÿÿ108ÿÿÿ12.062253ÿÿÿÿÿÿ1.12ÿÿ0.2395
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿseqÿ|ÿÿ118.29932ÿÿÿÿÿÿÿÿÿÿ5ÿÿÿ23.659864ÿÿÿÿÿÿ0.49ÿÿ0.7748
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿpid|seqÿ|ÿÿ242.18981ÿÿÿÿÿÿÿÿÿÿ5ÿÿÿ48.437963ÿÿ
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿ-----------+----------------------------------------------------
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿtrtÿ|ÿÿ2.6381029ÿÿÿÿÿÿÿÿÿÿ2ÿÿÿ1.3190515ÿÿÿÿÿÿ0.12ÿÿ0.8847
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿtimÿ|ÿÿ88.866095ÿÿÿÿÿÿÿÿÿÿ9ÿÿÿ9.8740106ÿÿÿÿÿÿ0.92ÿÿ0.5109
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿtrt#timÿ|ÿÿ161.54461ÿÿÿÿÿÿÿÿÿ18ÿÿÿ8.9747007ÿÿÿÿÿÿ0.83ÿÿ0.6593
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿvisÿ|ÿÿ49.292253ÿÿÿÿÿÿÿÿÿÿ2ÿÿÿ24.646127ÿÿÿÿÿÿ2.29ÿÿ0.1037
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿtrt#visÿ|ÿÿ26.899835ÿÿÿÿÿÿÿÿÿÿ4ÿÿÿ6.7249587ÿÿÿÿÿÿ0.62ÿÿ0.6453
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿvis#timÿ|ÿÿ180.79946ÿÿÿÿÿÿÿÿÿ18ÿÿÿ10.044415ÿÿÿÿÿÿ0.93ÿÿ0.5392
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿseq#timÿ|ÿÿ348.99504ÿÿÿÿÿÿÿÿÿ45ÿÿÿ7.7554454ÿÿÿÿÿÿ0.72ÿÿ0.9052
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿResidualÿ|ÿÿ2378.9672ÿÿÿÿÿÿÿÿ221ÿÿÿ10.764558ÿÿ
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿ-----------+----------------------------------------------------
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿTotalÿ|ÿÿ3681.6906ÿÿÿÿÿÿÿÿ329ÿÿÿ11.190549ÿÿ

        .ÿ
        .ÿ*ÿor
        .ÿ
        .ÿquietlyÿxtregÿgluÿi.(seqÿtrtÿtimÿtrt#timÿvisÿtrt#visÿvis#timÿseq#tim),ÿi(pid)ÿfe

        .ÿcontrastÿtrtÿtimÿtrt#timÿvisÿtrt#visÿvis#timÿseq#tim

        Contrastsÿofÿmarginalÿlinearÿpredictions

        Marginsÿÿÿÿÿÿ:ÿasbalanced

        ------------------------------------------------
        ÿÿÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿÿÿÿÿÿÿdfÿÿÿÿÿÿÿÿÿÿÿFÿÿÿÿÿÿÿÿP>F
        -------------+----------------------------------
        ÿÿÿÿÿÿÿÿÿtrtÿ|ÿÿÿÿÿÿÿÿÿÿ2ÿÿÿÿÿÿÿÿ0.12ÿÿÿÿÿ0.8847
        ÿÿÿÿÿÿÿÿÿÿÿÿÿ|
        ÿÿÿÿÿÿÿÿÿtimÿ|ÿÿÿÿÿÿÿÿÿÿ9ÿÿÿÿÿÿÿÿ0.92ÿÿÿÿÿ0.5109
        ÿÿÿÿÿÿÿÿÿÿÿÿÿ|
        ÿÿÿÿÿtrt#timÿ|ÿÿÿÿÿÿÿÿÿ18ÿÿÿÿÿÿÿÿ0.83ÿÿÿÿÿ0.6593
        ÿÿÿÿÿÿÿÿÿÿÿÿÿ|
        ÿÿÿÿÿÿÿÿÿvisÿ|ÿÿÿÿÿÿÿÿÿÿ2ÿÿÿÿÿÿÿÿ2.29ÿÿÿÿÿ0.1037
        ÿÿÿÿÿÿÿÿÿÿÿÿÿ|
        ÿÿÿÿÿtrt#visÿ|ÿÿÿÿÿÿÿÿÿÿ4ÿÿÿÿÿÿÿÿ0.62ÿÿÿÿÿ0.6453
        ÿÿÿÿÿÿÿÿÿÿÿÿÿ|
        ÿÿÿÿÿvis#timÿ|ÿÿÿÿÿÿÿÿÿ18ÿÿÿÿÿÿÿÿ0.93ÿÿÿÿÿ0.5392
        ÿÿÿÿÿÿÿÿÿÿÿÿÿ|
        ÿÿÿÿÿseq#timÿ|ÿÿÿÿÿÿÿÿÿ45ÿÿÿÿÿÿÿÿ0.72ÿÿÿÿÿ0.9052
        ÿÿÿÿÿÿÿÿÿÿÿÿÿ|
        ÿDenominatorÿ|ÿÿÿÿÿÿÿÿ221
        ------------------------------------------------

        .ÿ
        .ÿ*ÿor
        .ÿ
        .ÿquietlyÿmixedÿgluÿi.(seqÿtrtÿtimÿtrt#timÿvisÿtrt#visÿvis#timÿseq#tim)ÿ||ÿpid:ÿ,ÿ///
        >ÿÿÿÿÿÿÿÿÿremlÿdfmethod(satterthwaite)ÿnolrtestÿnolog

        .ÿcontrastÿtrtÿtimÿtrt#timÿvisÿtrt#visÿvis#timÿseq#tim,ÿdf(`e(df_max)')

        Contrastsÿofÿmarginalÿlinearÿpredictions

        Marginsÿÿÿÿÿÿ:ÿasbalanced

        ------------------------------------------------
        ÿÿÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿÿÿÿÿÿÿdfÿÿÿÿÿÿÿÿÿÿÿFÿÿÿÿÿÿÿÿP>F
        -------------+----------------------------------
        gluÿÿÿÿÿÿÿÿÿÿ|
        ÿÿÿÿÿÿÿÿÿtrtÿ|ÿÿÿÿÿÿÿÿÿÿ2ÿÿÿÿÿÿÿÿ0.12ÿÿÿÿÿ0.8847
        ÿÿÿÿÿÿÿÿÿÿÿÿÿ|
        ÿÿÿÿÿÿÿÿÿtimÿ|ÿÿÿÿÿÿÿÿÿÿ9ÿÿÿÿÿÿÿÿ0.92ÿÿÿÿÿ0.5109
        ÿÿÿÿÿÿÿÿÿÿÿÿÿ|
        ÿÿÿÿÿtrt#timÿ|ÿÿÿÿÿÿÿÿÿ18ÿÿÿÿÿÿÿÿ0.83ÿÿÿÿÿ0.6593
        ÿÿÿÿÿÿÿÿÿÿÿÿÿ|
        ÿÿÿÿÿÿÿÿÿvisÿ|ÿÿÿÿÿÿÿÿÿÿ2ÿÿÿÿÿÿÿÿ2.29ÿÿÿÿÿ0.1037
        ÿÿÿÿÿÿÿÿÿÿÿÿÿ|
        ÿÿÿÿÿtrt#visÿ|ÿÿÿÿÿÿÿÿÿÿ4ÿÿÿÿÿÿÿÿ0.62ÿÿÿÿÿ0.6453
        ÿÿÿÿÿÿÿÿÿÿÿÿÿ|
        ÿÿÿÿÿvis#timÿ|ÿÿÿÿÿÿÿÿÿ18ÿÿÿÿÿÿÿÿ0.93ÿÿÿÿÿ0.5392
        ÿÿÿÿÿÿÿÿÿÿÿÿÿ|
        ÿÿÿÿÿseq#timÿ|ÿÿÿÿÿÿÿÿÿ45ÿÿÿÿÿÿÿÿ0.72ÿÿÿÿÿ0.9052
        ÿÿÿÿÿÿÿÿÿÿÿÿÿ|
        ÿDenominatorÿ|ÿÿÿÿÿÿÿÿ221
        ------------------------------------------------

        .ÿ
        .ÿ//ÿSummaryÿmeasureÿàÿlaÿbioavailabilityÿstudiesÿ
        .ÿbysortÿpidÿvisÿ(tim):ÿgenerateÿbyteÿlastÿ=ÿ_nÿ==ÿ_N

        .ÿ
        .ÿgenerateÿdoubleÿiglÿ=ÿ0

        .ÿquietlyÿbyÿpidÿvis:ÿreplaceÿiglÿ=ÿ///
        >ÿÿÿÿÿÿÿÿÿsum(ÿ(gluÿ+ÿglu[_n-1])ÿ*ÿ(timÿ-ÿtim[_n-1])ÿ/ÿ2ÿ)ÿifÿ_nÿ>ÿ1

        .ÿ
        .ÿanovaÿiglÿseqÿ/ÿpid|seqÿtrtÿvisÿtrt#visÿifÿlast

        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿobsÿ=ÿÿÿÿÿÿÿÿÿ33ÿÿÿÿR-squaredÿÿÿÿÿ=ÿÿ0.7848
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿRootÿMSEÿÿÿÿÿÿ=ÿÿÿÿ137.388ÿÿÿÿAdjÿR-squaredÿ=ÿÿ0.5080

        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿSourceÿ|ÿPartialÿSSÿÿÿÿÿÿÿÿÿdfÿÿÿÿÿÿÿÿÿMSÿÿÿÿÿÿÿÿFÿÿÿÿProb>F
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿ-----------+----------------------------------------------------
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿModelÿ|ÿÿ963502.81ÿÿÿÿÿÿÿÿÿ18ÿÿÿ53527.934ÿÿÿÿÿÿ2.84ÿÿ0.0266
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿseqÿ|ÿÿ219847.29ÿÿÿÿÿÿÿÿÿÿ5ÿÿÿ43969.458ÿÿÿÿÿÿ0.54ÿÿ0.7449
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿpid|seqÿ|ÿÿ410223.64ÿÿÿÿÿÿÿÿÿÿ5ÿÿÿ82044.728ÿÿ
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿ-----------+----------------------------------------------------
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿtrtÿ|ÿÿ15859.439ÿÿÿÿÿÿÿÿÿÿ2ÿÿÿ7929.7195ÿÿÿÿÿÿ0.42ÿÿ0.6650
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿvisÿ|ÿÿ100208.42ÿÿÿÿÿÿÿÿÿÿ2ÿÿÿ50104.209ÿÿÿÿÿÿ2.65ÿÿ0.1053
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿtrt#visÿ|ÿÿ54670.023ÿÿÿÿÿÿÿÿÿÿ4ÿÿÿ13667.506ÿÿÿÿÿÿ0.72ÿÿ0.5899
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿResidualÿ|ÿÿ264258.07ÿÿÿÿÿÿÿÿÿ14ÿÿÿ18875.576ÿÿ
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿ-----------+----------------------------------------------------
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿTotalÿ|ÿÿ1227760.9ÿÿÿÿÿÿÿÿÿ32ÿÿÿ38367.527ÿÿ

        .ÿ
        .ÿexit

        endÿofÿdo-file


        .


        Note, I use the trapezoidal rule for integratioin above. Avoid using the official Stata -integ- for this. It forces a single-precision floating point variable type, regardless of any -set type- beforehand.

        Comment


        • #5
          Hi Joseph,

          Thank you for the examples. They have helped immensely.

          have a fundamental problem with your modeling change in glucose in a strict linear manner as this. It goes against physiology; blood glucose levels just won't behave in that way ad infinitum. For that reason (and because you have too limited a sample to estimate the second random effect well), I recommend that you abandon pursuing a random slope for time.
          Is it worth modelling time as a quadratic/cubic function? Either by generating new terms or using ##?

          Or another option I am aware of is the use of splines?

          quietly mixed glu i.(seq trt tim trt#tim vis trt#vis vis#tim seq#tim) || pid: , ///
          > reml dfmethod(satterthwaite) nolrtest nolog

          contrast trt tim trt#tim vis trt#vis vis#tim seq#tim, df(`e(df_max)')
          I have run this model with my data and I get a similar output to the example. However, I have significant P values for treatment and treatment#time.
          I am unsure as to what would be the best approach to investigate these significant effects.

          From my understanding you would recommend the following:

          If you want to look at the finer detail of the time-course, either plot the original values participantwise, or else use -marginsplot- after a model in which the time points are individually present as indicator variables ("factor variable" in Stata modeling parlance).
          which would be using the following code:

          Code:
          margins treatment#visit treatment, pwcompare
          is this correct? Or, alternatively would I use (?):

          Code:
          margins r.treatment, at(timepoint=(15 30 45 60 70 90 105 120 135 150)) asbalanced
          Thanks again

          Comment


          • #6
            Neither.

            You'd use something along the following lines.
            Code:
            anova glucose sequence / pid|sequence treatment##timepoint visit treatment#visit visit#timepoint sequence#timepoint
            quietly margins treatment#timepoint
            marginsplot , xdimension(timepoint) . . .
            with the ellipsis standing in for options to clean up the graph.

            Comment


            • #7
              ok great, thank you!

              Comment


              • #8
                Dear Joseph,

                Thank you for providing the example above. I have a similar crossover study where we wanted to compare the effects of 2 types of bread (trt1) on blood outcomes. I used the example that you provided and obtained the result below.

                Explanation of Variables
                trt1 - bread types. There are 2 bread types: A and B
                time_num - time measures. 0, 30, 60, 120, 180, 240
                vis - visit. Each subject visits twice, 1st or 2nd
                seq - sequence. This determines the order of the bread, AB or BA

                Code:
                . quietly mixed Lysine i.(seq trt1 trt1#time_num vis vis#time_num seq#time_num)
                >  || sid:, reml dfmethod(satterthwaite) nolrtest nolog
                
                . contrast trt1 time_num trt1#time_num vis vis#time_num seq#time_num, df(`e(df_
                > max)')
                
                Contrasts of marginal linear predictions
                
                Margins      : asbalanced
                
                -------------------------------------------------
                              |         df           F        P>F
                --------------+----------------------------------
                Lysine        |
                         trt1 |          1       13.31     0.0003
                              |
                     time_num |          5       27.09     0.0000
                              |
                trt1#time_num |          5        0.77     0.5757
                              |
                          vis |          1        1.74     0.1882
                              |
                 vis#time_num |          5        0.89     0.4859
                              |
                 seq#time_num |          5        2.03     0.0752
                              |
                  Denominator |        242
                -------------------------------------------------

                If I am trying to compare the effects of 2 types of bread on Lysine, I should look at the effects of trt1 as well as trt1#time_num right? So based on the results, I can say that at baseline, Lysine levels are significantly different between bread A and B (p=0.0003). However, over time, Lysine differences observed at baseline (in types of bread) is no longer present (p=0.5757). Is this correct?
                Last edited by Maudrene Tan; 29 Jul 2020, 02:13.

                Comment

                Working...
                X