Estimating medication adherence (MPR and PDC) using AdhereR - Part 1

Mark Bounthavong

30 March 2025

Introduction

Medication adherence is a measure of the meditation usage by a patient. Taking the medication as instructed is an assumption many researchers make when performing evaluations involving a medication’s effectiveness. In randomized controlled studies, medication adherence is closely monitored to prevent any bias that might impact or distort a medication’s efficacy. In retrospective studies using electronic health records or pharmacy claims databases, researchers do not have the luxury of closely monitoring adherence. Rather, they must make due with the real world data at hand, which can potentially impact the findings, particularly ones that involve the effectiveness of medications.

To insure that a patient adheres to the instructions of a medication is a challenging prospect. Researchers (and clinicians who prescribe the medications) are unable to fully observe a patient following the instructions of their prescription after they receive it from the pharmacy. Hence, researchers are left with proxy measurements of adherence such as the Medication Possession Ratio (MPR), Proportion of Days Covered (PDC), and self-response surveys by patients.

In this tutorial, we’ll review how to estimate the MPR and PDC for a single medication on a patient’s profile.

Medication adherence with pharmacy claims data

Medication adherence is often measured using pharmacy claims data or the electronic health records (EHR). In this tutorial, we’ll use the AdhereR package, which contains the med.events data. We’ll use this data to estimate the MPR and PDC of a single medication on a patient’s profile.

Medication adherence using the MPR and PDC is presented as a proportion. So, an MPR or PDC of 100% denotes that the individual is 100% adherent to the medication instructions If the MPR or PDC is 0%, then the individual is 0% adherent to the medication instructions.

Therefore, the range for the medication should be between 0% and 100%. However, with the MPR, the range can exceed 100% due to the limitations of the calculations (we will review how this is possible). The PDC caps the medication adherence ceiling to 100%.

Motivating example

The AdhereR package has a built-in data that we will use to estimate the Medication Possession Ratio (MPR) and the Proportion of Days Covered (PDF).

We can load the med.events by loading the AdhereR library in R:

### Load library:
# install.packages("AdhereR")   ## Install package
library("AdhereR")              ## On installed, load AdhereR package

### Inspect the data:
str(med.events)
## 'data.frame':    1080 obs. of  5 variables:
##  $ PATIENT_ID: int  1 1 1 1 1 1 1 1 1 1 ...
##  $ DATE      : chr  "04/26/2033" "07/04/2033" "08/03/2033" "08/17/2033" ...
##  $ PERDAY    : int  4 4 4 4 4 4 4 4 4 4 ...
##  $ CATEGORY  : chr  "medA" "medB" "medB" "medB" ...
##  $ DURATION  : int  50 30 30 30 30 30 30 30 30 30 ...
head(med.events)
##     PATIENT_ID       DATE PERDAY CATEGORY DURATION
## 286          1 04/26/2033      4     medA       50
## 287          1 07/04/2033      4     medB       30
## 288          1 08/03/2033      4     medB       30
## 289          1 08/17/2033      4     medB       30
## 291          1 10/13/2033      4     medB       30
## 290          1 10/16/2033      4     medB       30

The med.events data contains several variables that will be essential to estimating the MPR and PDC.

  • PATIENT_ID: Unique patient identifier

  • DATE: Date when the prescription is filled (also know as an “episode” event)

  • PERDAY: Frequency of medication intake

  • CATEGORY: Medication category (medA and medB)

  • DURATION: Total day supply of the prescription

The med.events data is in the long format:

First couple of individuals from the `med.events` data.

First couple of individuals from the med.events data.

Once you have gotten familiar with the med.events data, let’s review how the use these to estimate the MPR and PDC.

MPR and PDC calculations for CMA1 and CMA3 scenarios

A review of the literature will yield various methods to estimate the MPR and PDC. I tend to use Hess, et al. and Vollmer, et al.’s papers to focus on a few of these methods.

According to these resources, the MPR and PDC are estimated based on the following formulas (based on Vollmer, et al.):

Formulas to estimate the MPR and PDC.

Formulas to estimate the MPR and PDC.

There are a lot to absorb with this table. Don’t worry. I’ll walk you through these.

We’re going to focus on CMA1 and CMA3. CMA means “continuous multiple-interval measures of medication availability.” Basically, it attempts to measure medication adherence using the number of covered days by the number of day supply.

