calculate_pdc: Calculate Proportion Days Covered

Description Usage Arguments Value Examples

View source: R/Calculations.R

Description

Calculate the proportion of days covered (PDC) from a pharmaceutical claims database. This function is suggested only after one has properly adjusted their dates (propagate_date()) and identified gaps in therapy (identify_gaps()). This function calculates a length of total therapy as the first fill date to the last for a given grouping. Finally, if you'd like to view adherence by episodes after you have used rank_episodes(), the function will re-adjust gaps for you so that the gap that defined the episode isn't included.

Usage

1
calculate_pdc(.data, .summarise = TRUE)

Arguments

.data

data frame

.summarise

Logical value (defaulting to TRUE) indicating whether the output should be summarised or not

Value

a summarised tibble, by default, with proportion of days covered calculated

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
library(adheRenceRX)
library(dplyr)

toy_claims %>% 
  group_by(ID) %>% 
  propagate_date(.date = date, .days_supply = days_supply) %>% 
  identify_gaps() %>% 
  calculate_pdc()
  
#OR, one could group by the ID and episode of care like...
toy_claims %>% 
  group_by(ID) %>% 
  propagate_date(.date = date, .days_supply = days_supply) %>% 
  identify_gaps() %>% 
  rank_episodes(.permissible_gap = 30) %>% 
  ungroup() %>% 
  group_by(ID, episode) %>% 
  calculate_pdc()

Example output

sh: 1: timedatectl: Permission denied
Error in file(con, "r") : cannot open the connection
In addition: Warning messages:
1: In system("timedatectl", intern = TRUE) :
  running command 'timedatectl' had status 126
2: In file(con, "r") : cannot open file '/etc/timezone': Permission denied

Attaching package:dplyrThe following objects are masked frompackage:stats:

    filter, lag

The following objects are masked frompackage:base:

    intersect, setdiff, setequal, union

# A tibble: 3 x 4
  ID    total_gaps total_days adherence
  <chr>      <dbl>      <dbl>     <dbl>
1 A              0        270     1    
2 B             60        330     0.818
3 D             30        300     0.9  
# A tibble: 4 x 5
# Groups:   ID [3]
  ID    episode total_gaps total_days adherence
  <chr>   <dbl>      <dbl>      <dbl>     <dbl>
1 A           1          0        270       1  
2 B           1          0         60       1  
3 B           2          0        180       1  
4 D           1         30        300       0.9

adheRenceRX documentation built on Jan. 13, 2021, 7:50 a.m.