3 Using the Package in R

3.1 Installation

If you do not have R installed on your computer, please go to Appendix 1. Once you have R installed, you can install this package in the R console:

3.2 ACCEPT Prediction Functions

Sample Data

To get started, there is an R data frame with the package of sample patient data. I have printed columns 1-13 and 14-19 separately because there isn’t enough space:


Exacerbation Rate

To get a prediction for exacerbation rate, you will need to pass in a patient vector:

results <- predictACCEPT(samplePatients[1,])
print(t(results))
>                                                         [,1]        
> ID                                                      "10001"     
> male                                                    "1"         
> age                                                     "70"        
> smoker                                                  "1"         
> oxygen                                                  "1"         
> statin                                                  "1"         
> LAMA                                                    "1"         
> LABA                                                    "1"         
> ICS                                                     "1"         
> FEV1                                                    "33"        
> BMI                                                     "25"        
> SGRQ                                                    "50"        
> LastYrExacCount                                         "2"         
> LastYrSevExacCount                                      "1"         
> randomized_azithromycin                                 "0"         
> randomized_statin                                       "0"         
> randomized_LAMA                                         "0"         
> randomized_LABA                                         "0"         
> randomized_ICS                                          "0"         
> predicted_exac_probability                              "0.7799"    
> predicted_exac_rate                                     "1.813428"  
> azithromycin_predicted_exac_probability                 "0.703674"  
> azithromycin_predicted_exac_rate                        "1.406447"  
> predicted_severe_exac_probability                       "0.4394301" 
> predicted_severe_exac_rate                              "0.7688124" 
> azithromycin_predicted_severe_exac_probability          "0.425913"  
> azithromycin_predicted_severe_exac_rate                 "0.577342"  
> predicted_exac_probability_lower_PI                     "0.4425521" 
> predicted_exac_probability_upper_PI                     "0.9806575" 
> predicted_exac_rate_lower_PI                            "0.5843924" 
> predicted_exac_rate_upper_PI                            "3.945464"  
> azithromycin_predicted_exac_probability_lower_PI        "0.3644317" 
> azithromycin_predicted_exac_probability_upper_PI        "0.9531118" 
> azithromycin_predicted_exac_rate_lower_PI               "0.4532394" 
> azithromycin_predicted_exac_rate_upper_PI               "3.059998"  
> predicted_severe_exac_probability_lower_PI              "0.06018855"
> predicted_severe_exac_probability_upper_PI              "0.904737"  
> predicted_severe_exac_rate_lower_PI                     "0.07760276"
> predicted_severe_exac_rate_upper_PI                     "2.254686"  
> azithromycin_predicted_severe_exac_probability_lower_PI "0.05621219"
> azithromycin_predicted_severe_exac_probability_upper_PI "0.898296"  
> azithromycin_predicted_severe_exac_rate_lower_PI        "0.05628177"
> azithromycin_predicted_severe_exac_rate_upper_PI        "1.701869"  
> predicted_exac_probability_lower_CI                     "0.7705132" 
> predicted_exac_probability_upper_CI                     "0.7892394" 
> predicted_exac_rate_lower_CI                            "1.760126"  
> predicted_exac_rate_upper_CI                            "1.868583"  
> azithromycin_predicted_exac_probability_lower_CI        "0.6931493" 
> azithromycin_predicted_exac_probability_upper_CI        "0.7142844" 
> azithromycin_predicted_exac_rate_lower_CI               "1.365329"  
> azithromycin_predicted_exac_rate_upper_CI               "1.447842"  
> predicted_severe_exac_probability_lower_CI              "0.4235962" 
> predicted_severe_exac_probability_upper_CI              "0.4542333" 
> predicted_severe_exac_rate_lower_CI                     "0.7323719" 
> predicted_severe_exac_rate_upper_CI                     "0.8092376" 
> azithromycin_predicted_severe_exac_probability_lower_CI "0.4116278" 
> azithromycin_predicted_severe_exac_probability_upper_CI "0.4400719" 
> azithromycin_predicted_severe_exac_rate_lower_CI        "0.5519708" 
> azithromycin_predicted_severe_exac_rate_upper_CI        "0.6030546"

