Git Product home page Git Product logo

predictriskscores's Introduction

PREDICT CVD Risk Scores

This is an R package featuring functions for generating PREDICT cardiovascular disease (CVD) risk scores.

Features

  • Estimate 5 year CVD risk in people with and without established CVD
  • Estimate 5 year CVD risk in people who have experienced an acute coronary syndrome (ACS)
  • Estimate 5 year CVD risk in people without established Type-II diabetes
  • Estimate 5 year major bleeding risk in people without established CVD

Functions

  1. NoPriorCVDRisk calculates the 5 year absolute risk of CVD for people without a history of atherosclerotic CVD. Published in the Lancet (Pylypchuk et al. 2018) and does not include BMI as a predictor. Full Article

  2. NoPriorCVDRisk_BMI calculates the 5 year absolute risk of CVD for people without a history of atherosclerotic CVD. Published as a Ministry of Health's HISO standard and adds BMI as a predictor to the Lancet equation. HISO Standard

  3. NoPriorCVDRisk_Policy calculates the 5 year absolute risk of CVD for people without a history of atherosclerotic CVD that is intended for use at policy or general population level. Publushed in the IJE (Mehta et al. 2018) and uses routinely-collected health information as predictors. Full Article

  4. NoPriorCVDBleedRisk calculates the 5 year absolute risk of major bleeding for people without a history of atherosclerotic CVD. Published in AnnIntMed (Selak et al. 2019). Full Article

  5. NoPriorT2DRisk creates a 5 year absolute risk of CVD for people without a history of type-II diabetes. Published as a Ministry of Health's HISO standard and includes BMI as a predictor. HISO Standard

  6. PostCVDRisk creates a 5 year absolute risk of CVD for people with prior CVD. This equation is yet to be published. However, it is an update to the previously published equation in Heart (Poppe et al. 2017). Full Article

  7. PostACSRisk creates a 5 year absolute risk for people for people who have experienced an ACS event. Published in heart (Poppe et al. 2019). Full Article

Installation

To install package:

remotes::install_github("billy-nz/PredictRiskScores")

To load the package:

library(PredictRiskScores)

Usage

One-off Calculator

Each function can be used as either a calculator or vectoriser. When used as a one-off calculator, a dataset is not required. This can be handy when checking the risk estimate for an individual person or for quickly seeing the effect of changing a single parameter value.

PostACSRisk(sex="F", age=65, eth=Indian, nzdep=5, smoker=0, diabetes=0,
            af=0, hf=1, acsdays=65, acstype="NSTEMI", bmi=NA, sbp=118,
            tchdl=3.3, hba1c=NA, scr=52, bpl=1, lld=1, athrombi=1)
[1] 0.4877

All parameter values can be numeric or encoded. Values for some parameters such as BMI and HbA1C can be NA if the value is unknown. See values in R documentation. Binary variables can take TRUE/FALSE boolean values.

PostACSRisk(sex=0, age=65, eth=43, nzdep=5, smoker=0, diabetes=0,
            af=0, hf=1, acsdays=65, acstype=1, bmi=NA, sbp=118,
            tchdl=3.3, hba1c=NA, scr=52, bpl=T, lld=F, athrombi=1)
[1] 0.4877

Binary parameters can take a variety of input values. For example, the value for TRUE can be T, Y, Yes, or 1, while the value for FALSE can be F, N, No, or 0. Quotations are not required and case sensitivity is ignored.

NoPriorCVDRisk(sex=F, age=30, eth=M, exsmoker=0, smoker=TRUE, nzdep=3, diabetes=Y,
               af=F, familyhx=1, lld=y, athrombi=yes, bpl=T, sbp=150, tchdl=5)
[1] 0.0549

Vectorise Dataset

When a dataset is supplied, a risk score is produced for each row of data. Each argument requires the variable name from the dataset. This can be handy when risk estimates are required for each row of data, or when datasets require vectorisation.

