# Bioequivalence and Crossover Analysis with sasLM

#### Kyun-Seop Bae

## The standard 2x2 crossover analysis

Average bioequivalence with a 2x2 crossover design is conventionally analyzed with SAS PROC GLM:

    PROC GLM DATA=be;
      CLASS SEQ SUBJ PRD TRT;
      MODEL LNCMAX = SEQ SUBJ(SEQ) PRD TRT;
      RANDOM SUBJ(SEQ) / TEST;
      LSMEANS TRT / CL ALPHA=0.1;
      ESTIMATE 'T - R' TRT -1 1 / CL ALPHA=0.1;
    RUN;

The package ships `BEdata`, real data from a 2x2 bioequivalence study with three hospitalization groups. The same analysis with `sasLM`:

    BEdata = af(BEdata, c("ADM", "SEQ", "PRD", "TRT", "SUBJ")) # columns as factors
    formula1 = log(CMAX) ~ SEQ/SUBJ + PRD + TRT
    GLM(formula1, BEdata)

    $ANOVA
    Response : log(CMAX)
                    Df  Sum Sq Mean Sq F value    Pr(>F)
    MODEL           48 23.1924 0.48317  5.6278 4.395e-08 ***
    RESIDUALS       42  3.6059 0.08585
    CORRECTED TOTAL 90 26.7983
    ---
    Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

    $Fitness
      Root MSE log(CMAX) Mean Coef Var  R-square  Adj R-sq
     0.2930098       6.071036 4.826355 0.8654428 0.7116631

    $`Type I`
             Df  Sum Sq Mean Sq F value    Pr(>F)
    SEQ       1  0.6454 0.64544  7.5178  0.008938 **
    SEQ:SUBJ 45 22.4395 0.49866  5.8081 3.359e-08 ***
    PRD       1  0.0969 0.09686  1.1281  0.294242
    TRT       1  0.0106 0.01057  0.1231  0.727410
    ---
    Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

    $`Type II`
             Df  Sum Sq Mean Sq F value    Pr(>F)
    SEQ       1  0.6440 0.64395  7.5005  0.009011 **
    SEQ:SUBJ 45 22.5232 0.50052  5.8298 3.173e-08 ***
    PRD       1  0.0996 0.09958  1.1599  0.287632
    TRT       1  0.0106 0.01057  0.1231  0.727410
    ---
    Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

    $`Type III`
             Df  Sum Sq Mean Sq F value    Pr(>F)
    SEQ       1  0.3368 0.33679  3.9228   0.05421 .
    SEQ:SUBJ 45 22.5232 0.50052  5.8298 3.173e-08 ***
    PRD       1  0.0996 0.09958  1.1599   0.28763
    TRT       1  0.0106 0.01057  0.1231   0.72741
    ---
    Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

`SEQ/SUBJ` denotes subjects nested within sequence, equivalent to `SEQ SUBJ(SEQ)` of SAS. The Type I, II, and III tables above match SAS PROC GLM for this unbalanced data set (91 subjects).

## Testing SEQ against the correct error term

The sequence effect must be tested against the subject-within-sequence mean square, not the residual. This is what the RANDOM / TEST statement of SAS does:

    RanTest(formula1, BEdata, Random="SUBJ")

    $SEQ
    Error: 0.9669*SEQ:SUBJ + 0.0331*MSE
              Df  Sum Sq Mean Sq F value Pr(>F)
    SEQ    1.000  0.3368 0.33679  0.6919 0.4099
    Error 45.529 22.1626 0.48679

    $`The Rest Terms`
              Df  Sum Sq Mean Sq F value    Pr(>F)
    PRD        1  0.0996 0.09958  1.1599    0.2876
    TRT        1  0.0106 0.01057  0.1231    0.7274
    SEQ:SUBJ  45 22.5232 0.50052  5.8298 3.173e-08 ***
    RESIDUALS 42  3.6059 0.08585
    ---
    Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

    $EMS
             SEQ PRD TRT SEQ:SUBJ eps
    SEQ        Q           1.8693   1
    PRD            Q                1
    TRT                Q            1
    SEQ:SUBJ               1.9333   1

## The 90% confidence interval of the geometric mean ratio

The two-one-sided-tests (TOST) procedure at the 5% level is operationally the 90% confidence interval of T/R in the log scale:

    ci0 = CIest(formula1, BEdata, "TRT", c(-1, 1), conf.level=0.90)
    ci0

         Estimate  Lower CL Upper CL Std. Error t value Df Pr(>|t|)
    [1,] 0.021944 -0.083236  0.12712   0.062535  0.3509 42   0.7274

    exp(ci0[, c("Estimate", "Lower CL", "Upper CL")]) # GMR and its 90% CI

     Estimate  Lower CL  Upper CL
    1.0221866 0.9201339 1.1355579

The exponentiated estimate and confidence limits are the geometric mean ratio (GMR) and its 90% confidence interval. Bioequivalence is concluded when the interval is contained in [0.80, 1.25].

## Least squares means of treatments

    LSM(formula1, BEdata, "TRT", conf.level=0.90)

      Group   LSmean  LowerCL  UpperCL         SE Df
    T     A 6.060638 5.988736 6.132541 0.04274955 42
    R     A 6.038694 5.961929 6.115459 0.04564037 42

## Notes

- For unbalanced designs with missing periods, a mixed effects model (SAS PROC MIXED or the ‘nlme’ package) is generally preferred; see the example in `?sasLM` for the equivalent `nlme::lme` call.
- The author’s ‘BE’ package builds the complete bioequivalence workflow (including sample size and outlier diagnostics) on top of ‘sasLM’.