CMA1 focuses on the number of covered days divided the the number of day supply.

CMA3 uses the same equation, but caps the overall results at 1.0 or 100% medication adherence.

Let’s focus on the CMA1 adherence formula:

\[\begin{aligned} MPR = \frac{\text{Number of days dispensed}}{\text{|Date of first fill - Date of last fill|}} \end{aligned}\]

The numerator is the total day supplied, which can be estimated by summing all the intended day supply of the medication in the observation window (except the last fill). The denominator is the difference in days between date of first fill in the observation window and the date of last fill in the observation window.

Here is a diagram to illustrate how this formula is used for the CMA1 and CMA3 scenarios for a single individual:

Medication adherence for a single patient with 4 fills using the last date of fill within the OW.

Medication adherence for a single patient with 4 fills using the last date of fill within the OW.

We need to identify the observation window. This is determined by the investigators. In this example, we start the observation window (OW) at 30 December 2020 and end the OW at 26 April 2020. Note: We are not interested in prescription fills outside the OW.

Next, we sum up the total days supplied excluding the last fill in the observation window. This will sum up the total days supplied as 90 days. This will be numerator in our MPR calculation.

For the denominator, we need to estimate the absolute difference in the days between the Date of the first fill in the OW and the Date of the last fill in the OW. The Date of the first fill in the OW is 01 January 2020. The Date of last fill is for the prescription that is filled in the OW, but its day supply is not included in the denominator. This will be 25 March 2020. The absolute difference is 84 days.

The MPR can now be calculated for the CMA1 scenario:

\[\begin{aligned} MPR = \frac{\text{90 days}}{\text{84 days}} = 1.07 \end{aligned}\]

In this example, the MPR is 1.07, which is greater than 1.0. This means that the subject is overly adherent to their medication regimen. The MPR > 1.00 is a problem because an individual can’t be overly adherent. The maximum theoretical MPR value should be 1.00. So what’s going on?

One of the limitations of the MPR involves the potential to generate values that are beyond the reasonable range. This can occur when an individual refills their medications early. In this example, we can visualize when the hypothetical individual refilled their medication 15 days early on 19 February 2020.

This potential problem is the reason why we have the Proportion of Days Covered (PDC) as an alternative to the MPR for medication adherence.

The CMA3 scenario estimates the PDC using the same formula but caps the MPR at 1.00.

MPR and PDC calculations for CMA2 and CMA4 scenarios

The CMA2 and CMA4 scenarios uses similar equation to estimate the MPR and PDC with the CMA1 and CMA3 scenarios, respectively, except for one difference. The denominator doesn’t use the Date of the last fill. Instead, it uses the Date of the end of the observation window (OW).

\[\begin{aligned} MPR = \frac{\text{Number of days dispensed}}{\text{|Date of first fill - Last date of the OW|}} \end{aligned}\]

Here is a diagram to illustrate how this formula is used for the CMA2 and CMA4 scenarios:

Medication adherence for a single patient with 4 fills using the end of the OW date.

Medication adherence for a single patient with 4 fills using the end of the OW date.

In the example, the last date of the OW is 26 April 2020. Using this date, we estimate the absolute difference between the Date of first fill and the Last date of the OW as 116 days.

\[\begin{aligned} MPR = \frac{\text{90 days}}{\text{116 days}} = 0.78 \end{aligned}\]

The MPR is 0.78 using the CMA2 scenario.

The PDC should be exactly the same as the CMA2 estimates since the MPR is not greater than 1.0.

Excel spreadsheet exercise

The above examples were recreated using an Excel spreadsheet that you can download here

Excel spreadsheet estimating the adherence measures for CMA1, CMA2, CMA3, and CMA4.

Excel spreadsheet estimating the adherence measures for CMA1, CMA2, CMA3, and CMA4.

Applying the AdhereR package

In the AdhereR package, there is an example data called med.events that we will use to illustrate how to estimate the mean, median, and standard deviation of the MPR and PDC a sample.

AdhereR has a very nice tutorial available from the developers at their CRAN Project site link, which I highly recommend reviewing. I took a lot of inspiration from their work to develop this tutorial.

