Analysis of Repeated Measures Data using SAS (1)

 

SAS code 1: 

proc mixed data=yy method=reml;

   where param="xxx";

class USUBJID treatment AVISITN timepoint;

 

    model CHG = 

        BASE

        treatment 

        AVISITN 

        timepoint 

        treatment*AVISITN

        treatment*timepoint

        AVISITN*timepoint

        treatment*AVISITN*timepoint

        / solution ddfm=kr;

 

   repeated Timepoint / subject=USUBJID*AVISITN  type=un;

    lsmeans treatment*AVISITN*timepoint / cl;

run;


SAS code 2:

proc mixed data=yy method=reml;

where param="xxx";

 class USUBJID treatment AVISITN timepoint;

 

    model CHG = 

        BASE

        treatment 

        AVISITN 

        timepoint 

        treatment*AVISITN

        treatment*timepoint

        AVISITN*timepoint

        treatment*AVISITN*timepoint

        / solution ddfm=kr;

 repeated avisitn*Timepoint / subject=USUBJID  type=un;

  lsmeans treatment*AVISITN*timepoint / cl ;

run;



Difference in repeated Statement:


Code 1

  • Subject = USUBJID*AVISITN: This treats each subject at each visit (AVISITN) as a separate experimental unit. In other words, it assumes that repeated measures are nested within each subject-visit combination.
  • Repeated = Timepoint: The repeated measures are taken across different timepoints within each subject-visit.
  • Implication: This structure models the correlation of timepoints within each visit for each subject. It’s useful when you expect the correlation structure to reset or differ across visits.



This model assumes separate covariance structures for each visit. The matrix is block diagonal, meaning correlations are modeled within each visit only, and there's no correlation across visits






Code 2
  • Subject = USUBJID: This treats each subject as the experimental unit, regardless of visit.
  • Repeated = avisitn*Timepoint: The repeated measures are now defined across both visit and timepoint combinations.
  • Implication: This structure models the correlation of all visit-timepoint combinations within each subject. It assumes a single covariance structure across all combinations of visit and timepoint.

This model assumes a unified covariance structure across all visit-timepoint combinations. It allows for correlations across both visits and timepoints.


 Conceptual Summary

FeatureCode 1Code 2
SubjectUSUBJID*AVISITNUSUBJID
Repeated MeasuresTimepoint within each visitVisit-Timepoint combinations
Covariance StructureSeparate per visitUnified across visits
Use CaseWhen visits are independent or have different dynamicsWhen modeling all timepoints and visits jointly

✅ Which to Use?

  • Use Code 1 if you believe the correlation structure differs across visits (e.g., different treatment phases or conditions).
  • Use Code 2 if you want to model a single covariance structure across all visit-timepoint combinations within each subject.


Comments

Popular posts from this blog

Analysis of Repeated Measures Data using SAS (1)

Medical information for Melanoma, Merkel cell carcinoma and tumor mutation burden

Four essential statistical functions for simulation in SAS