Abstract
SAS® is commonly used for bioequivalence (BE) data analysis. R is a free and open software for general purpose data analysis, and is less frequently used than SAS® for BE data analysis. This tutorial explains how R can be used for BE data analysis to generate comparable results with SAS®. The main SAS® procedures for BE data analysis are PROC GLM and PROC MIXED, and the corresponding R main packages are “sasLM” and “nlme” respectively. For fixed effects only or balanced data, the SAS® PROC GLM and R “sasLM” provide good estimates; however, for a mixed-effects model with unbalanced data, the SAS® PROC MIXED and R “nlme” are better for providing estimates without bias. The SAS® and R scripts are provided for convenience.
Keywords: SAS®, GLM, MIXED, sasLM, nlme
INTRODUCTION
The SAS® PROC GLM has been used for more than 40 years since 1976, and the SAS® PROC MIXED is a relatively new procedure that has been available since 1992 [1]. The PROC GLM treats all effects as fixed effects for the calculation, while the PROC MIXED is devised to correctly calculate the mixed-effects model including random effects [1]. Because the fixed and random effects are both commonly used in bioequivalence (BE) studies, the MIXED procedure provides a better linear unbiased estimator of the random effects than the GLM for BE analysis [2].
The issue of whether an effect is fixed or random has been discussed in BE studies [2]. Factors that have shown several unique values in experiments or have been chosen intentionally by the investigators are called fixed factors. In BE studies, the period and treatment are typically fixed effects because BE studies are exclusively focused on mean differences and most importantly, the treatment levels resulting from deliberate choice and not from sampling a distribution [3]. On the other hand, many studies use random factors whose levels represent a broader population. For example, the subject is considered as a random factor because it was selected to represent a sample of a population with a probability distribution. Level means and differences for fixed factors can be estimated and tested whereas those for random factors should not be estimated nor tested; only the size of variability (i.e., degree of spread) should be estimated [2].
The detailed explanation and comparison of the GLM and MIXED analyses in the “SAS® for linear models, 4th ed” [3] are summarized in Table 1.
Table 1. Comparison of the GLM and MIXED methods in Littell et al. [3].
| Description | PROC GLM or “sasLM” | PROC MIXED or “nlme” |
|---|---|---|
| Estimation | LS method. | ML or REML. |
| Fixed only vs. mixed | All (fixed or random) effects are initially considered as fixed effects. | Variance of random effects is estimated simultaneously with fixed effects. |
| Variance of random effects is calculated with the estimates of the above. | ||
| Biasedness | In case of mixed-effects model with unbalanced data, bias is introduced. This is good only for all fixed effects or mixed model with balanced data. | This gives unbiased estimation with REML, less biased estimation with ML than GLM. |
LS, least square; ML, maximum likelihood; REML, restricted maximum likelihood.
Despite the clear statement in many references that “models that have both fixed and random effects should be analyzed using the PROC MIXED” [1,2,3,4], the procedure of GLM rather than MIXED has been mostly used in crossover BE studies (2 × 2) because the two methods produce comparable results when using balanced data [3]. Since the PROC GLM requires balanced data, subjects in a crossover trial who do not provide evaluable data for both the test and reference products (e.g., dropout) should not be included when performing the statistical analysis with the PROC GLM [5]. On the other hand, the PROC MIXED allows the existence of data that are missing at random, there is no need to exclude subjects with missing data [2].
Before the R “sasLM” package became available, it was not feasible to generate the same results as the SAS® PROC GLM in R [6]. The “Anova” function in the “car” package or “drop1” function does not work for BE data that use nested crossover design. However, it is recommended to use the SAS® PROC MIXED or R “nlme” for the significance tests and confidence intervals (CIs).
This tutorial illustrates the comparison between the two procedures (PROC MIXED and PROC GLM) using an example of a simulated dataset for analyzing BE data, and introduces R packages that generated the same results that can be obtained in SAS®. Graphical analysis and sample size determination will be handled in separate tutorials.
METHODS
For the assessment of average BE between formulations in average bioavailability, the usual procedure is as follows:
1) Use log-transformed values for both the areas under the plasma concentration‐time curve from 0 to the last measurable concentration (AUClast) and the peak concentrations (Cmax).
2) Perform ANOVA (e.g., PROC GLM from SAS®) to test the effect of group (or sequence), subject, period, and formulation (or treatment).
3) After the above-mentioned assessment, obtain 90% CIs using the mean squared error of ANOVA, which should be in the range of log(0.80) to log(1.25).
Therefore, the following process of BE analysis is proposed:
1) Use log-transformed values for both AUClast and Cmax. Data from dropout subjects can be used if non-compartmental analysis can be performed from one or more periods.
2) Test the effects of group (or sequence), subject, period, and formulation (or treatment) using the mixed-effects model (e.g., PROC MIXED of SAS® or nlme::lme of R). This test is used for the consideration of the study and not for its invalidation or judgement.
3) After the above test, determine 90% CIs using the estimate for intrasubject variance, which should be in the range of log(0.80) to log(1.25).
Software
SAS® 9.4 and R 4.0.3 were used for the script and results.
Statistical tools for BE analysis
To demonstrate the differences between mixed-effects models through the restricted maximum likelihood estimation versus fixed-effects models, tools originally intended for linear mixed-effects models (SAS® PROC MIXED, “nlme” in R) were compared with those originally intended for fixed-effects models (SAS® GLM, “sasLM” in R). A simulated and unbalanced dataset was used as an example for the BE assessment.
Example dataset
An example dataset is shown in Fig. 1.
Figure 1. An example dataset saved as “BEsim.csv.”.
Note that Subjects 3 and 6 dropped out after period 1 and that their data for period 2 are missing. Subjects with missing observations, such as dropouts should be ignored when using GLM procedure. However, in this example, BE analysis was demonstrated without excluding dropouts to compare the results with the same data. Only Cmax data are used for demonstration, and AUC data are omitted. If AUC data are available, the relevant AUC column can be added, and the script should be adjusted accordingly.
SAS script
The SAS script of data preparation and check is shown in Fig. 2, and those for PROC GLM and PROC MIXED analyses for 2 × 2 BE data are shown in Figs. 3 and 4, respectively. For the above analysis, the PROC GLM calculates group (or sequence), subject, period, and formulation (or treatment) as fixed effects, and then considers the subject effect as a random effect after the calculation.
Figure 2. SAS script for data preparation and check.
Figure 3. SAS script using PROC GLM.
Figure 4. SAS script using PROC MIXED.
R script
The R script for data preparation is shown in Fig. 5, and the scripts equivalent to the SAS PROC GLM and PROC MIXED analyses for 2 × 2 BE data are shown in Figs. 6 and 7, respectively. The “nlme” in R and PROC MIXED considers the subject effect as a random effect from the beginning of the calculation. In addition, the “nlme” and PROC MIXED can test the effects of group, period, and formulation by F-test or t-test, which is the primary objective of the ANOVA.
Figure 5. R script for data preparation.
Figure 6. R script equivalent to SAS PROC GLM.
ANOVA, analysis of variance; CI, confidence interval; GMR, geometric mean ratio.
Figure 7. R script equivalent to SAS PROC MIXED.
CI, confidence interval; GMR, geometric mean ratio.
The “af” function in the “sasLM” package changes the type of some columns to the factor type. The “af” should be regarded as the abbreviation of “as factor.” Note that the difference and CI are estimated in log scales and are reversed using the “exp” function.
One thing to be cautious about is that the subject ID (Subject) should be different for each group. If some of the subject IDs are the same between groups, the random argument of the second line should be changed as follows:
Result = lme(log(Cmax) ~ Group + Period + Treatment, random=~1|Group/Subject, data=BEdata)
The above statement can be used for various crossover designs such as 2 × 4, 6 × 3, and 3 × 3.
RESULTS
The estimate and LSMeans of the GLM and MIXED analyses generate the estimates and the corresponding standard errors of the method means. The “nlme” package of the R software reproduced the same results as “SAS® PROC MIXED” (point estimates 0.8668, 90% CI 0.5565–1.3501 of geometric mean ratio, Table 2). Also, considering that the results of the “sasLM” package were the same as those produced in SAS® PROC GLM (point estimates 0.8708, 90% CI 0.5515–1.3748 of geometric mean ratio, Table 3), the “sasLM” package could be a viable alternative method for calculating the type III sum of squares [6].
Table 2. Summary of the SAS and R script results (SAS® PROC MIXED vs. R “nlme”).
| Description | SAS® PROC MIXED | R “nlme” | |||||||
|---|---|---|---|---|---|---|---|---|---|
| Random effect | |||||||||
| Subject (group) | 0.3368 | 0.33682883 | |||||||
| Residual | 0.04701 | 0.04699731 | |||||||
| Fixed effect | |||||||||
| Source | Numerator Df | Denominator Df | F value | p-value | Numerator Df | Denominator Df | (t value)2 | p-value | |
| Group | 1 | 4 | 0.34 | 0.5903 | 1 | 4 | 0.3414819 | 0.5903456 | |
| Period | 1 | 2 | 1.06 | 0.4115 | 1 | 2 | 1.0594267 | 0.4115420 | |
| Treatment | 1 | 2 | 0.89 | 0.4458 | 1 | 2 | 0.8867064 | 0.4457718 | |
| Geometric mean ratio | |||||||||
| Point estimate | 0.86685 | 0.8668540 | |||||||
| 90% CI | 0.55657–1.35012 | 0.5565718–1.3501148 | |||||||
CI, confidence interval.
Table 3. Summary of the SAS and R script results (SAS® PROC GLM vs. R “sasLM”).
| Description | SAS® PROC GLM | R “sasLM” | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| ANOVA | |||||||||||
| Source | Df | Type III SS | Mean square | F value | p-value | Df | Type III SS | Mean square | F value | p-value | |
| Group | 1 | 0.163819 | 0.163819 | 0.28 | 0.6236 | 1 | 0.16382 | 0.16382 | 0.2811 | 0.6236 | |
| Subject (group) | 4 | 2.597930 | 0.649482 | 13.28 | 0.0713 | 4 | 2.59793 | 0.64948 | 13.2759 | 0.07127 | |
| Period | 1 | 0.038548 | 0.038548 | 0.79 | 0.4684 | 1 | 0.03855 | 0.03855 | 0.7879 | 0.46837 | |
| Treatment | 1 | 0.038269 | 0.038269 | 0.78 | 0.4698 | 1 | 0.03827 | 0.03827 | 0.7823 | 0.46976 | |
| Residual | 2 | 0.097844 | 0.048922 | - | - | 2 | 0.09784 | 0.04892 | - | - | |
| Geometric mean ratio | |||||||||||
| Point estimate | 0.87081 | 0.8708130 | |||||||||
| 90% CI | 0.55156–1.37486 | 0.5515549–1.3748684 | |||||||||
ANOVA, analysis of variance; CI, confidence interval.
By comparing the GLM and MIXED analyses of a BE crossover study with fixed and random effects, the results showed that GLM and MIXED methods produced different F values, mean, and mean differences because the example dataset was unbalanced. The MIXED method (“nlme” in R software) is recommended over the GLM method for analyzing crossover BE studies to appropriately estimate the random between-subject effects and their variance.
ACKNOWLEDGEMENTS
We thank Dr. Joon Seo Lim from the Scientific Publications Team at Asan Medical Center for his editorial assistance in preparing this manuscript.
Footnotes
Reviewer: This article was invited.
Conflict of Interest: - Authors: Nothing to declare
- Editors: Nothing to declare
- Conceptualization: Bae KS.
- Formal analysis: Bae KS.
- Validation: Bae KS.
- Writing - original draft: Park G, Kim H.
- Writing - review & editing: Park G, Kim H, Bae KS.
References
- 1.Littell RC. The evolution of linear models in SAS: a personal perspective. SAS Global Forum 2011. [Accessed October 14, 2020]. http://support.sas.com/resources/papers/proceedings11/325-2011.pdf.
- 2.Bae KS, Kang SH. Bioequivalence data analysis for the case of separate hospitalization. Transl Clin Pharmacol. 2017;25:93–100. doi: 10.12793/tcp.2017.25.2.93. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 3.Littell R, Stroup WW, Freund R. SAS® for linear models. 4th ed. Hoboken (NJ): Wiley; 2002. [Google Scholar]
- 4.Park SH. Design of experiments. 2nd ed. Seoul: Min-Young Sa; 2003. pp. 58–60.pp. 107–109.pp. 146–148. [Google Scholar]
- 5.EMA. Questions & answers: positions on specific questions addressed to the Pharmacokinetics Working Party (PKWP) [Accessed October 14, 2020]. https://www.ema.europa.eu/en/documents/scientific-guideline/questions-answers-positions-specific-questions-addressed-pharmacokinetics-working-party_en.pdf.
- 6.Sunwoo J, Kim H, Choi D, Bae KS. Validation of “sasLM,” an R package for linear models with type III sum of squares. Transl Clin Pharmacol. 2020;28:83–91. doi: 10.12793/tcp.2020.28.e9. [DOI] [PMC free article] [PubMed] [Google Scholar]