The AdhereR package has a function for every one of the CMA scenarios that Vollmer, et al identified in their paper. These are written as CMA1, CMA2, CMA3, CMA4, CMA5, CMA6, CMA7, and CMA8.

These functions are largely used in the same way with few exceptions. In this tutorial, we’ll only go over CMA1, CMA2, CMA3, and CMA4 since they represent the most common types of adherence measures in the literature.

The CMA3 and CMA4 scenarios use the same coding parameters as CMA1 and CMA2 scenarios except that the PDC puts a ceiling on the adherence ratio at 1.0.

In the example, I will use the same parameters as the original authors. The observation window will start 182 days after the individual is first entered into the study (Note: each individual in the data can enter the study at different times, so we re-center their entry time at 0 days). The end of the observation window will be 365 days afterwards.

There are several parameters that are important:

  • ID.colname: Denotes the unique individual identifier

  • event.date.colname: The date of fill variable

  • event.duration.colname: Total day supply of the prescription

  • followup.window.start: This is set at 0 since that is when the subjects is entered into the study

  • observation.window.start: This sets the beginning of the observation window relative to the followup.window.start

  • observation.window.duration: This sets the end fo the observation window relative to the observation.window.start

  • date.format: Denotes the date format, which is using “MM/DD/YYYY”

AdhereR allows us to plot the medication refill patterns for an individual in the data. Here is a visual medication fill pattern for a random individual in the med.events data (subject = 55). The observation window start is defined as 182 days after entry, and the end of the observation window is defined as 385 days after the start of the observation window:

################
## CMA0 - PLOT
################
#### Plot only subject 55

### Create data with subject 55
single_subject355 <- med.events[med.events$PATIENT_ID %in% c(55), ]

### Set up the CMA0 to plot
cma0_55 <- CMA0(data = single_subject355,
             ID.colname = "PATIENT_ID",
             event.date.colname = "DATE",
             event.duration.colname = "DURATION",
             followup.window.start = 0, 
             observation.window.start = 182, 
             observation.window.duration = 365,
             date.format = "%m/%d/%Y")

# Plot the medication fills only
plot(cma0_55)

CMA1 - MPR

For the CMA1 function, we invoke it using the follow code chunk (This the MPR in the CMA1 scenario):

################
## CMA1
################
# MPR - CMA1 scenario
# Create an object called cma1:
cma1 <- CMA1(data = med.events,
             ID.colname = "PATIENT_ID",
             event.date.colname = "DATE",
             event.duration.colname = "DURATION",
             followup.window.start = 0, 
             observation.window.start = 182, 
             observation.window.duration = 365,
             date.format = "%m/%d/%Y")

However, we need to convert this into a dataframe for us to analyze.

cma1.dataframe <- data.frame(cma1$CMA)

Once we have this in a dataframe, we can run some descriptive statistics.

library("psych") ## We need the psych package to use the describeBy function

describeBy(cma1.dataframe$CMA)
##    vars  n mean   sd median trimmed mad min max range skew kurtosis   se
## X1    1 96 0.89 0.72   0.83    0.79 0.5 0.1   6   5.9 4.03    24.69 0.07

In the med.events data, there were 100 subjects; however, some of them had missing data, which only yielded MPR estimates for 96 individuals. In the CMA1 scenario, the mean MPR was 0.89 with a standard deviation of 0.72. Additionally, the median MPR was 0.83 with a min and max of 0.1 and 6.0.

CMA2 - MPR

Let’s try this using the CMA2 function, which estimates the MPR using the end of the OW instead of the Date of the last fill.

################
## CMA2
################
# MPR - CMA2 scenario
# Create an object called cma2:
cma2 <- CMA2(data = med.events, # 
             ID.colname = "PATIENT_ID",
             event.date.colname  ="DATE",
             event.duration.colname = "DURATION",
             followup.window.start = 0, 
             observation.window.start = 182, 
             observation.window.duration = 365,
             date.format = "%m/%d/%Y")

cma2.dataframe <- data.frame(cma2$CMA)
describeBy(cma2.dataframe$CMA)
##    vars  n mean   sd median trimmed  mad  min  max range skew kurtosis   se
## X1    1 99 0.81 0.43   0.75    0.77 0.45 0.19 2.66  2.47 1.04     1.85 0.04