NoPriorCVDRisk(dat=DATA, sex=sex, age=age, eth=ethnicity, exsmoker=exsmoker, smoker=current_smk, nzdep=nzdep, 
              diabetes=diab_status, af=hx_af, familyhx=familyhx, lld=lld, athrombi=athrombotics, bpl=bpl, 
              sbp=sbp, tchdl=tchdl)
[1] 0.3327 0.0489 0.0620 0.5441 0.0688 0.1672 0.5054 0.0442 0.0150 0.0387

When a dataset is supplied, the function returns a numeric vector of risk scores. Each element of the vector is positioned as per row index. As such, the resulting numeric vector can be assigned back to the dataset as a new variable.

DATA$riskscores <- NoPriorCVDRisk(dat=DATA, sex=sex, age=age, eth=ethnicity, exsmoker=exsmoker, smoker=current_smk,
                                  nzdep=nzdep, diabetes=diab_status, af=hx_af, familyhx=familyhx, lld=lld, 
                                  athrombi=athrombotics, bpl=bpl, sbp=sbp, tchdl=tchdl)l)

Integration with data.table and dplyr

The suite of functions in this package can be integrated into both data.table and dplyr. For example, when datasets are extremely large, consider using data.table along with the := notation. In the example below, a new column called riskscore is created. The data.table syntax might seem confusing at first but it offers fast and efficient performance.

library(data.table); setDT(DATA)

DATA[, riskscore := NoPriorCVDRisk(dat=DATA, sex=sex, age=age, eth=ethnicity, exsmoker=exsmoker, smoker=current_smk,
                                  nzdep=nzdep, diabetes=diab_status, af=hx_af, familyhx=familyhx, lld=lld,
                                  athrombi=athrombotics, bpl=bpl, sbp=sbp, tchdl=tchdl)]

Users who are more comfortable with dplyr will find that the functions works with mutate. In the example below, a new column called riskscore is created.

library(dplyr)

DATA %>%
  mutate(riskscore = NoPriorCVDRisk(dat=DATA, sex=sex, age=age, eth=ethnicity, exsmoker=exsmoker, smoker=current_smk,
                                    nzdep=nzdep, diabetes=diab_status, af=hx_af, familyhx=familyhx, lld=lld,
                                    athrombi=athrombotics, bpl=bpl, sbp=sbp, tchdl=tchdl))

Further Arguements

Each function contains 3 dot parameters: dp, allow.age, and allow.na. A function will:

  • by default return risk scores to 4 decimal places. The number of decimal places can be changed using the argument dp. For example, dp = 6 will produce risk scores containing 6 decimal places.
  • by default return risk scores for people between 18 and 110 years of age. Ages 18 - 29 are calculated as 30; and 80 - 110 as 79. However, the risk prediction equations were developed from a cohort of people aged 30 to 74 years. Using the argument allow.age will determine whether a function is applied to ages outside of 30 - 74. If allow.age is set to FALSE, then age values between 30 and 74 must be provided, else NA is returned as the risk score.
  • by default return risk scores where the missing values NA is treated as 0, No, or FALSE. This applies only to binary variables including smoking status. If allow.na is set to FALSE, then binary inputs including smoking status must have a value, else NA will be returned as the risk score.

R Documentation

library(PredictRiskScores)

?NoPriorCVDRisk
?NoPriorCVDRisk_BMI
?NoPriorCVDRisk_Policy
?NoPriorCVDBleedRisk
?NoPriorT2DRisk
?PostCVDRisk
?PostACSRisk

Maintainer / Developer

See Also

I built a web-based risk calculator using the bleeding risk equation developed by Selak et al (2019) and the general CVD risk equation developed by Pylypchuk et al (2018), to provides clinicians with an individualised estimate of the CVD benefit and bleeding harms of aspirin for their patients without established CVD. Full Article.

Link to the risk calculator here

Coming Soon

  • Estimate 5 year CVD risk in people with severe mental illness
  • Estimate 5 year diabetes risk in people without established diabetes
  • Estimate 5 year acute CVD risk in people with established ACS
  • Estimate 5 year acute bleeding risk in people with established ACS

predictriskscores's People

Contributors

billy-nz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.