This analysis deals with exploring medication adherence from the hypothetical data set included in the AdhereR package in RStudio. The exploration of medication adherence begins with ensuring that both medication A (medA) and medication B (medB) were required to be taken by each patient. Once confirmed, we will narrow our focus onto two patients and dive into a general overview of the medication events per patient. We will analyze their adherence which will be represented as a percentage. The data represented in this analysis can be found on https://cran.r-project.org/web/packages/AdhereR/vignettes/AdhereR-overview.html as well as definitions to the terminology used within this analysis.
The data analysis will be broken down by the following sections:
Medication A and Medication B required for every patient?
Medication Adherence of Patient 11 and Patient 89
Medication Adherence Calculations
CMA Estimates per Medication Episode
CMA Estimates - Sliding Window
ggplot(data = data, mapping = aes(x = CATEGORY)) +
geom_bar(aes(fill = CATEGORY)) +
labs(x = "Medication Type",
y = "Count",
title = "Frequency of Medication Type",
caption = "Source: https://cran.r-project.org/web/packages/AdhereR") +
theme(plot.title = element_text(hjust = 0.5),
plot.subtitle = element_text(hjust = 0.5))
medication_count <- data %>%
group_by(CATEGORY) %>%
summarise(count = n())
knitr::kable(medication_count, caption = "Total Count for Medication A and Medication B")
| CATEGORY | count |
|---|---|
| medA | 549 |
| medB | 531 |
As plotted above, we can see that the frequency of patients who take Medication A (549 medication events) is relatively equal to those who take Medication B (531 medication events). Therefore, we can assume that either half of the patients take just medication A and the other half take medication B or that every patient takes both medication A and medication B.
The latter is proven to be true as shown below:
medicationA_taken <- data %>%
filter(CATEGORY == "medA")
unique(medicationA_taken$PATIENT_ID)
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
## [19] 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
## [37] 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
## [55] 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
## [73] 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
## [91] 91 92 93 94 95 96 97 98 99 100
medicationB_taken <- data %>%
filter(CATEGORY == "medB")
unique(medicationB_taken$PATIENT_ID)
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
## [19] 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
## [37] 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
## [55] 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
## [73] 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
## [91] 91 92 93 94 95 96 97 98 99 100
As shown above, every patient (1-100) has taken both medication throughout their entire Follow Up Window (start to finish of their duration).
Now that we have confirmed that every patient was taking medication A and medication B, we can analyze the medication adherence for patient 11 and patient 89 while taking both medications.
We will first filter our data to show the medication events for only patient 11 and patient 89:
patient.11.89 <- data %>%
filter(PATIENT_ID == "11" | PATIENT_ID == "89")
knitr::kable(patient.11.89, caption = "The Medication Events for Patient 11 and Patient 89")
| PATIENT_ID | DATE | PERDAY | CATEGORY | DURATION |
|---|---|---|---|---|
| 11 | 10/29/2035 | 8 | medA | 30 |
| 11 | 07/18/2036 | 8 | medA | 30 |
| 11 | 07/23/2036 | 8 | medA | 30 |
| 11 | 06/11/2037 | 8 | medA | 30 |
| 11 | 09/19/2037 | 4 | medB | 30 |
| 11 | 10/09/2037 | 4 | medB | 30 |
| 89 | 01/14/2034 | 4 | medA | 50 |
| 89 | 10/02/2034 | 4 | medA | 50 |
| 89 | 02/18/2035 | 4 | medA | 50 |
| 89 | 07/10/2035 | 4 | medB | 30 |
| 89 | 08/16/2035 | 4 | medB | 30 |
| 89 | 01/03/2036 | 4 | medB | 30 |
Below is the general overview/visualization of the above data:
cma0 <- CMA0(data = patient.11.89,
ID.colname = "PATIENT_ID",
event.date.colname = "DATE",
event.duration.colname = "DURATION",
event.daily.dose.colname = "PERDAY",
medication.class.colname = "CATEGORY",
followup.window.start = 0,
observation.window.start = 182, #Observation window starts roughly 6 months after the start of treatment
observation.window.duration = 365, # Observation window will be a year long from the start of the observation window as set in the above argument
date.format = "%m/%d/%Y")
plot(cma0,
print.dose = TRUE, plot.dose = TRUE,
align.all.patients = TRUE,
show.legend = FALSE)
The green dashed box shows the follow up window
The yellow-tan filled box between 180-540 days is the observation window (of 1 year)
The red arrow signifies the duration of medA and the number below it represents the daily dosage of medA.
The blue arrow signifies the duration of medB and the number below it represents the daily dosage of medB.
The X axis represents a 2 year follow up window
The Y axis represents the two patients (patient 89 and patient 11) and their medication history
We can see in patient 89 that they consistently finished their medication supply before obtaining their next supply. However, they had an interruption of over 100 days between the first and second supply of medA.
We can see in patient 11 that the patient would acquire new supply of medication before the previous supply was used as shown in the second and third supply of medA and the first and second supply of medB. We can also see that this patient had an interruption of more than 200 days between the first and second supply and an interruption of more than 250 days between the third and fourth supply of medA.
Now we will calculate the medication adherence for each patient within a specified observation window.
The medication adherence is calculated by taking the total prescribed duration of a medication episode divided by the total duration of the observation window times 100.
If there are large gaps between the prescribed medication end date and the date of resupply, the adherence percentage will decrease.
cma6 <- CMA6(data=patient.11.89, # we're estimating CMA6 now!
ID.colname="PATIENT_ID",
event.date.colname="DATE",
event.duration.colname="DURATION",
event.daily.dose.colname="PERDAY",
medication.class.colname="CATEGORY",
carry.only.for.same.medication=FALSE, # Carry over should always happen irrespective of what medication is supplied
consider.dosage.change=FALSE,
followup.window.start=0, observation.window.start=250,
observation.window.duration=365,
date.format="%m/%d/%Y");
plot(cma6,patients.to.plot=c("11"), show.legend=FALSE) #23.9% Adherence
plot(cma6,patients.to.plot=c("89"), show.legend=FALSE) #45.2% Adherence
getCMA(cma6)
## PATIENT_ID CMA
## 1 11 0.2386364
## 2 89 0.4519774
Based on the CMA6 taking to account for the first and last medical event, the medical adherence for patient 11 is 23.9% and for patient 89 is 45.2%. The reason for the low percentage of adherence is due to the large gaps between each medication event as stated above.
Within the package there are 9 simple CMAs that we can use to estimate the adherence within an observation window. Below are the reasons we did not consider CMAs 1-5 and 7-9.
CMAs 1-4 were not considered due to major limitation of not taking timing of events to account
CMA5 ignores the last event of the observation window as does CMA1
CMA7 accounts for the gap between start of observation window (OW) and first medication event. However, our OW does not have that issue. It is predicted that both CMAs should result in similar adherence score.
CMA8 is used for involving ongoing treatment. Our plot does not have that scenario.
CMA9 is for longitudinal studies which ours is not.
Therefore, CMA6 is the best choice for our adherence check.
Instead of calculating an estimate for adherence within a specified observation window.
We can calculate the CMA estimation of adherence for each medication episode specified by either a gap larger than 6 months or a change in medication (this will indicate a new medication episode).
cmaE <- CMA_per_episode(CMA="CMA6", # apply the simple CMA7 to each treatment episode
data=patient.11.89,
ID.colname="PATIENT_ID",
event.date.colname="DATE",
event.duration.colname="DURATION",
event.daily.dose.colname="PERDAY",
medication.class.colname="CATEGORY",
carryover.within.obs.window = TRUE,
carry.only.for.same.medication = FALSE,
consider.dosage.change = FALSE, # conditions on treatment episodes
medication.change.means.new.treatment.episode = TRUE,
maximum.permissible.gap = 180,
maximum.permissible.gap.unit = "days",
followup.window.start=0,
followup.window.start.unit = "days",
followup.window.duration = 365 * 2,
followup.window.duration.unit = "days",
observation.window.start=0,
observation.window.start.unit = "days",
observation.window.duration=365*2,
observation.window.duration.unit = "days",
date.format="%m/%d/%Y",
parallel.backend="none",
parallel.threads=1)
cmaE$CMA #To get summary results for each patient
## PATIENT_ID episode.ID episode.start end.episode.gap.days episode.duration
## 1 11 1 2035-10-29 233 30
## 2 11 2 2036-07-18 268 60
## 3 11 3 2037-06-11 70 30
## 4 11 4 2037-09-19 0 39
## 5 89 1 2034-01-14 211 50
## 6 89 2 2034-10-02 92 189
## 7 89 3 2035-07-10 0 188
## episode.end CMA
## 1 2035-11-28 1.0000000
## 2 2036-09-16 1.0000000
## 3 2037-07-11 1.0000000
## 4 2037-10-28 1.0000000
## 5 2034-03-05 1.0000000
## 6 2035-04-09 0.5291005
## 7 2036-01-14 0.3776596
plot(cmaE, patients.to.plot=c("11"), show.legend=FALSE) #all 100%
plot(cmaE, patients.to.plot=c("89"), show.legend=FALSE) #100, 53, 38
Since the permissible gap (determining when the next treatment episode is) is 6 months, each gap between each treatment is at least 6 months long or a transition between MedA to medB (or vice versa).
The reason why our permissible gap is 6 months is because of the following assumption: “minimum of 6 months needs to pass after the end of a medication supply (taken as prescribed) to be reasonably confident that the patient has discontinued treatment”
As shown above, each medication episode over the total duration of the follow up window was given an adherence score. There were 4 medication episodes in patient 11 and 3 medication episodes in patient 89.
cmaW <- CMA_sliding_window(CMA.to.apply="CMA6", # apply the simple CMA6 to each sliding window
data=patient.11.89,
ID.colname="PATIENT_ID",
event.date.colname="DATE",
event.duration.colname="DURATION",
event.daily.dose.colname="PERDAY",
medication.class.colname="CATEGORY",
carry.only.for.same.medication=FALSE,
consider.dosage.change=FALSE,
followup.window.start=0,
observation.window.start=0,
observation.window.duration=365*2,
sliding.window.start=0, # sliding windows definition
sliding.window.start.unit="days",
sliding.window.duration=120,
sliding.window.duration.unit="days",
sliding.window.step.duration=30, # Can change the stacking of the CMA estimations with this number!
sliding.window.step.unit="days",
date.format="%m/%d/%Y",
parallel.backend="none",
parallel.threads=1)
cmaW$CMA
## PATIENT_ID window.ID window.start window.end CMA
## 1 11 1 2035-10-29 2036-02-26 0.2500000
## 2 11 2 2035-11-28 2036-03-27 NA
## 3 11 3 2035-12-28 2036-04-26 NA
## 4 11 4 2036-01-27 2036-05-26 NA
## 5 11 5 2036-02-26 2036-06-25 NA
## 6 11 6 2036-03-27 2036-07-25 1.0000000
## 7 11 7 2036-04-26 2036-08-24 1.0000000
## 8 11 8 2036-05-26 2036-09-23 0.8955224
## 9 11 9 2036-06-25 2036-10-23 0.6185567
## 10 11 10 2036-07-25 2036-11-22 NA
## 11 11 11 2036-08-24 2036-12-22 NA
## 12 11 12 2036-09-23 2037-01-21 NA
## 13 11 13 2036-10-23 2037-02-20 NA
## 14 11 14 2036-11-22 2037-03-22 NA
## 15 11 15 2036-12-22 2037-04-21 NA
## 16 11 16 2037-01-21 2037-05-21 NA
## 17 11 17 2037-02-20 2037-06-20 1.0000000
## 18 11 18 2037-03-22 2037-07-20 0.7692308
## 19 11 19 2037-04-21 2037-08-19 0.4347826
## 20 11 20 2037-05-21 2037-09-18 0.3030303
## 21 11 21 2037-06-20 2037-10-18 1.0000000
## 22 89 1 2034-01-14 2034-05-14 0.4166667
## 23 89 2 2034-02-13 2034-06-13 NA
## 24 89 3 2034-03-15 2034-07-13 NA
## 25 89 4 2034-04-14 2034-08-12 NA
## 26 89 5 2034-05-14 2034-09-11 NA
## 27 89 6 2034-06-13 2034-10-11 1.0000000
## 28 89 7 2034-07-13 2034-11-10 1.0000000
## 29 89 8 2034-08-12 2034-12-10 0.7246377
## 30 89 9 2034-09-11 2035-01-09 0.5050505
## 31 89 10 2034-10-11 2035-02-08 NA
## 32 89 11 2034-11-10 2035-03-10 1.0000000
## 33 89 12 2034-12-10 2035-04-09 1.0000000
## 34 89 13 2035-01-09 2035-05-09 0.6250000
## 35 89 14 2035-02-08 2035-06-08 0.4545455
## 36 89 15 2035-03-10 2035-07-08 NA
## 37 89 16 2035-04-09 2035-08-07 1.0000000
## 38 89 17 2035-05-09 2035-09-06 0.8793103
## 39 89 18 2035-06-08 2035-10-06 0.6818182
## 40 89 19 2035-07-08 2035-11-05 0.5084746
## 41 89 20 2035-08-07 2035-12-05 0.2702703
## 42 89 21 2035-09-06 2036-01-04 1.0000000
plot(cmaW, patients.to.plot=c("11"), show.legend=FALSE)
plot(cmaW, patients.to.plot=c("89"), show.legend=FALSE)
Sliding windows are good to estimate the variation of adherence during a medication episode. As shown in each patient, we set the step duration to 30, which allows for a CMA estimation to be calculated every month for a 4 month duration.
Both CMA per episode and CMA sliding windows are necessary to understand adherence within patients as they provide slightly different insights.
Medication Adherence is an important factor to understanding the overall health outlook of a patient. Although the patient can be prescribed medication that would be beneficial to their recovery, if not taken as prescribed, could lead to failure of recovery or worse. AdhereR allows for the calculation of adherence per patient and provides insight on how well or how poor a patient is adhering to the prescribed instructions.
As shown within our analysis, we were able to visualize the general overview of the medication history per patient. WE were able to calculate the adherence percentage within a specified window, within each medication episode, and within the sliding window format.
Opportunities for further analysis could be by focusing on the following:
Applying AdhereR to a “real life” data set
Calculate adherence percentages for all patients within a particular window and compare
Analyze patients with favorable adherence scores and gather their demographic information