In the CMA2 scenario, the mean MPR was 0.81 with a standard deviation of 0.43. Additionally, the median MPR was 0.75 with a min and max of 0.19 and 2.66.

CMA3 - PDC

The code chunk for the CMA3 is below:

################
## CMA3
################
# PDC - CMA3 scenario
# Create an object called cma2:
cma3 <- CMA3(data = med.events, # 
             ID.colname = "PATIENT_ID",
             event.date.colname  ="DATE",
             event.duration.colname = "DURATION",
             followup.window.start = 0, 
             observation.window.start = 182, 
             observation.window.duration = 365,
             date.format = "%m/%d/%Y")

cma3.dataframe <- data.frame(cma3$CMA)
describeBy(cma3.dataframe$CMA)
##    vars  n mean   sd median trimmed  mad min max range  skew kurtosis   se
## X1    1 96 0.71 0.28   0.83    0.73 0.26 0.1   1   0.9 -0.41    -1.31 0.03

CMA4 - PDC

The code chunk for the CMA3 is below:

################
## CMA4
################
# PDC - CMA4 scenario
# Create an object called cma2:
cma4 <- CMA4(data = med.events, # 
             ID.colname = "PATIENT_ID",
             event.date.colname  ="DATE",
             event.duration.colname = "DURATION",
             followup.window.start = 0, 
             observation.window.start = 182, 
             observation.window.duration = 365,
             date.format = "%m/%d/%Y")

cma4.dataframe <- data.frame(cma4$CMA)
describeBy(cma4.dataframe$CMA)
##    vars  n mean   sd median trimmed  mad  min max range  skew kurtosis   se
## X1    1 99 0.71 0.27   0.75    0.73 0.36 0.19   1  0.81 -0.31    -1.46 0.03

Comparison of methods

The following table provides a comparison of the various methods.

Comparison of medication adherence methods.

Comparison of medication adherence methods.

The PDC calculations are lower than the MPR calculations because of the restriction on the adherence ratio maximum value at 1.0. This greatly lowers the adherence level of the sample when compared to the MPR calculations.

Conclusions

The comparison of medication adherence methods introduced in this tutorial illustrates the importance of establishing rules for estimating medication adherence. Deciding which of these medication adherence measures to use will depend on the study, stakeholders’ needs, and the investigators’ objectives. Vollmer, et al wrote that the CMA1 and CMA3 scenarios would lead to an upward bias since the Date of the last fill was used instead of the Last date of the observation window and that MPR values > 1.0 can skew the average adherence ratio. Hence, it may be preferable to use the PDC with the Last date of the observation window (CMA4 scenario) to reduce potential bias. However, this decision will ultimately need to be justified when conducting your own study.

In continuing with the medication adherence theme, we’ll explore other assumptions regarding these calculations in a future tutorial.

References

Dima AL, Dediu D. Computation of adherence to medication and visualization of medication histories in R with AdhereR: Towards transparent and reproducible use of electronic healthcare data. PLoS One. 2017 Apr 26;12(4):e0174426. doi: 10.1371/journal.pone.0174426. PMID: 28445530; PMCID: PMC5405929.

Vollmer WM, Xu M, Feldstein A, Smith D, Waterbury A, Rand C. Comparison of pharmacy-based measures of medication adherence. BMC Health Serv Res. 2012 Jun 12;12:155. doi: 10.1186/1472-6963-12-155. PMID: 22691240; PMCID: PMC3413584.

Hess LM, Raebel MA, Conner DA, Malone DC. Measurement of adherence in pharmacy administrative databases: a proposal for standard definitions and preferred measures. Ann Pharmacother. 2006 Jul-Aug;40(7-8):1280-88. doi: 10.1345/aph.1H018. PMID: 16868217.

Acknowledgements

Alexandra L. Dima, Dan Dediu & Samuel Allemann created a fantastic tutorial on using the AdhereR package for a variety of adherence estimations link. I thought this was an amazing tutorial that goes through all CMA versions that Vollmer identifies, but they also go beyond these CMA versions and include other types of adherence measures in their tutorial. I highly recommend reading through their tutorial to get a comprehensize understanding of the AdhereR package and its features. Their GitHub site is located here.

Disclaimers

This is a work in progress. Thus, the content will be subject to changes and updates.

This is for educational purposes only.