The predictACCEPT() function returns a data frame with the original patient data, along with the predictions for different treatment options. Here is a summary of the results:


To visualize the data, there is a graphing function called plotExacerbations(), which creates a Plotly bar graph. You have the option of selecting probability or rate for which prediction you want to see, and either CI or PI to select the confidence interval or prediction interval respectively.

Probability of N Exacerbations (Poisson)

We can also calculate the predicted number of exacerbations in a year:

The shortened parameter groups the probabilities from 3-10 exacerbations into one category, “3 or more exacerbations.” To see all n exacerbation probabilities:

exacerbationsMatrix = predictCountProb(patientResults, n = 10, shortened = FALSE)
print(exacerbationsMatrix)
>                          0 severe       1 severe      2 severe
> 0 exacerbation(s) 0.1631249390163 0.000000000000 0.00000000000
> 1 exacerbation(s) 0.1616077243627 0.134176756503 0.00000000000
> 2 exacerbation(s) 0.0800523106129 0.132928787049 0.05518286197
> 3 exacerbation(s) 0.0264359163925 0.065846212439 0.05466960969
> 4 exacerbation(s) 0.0065475094051 0.021744593672 0.02708056557
> 5 exacerbation(s) 0.0012973222875 0.005385587148 0.00894289698
> 6 exacerbation(s) 0.0002142093293 0.001067099229 0.00221492992
> 7 exacerbation(s) 0.0000303167117 0.000176195701 0.00043886580
> 8 exacerbation(s) 0.0000037543422 0.000024936702 0.00007246399
> 9 exacerbation(s) 0.0000004132693 0.000003088096 0.00001025572
>                        3 severe      4 severe      5 severe      6 severe
> 0 exacerbation(s) 0.00000000000 0.00000000000 0.00000000000 0.00000000000
> 1 exacerbation(s) 0.00000000000 0.00000000000 0.00000000000 0.00000000000
> 2 exacerbation(s) 0.00000000000 0.00000000000 0.00000000000 0.00000000000
> 3 exacerbation(s) 0.01513003362 0.00000000000 0.00000000000 0.00000000000
> 4 exacerbation(s) 0.01498931014 0.00311126375 0.00000000000 0.00000000000
> 5 exacerbation(s) 0.00742494776 0.00308232608 0.00051182766 0.00000000000
> 6 exacerbation(s) 0.00245196293 0.00152682878 0.00050706718 0.00007016644
> 7 exacerbation(s) 0.00060728935 0.00050420928 0.00025117549 0.00006951382
> 8 exacerbation(s) 0.00012032820 0.00012487992 0.00008294644 0.00003443364
> 9 exacerbation(s) 0.00001986817 0.00002474368 0.00002054374 0.00001137113
>                         7 severe        8 severe     9 severe
> 0 exacerbation(s) 0.000000000000 0.0000000000000 0.000000e+00
> 1 exacerbation(s) 0.000000000000 0.0000000000000 0.000000e+00
> 2 exacerbation(s) 0.000000000000 0.0000000000000 0.000000e+00
> 3 exacerbation(s) 0.000000000000 0.0000000000000 0.000000e+00
> 4 exacerbation(s) 0.000000000000 0.0000000000000 0.000000e+00
> 5 exacerbation(s) 0.000000000000 0.0000000000000 0.000000e+00
> 6 exacerbation(s) 0.000000000000 0.0000000000000 0.000000e+00
> 7 exacerbation(s) 0.000008244955 0.0000000000000 0.000000e+00
> 8 exacerbation(s) 0.000008168270 0.0000008477255 0.000000e+00
> 9 exacerbation(s) 0.000004046149 0.0000008398409 7.747644e-08

To visualize the matrix as a heatmap, we can use the function plotHeatMap: