Package 'expard'

Title: Drug EXPosures and ADRs
Description: An R package for fitting complex drug exposure and adverse drug reaction (ADR) relationships
Authors: Louis Dijkstra
Maintainer: Louis Dijkstra <[email protected]>
License: GPL-3
Version: 1.0.0
Built: 2025-01-04 05:56:51 UTC
Source: https://github.com/bips-hb/expard

Help Index


Apply Function to Subset Drug History

Description

Observations might not be present for certain patients, since they entered the data set later time = 1 or before the end. This function applies, for example, a risk model only to the observed time points.

Usage

apply_function_to_observed_timepoints(
  drug_history,
  fn = expard::risk_model_current_use()
)

Arguments

drug_history

The drug history. Unobserved time points are denoted by NA

fn

A function (Default risk_model_current_use).

Value

Vector of the same length as drug_history. None observed time points are denoted by NA


Creating a 2×22 \times 2 Table

Description

Creates a 2×22 \times 2 contingency table for a drug and ADR.

A table is structured in the following form:

ADR not ADR
drug a c
not drug b d

Usage

create2x2table(drug_ADR_pair, method = c("time-point", "drug-era", "patient"))

Arguments

drug_ADR_pair

A drug-ADR pair; see generate_cohort

method

Method used to construct the table; either time-point, drug-era and patient. See the description for more information (Default: time-point)

Value

A cont_table object; a list with

a, b, c, d

The counts in the table

method

Method that was used to construct the table

n

Total count (n = a + b + c + d). The interpretation depends on the method used

Ways to construct the table

The counts can be constructed in three different ways. See for two of them Zorych et al. (2013).

By individual time-points (time-point)

Each time-point is counted separately. The counts are the number of time points that

  • a - the drug was prescribed and the ADR occurred

  • b - the drug was not prescribed but the ADR occurred

  • c - the drug was prescribed but the ADR did not occur

  • d - the drug was not prescribed and the ADR did not occur

Note that in this case the total count n = a + b + c + d is the same as the total number of time points observed, i.e., the total number of patients times the number of time points observed: n_patients * simulation_time.

By individual patients (patient)

In this case, individual patients are counted. The counts are the number of patients that

  • a - were prescribed the drug and did experience the ADR

  • b - were never prescribed the drug and did experience the ADR

  • c - were prescribed the drug and never experienced the ADR

  • d - were never prescribed the drug and never experienced the ADR

In this case, the total count n = a + b + c +d is the same as the number of patients, n_patients.

By individual patients (drug-era)

In this case we look at drug-eras, i.e., periods in which the patients was prescribed or not prescribed the drug for a longer time. For example, if the patient was prescribed the drug from time point 3 to 6, then that period is called a drug-era. The counts are the number of drug- and non-drug eras in which

  • a - the drug was prescribed and the ADR occurred

  • b - the drug was not prescribed but the ADR occurred

  • c - the drug was prescribed but the ADR did not occur

  • d - the drug was not prescribed and the ADR did not occur

In this case, the total count n is the total number of drug- and non-drug eras.

References

Zorych, I., Madigan, D., Ryan, P., & Bate, A. (2013). Disproportionality methods for pharmacovigilance in longitudinal observational databases. Statistical Methods in Medical Research, 22(1), 39–56. https://doi.org/10.1177/0962280211403602

See Also

generate_cohort

Examples

set.seed(1)
cohort <- generate_cohort(n_patients = 200) 

# create the 2x2 contingency table per time-point, 
# drug-era and patient: 
create2x2table(cohort, method = "time-point")
create2x2table(cohort, method = "drug-era")
create2x2table(cohort, method = "patient")

2×22 \times 2 Tables

Description

Creates the 2×22 \times 2 contingency tables for all drug-ADR pairs in a specific cohort. The function is basically a wrapper for create2x2table

Usage

create2x2tables(
  cohort,
  method = c("time-point", "drug-era", "patient"),
  verbose = TRUE
)

Arguments

cohort

A cohort; see generate_cohort

method

Method used to construct the table; either time-point, drug-era and patient. See the description for more information (Default: time-point)

Details



A table is structured in the following form:

ADR not ADR
drug a c
not drug b d

Value

A list of cont_table objects

Ways to construct the table

The counts can be constructed in three different ways. See for two of them Zorych et al. (2013).

By individual time-points (time-point)

Each time-point is counted separately. The counts are the number of time points that

  • a - the drug was prescribed and the ADR occurred

  • b - the drug was not prescribed but the ADR occurred

  • c - the drug was prescribed but the ADR did not occur

  • d - the drug was not prescribed and the ADR did not occur

Note that in this case the total count n = a + b + c + d is the same as the total number of time points observed, i.e., the total number of patients times the number of time points observed: n_patients * simulation_time.

By individual patients (patient)

In this case, individual patients are counted. The counts are the number of patients that

  • a - were prescribed the drug and did experience the ADR

  • b - were never prescribed the drug and did experience the ADR

  • c - were prescribed the drug and never experienced the ADR

  • d - were never prescribed the drug and never experienced the ADR

In this case, the total count n = a + b + c +d is the same as the number of patients, n_patients.

By individual patients (drug-era)

In this case we look at drug-eras, i.e., periods in which the patients was prescribed or not prescribed the drug for a longer time. For example, if the patient was prescribed the drug from time point 3 to 6, then that period is called a drug-era. The counts are the number of drug- and non-drug eras in which

  • a - the drug was prescribed and the ADR occurred

  • b - the drug was not prescribed but the ADR occurred

  • c - the drug was prescribed but the ADR did not occur

  • d - the drug was not prescribed and the ADR did not occur

In this case, the total count n is the total number of drug- and non-drug eras.

References

Zorych, I., Madigan, D., Ryan, P., & Bate, A. (2013). Disproportionality methods for pharmacovigilance in longitudinal observational databases. Statistical Methods in Medical Research, 22(1), 39–56. https://doi.org/10.1177/0962280211403602

See Also

create2x2table

Examples

set.seed(1)
cohort <- generate_cohort(n_patients = 200) 

# create the 2x2 contingency table per time-point, 
# drug-era and patient: 
create2x2table(cohort, method = "time-point")
create2x2table(cohort, method = "drug-era")
create2x2table(cohort, method = "patient")

First Prescription

Description

determine_first_perscription returns a time point for the first prescription of the drug of interest given the time frame of the patient (simulation_time) and the chance for it be prescribed is min_chance_drug. The patient, in this case, is always prescribed the drug at least once. The time point follows a Γ\Gamma distribution.

Usage

determine_first_prescription(n_patients, simulation_time, min_chance_drug)

Arguments

n_patients

Number of patients (Default: 1)

simulation_time

The total number of time points for this patient

min_chance_drug

The probability of the drug being prescribed at any given time point

Details

Note: we assume here that the probability of the drug being prescribed does not depend on any previous prescriptions.

Value

A time point between 1 and simulation_time

Examples

set.seed(1)
determine_first_prescription(n_patients = 4, simulation_time = 10, min_chance_drug = 0.1)
# -> [1] 2 3 5 9

Compute Frequency Table

Description

Determine how often different values from time_steps_ago appear in the data set and how often the ADR occurs for each of them. This is used for speeding up the computation of the loglikeihood

Usage

determine_frequency_unique_values(mat, adr_history)

Arguments

mat

Matrix with relevant values (depends on model)

adr_history

History of ADRs

Value

Tibble


Fit a Model to Cohort Data

Description

fit_model fits a specified risk model risk_model to cohort data.

Usage

fit_model(
  pair,
  model = c("no-association", "current-use", "past-use", "withdrawal", "delayed",
    "decaying", "delayed+decaying", "long-term"),
  zero_patients = 0,
  zero_timepoints = 0,
  method = c("L-BFGS-B", "Nelder-Mead", "BFGS", "CG", "SANN", "Brent"),
  maxiter = 1000,
  parameters = list(),
  mc.cores = 1
)

Arguments

model

Label for a risk model. Can be either ...

method

Methods used by the base optim-solver

maxiter

Maximum number iterations for the optim-solver

cohort

A cohort dataset. See details below.

start

Starting point for the base optim-solver (Default: c(-1,1))

control

List used by the base optim-solver

Value

A model fit. A list with the items

n_patients

Total number of patients in the dataset

simulation_time

Total number of time points

loglikelihood

The maximal log-likelihood value

beta0

Intercept for the logistic model

beta

Parameter for the logistic model

prob_no_adr_with_drug

Estimated probability of no ADR occurring

prob_ADR_with_drug

Estimated probability of ADR occurring

convergence

Convergence value of optim. 0 means that the algorithm converged

Patient models

fit_model can currently only deal with the patient_model_uninformative. More complex patient models, such as patient_model_sex require the estimation of more parameters which is currently not supported.

Cohort data object

Minimal requirement is that the cohort is a list with two matrix with the items

  • drug_history A binary matrix of size n_patients x simulation_time describing the drug prescriptions.

  • adr_history A binary matrix of size n_patients x simulation_time describing ADR histories

See check_cohort and generate_cohort for more details on the cohort object.

See Also

check_cohort,generate_cohort

Examples

cohort <- expard::generate_cohort(n_patients = 1000, 
                                  simulation_time = 100, 
                                  risk_model = expard::risk_model_immediate(), 
                                  verbose = TRUE, 
                                  min_chance_drug = probability_model_constant(.3), 
                                  max_chance_drug = probability_model_constant(.7), 
                                  min_chance_adr = probability_model_constant(.3),
                                  max_chance_adr = probability_model_constant(.6))
# fit the no effect model
fit_model(cohort, risk_model = expard::risk_model_no_effect()) 

# fit the true immediate effect model
fit_model(cohort, risk_model = expard::risk_model_immediate())
# note that the estimators are close to the truth (.3 and .6)

Returns ADR History

Description

Generates a binary vector of ADR occurrences given a drug history and a risk model.

Usage

generate_adr_history(drug_history, risk_model, min_chance, max_chance, ...)

Arguments

drug_history

Binary vector denoting the drug prescriptions history

risk_model

A risk model, e.g., risk_model_current_use

min_chance

The probability of the ADR when the drug history has no effect

max_chance

The probability of the ADR when the drug history has the highest possible effect

Value

Binary vector of the same length as drug_history


Generate a Cohort

Description

Generates a cohort which is a collection of drug-ADR pair. It is a wrapper function for the generate_patient function.

Usage

generate_cohort(
  n_patients = 100,
  simulation_time = 100,
  n_drug_ADR_pairs = 50,
  risk_model = rep("risk_model_current_use()", n_drug_ADR_pairs),
  min_chance_drug = rep(0.1, n_drug_ADR_pairs),
  avg_duration = rep(5, n_drug_ADR_pairs),
  max_chance_drug = rep(NULL, n_drug_ADR_pairs),
  prob_guaranteed_exposed = rep(1, n_drug_ADR_pairs),
  min_chance = rep(0.1, n_drug_ADR_pairs),
  max_chance = rep(0.4, n_drug_ADR_pairs),
  verbose = FALSE
)

Arguments

n_patients

Number of patients

simulation_time

The total number of time steps

n_drug_ADR_pairs

Number of drug-ADR pairs simulated

risk_model

Vector with risk models. Each risk model is given as a string, e.g., "risk_model_current_use()". The vector must have the length n_drug_ADR_pairs#'

min_chance_drug

Vector with the probabilities of the drug being prescribed when the drug history and the ADR history have no effect. Must have a length of n_drug_ADR_pairs.

avg_duration

Average number of time points a patient is exposed once exposed to the drug (Determines max_chance) Must have a length of n_drug_ADR_pairs.

max_chance_drug

The probability of the ADR when the drug history and the ADR history have the highest possible effect (Default: NULL) Must have a length of n_drug_ADR_pairs.

min_chance

The probability of the ADR when the drug history has no effect Must have a length of n_drug_ADR_pairs.

max_chance

The probability of the ADR when the drug history has the highest possible effect Must have a length of n_drug_ADR_pairs.

verbose

Show progress bar (Default: FALSE)

Value

A cohort object; A list of length n_drug_ADR_pairs. Each entry contains two binary matrices; one for the drug histories of all patients and one for the ADR histories of all patients. Each row is a patient

See Also

generate_patient


Generate a Drug-ADR pair

Description

Generates the drug- and ADR history

Usage

generate_drug_ADR_pair(
  simulation_time = 100,
  risk_model = risk_model_current_use(),
  min_chance_drug = 0.1,
  avg_duration = 5,
  max_chance_drug = NULL,
  guaranteed_exposed = TRUE,
  min_chance = 0.1,
  max_chance = 0.4
)

Arguments

simulation_time

The total number of time steps

risk_model

One of the risk models

min_chance_drug

The probability of the drug being prescribed when the drug history and the ADR history have no effect

avg_duration

Average number of time points a patient is exposed once exposed to the drug (Determines max_chance)

max_chance_drug

The probability of the ADR when the drug history and the ADR history have the highest possible effect (Default: NULL)

guaranteed_exposed

If TRUE, the patient is exposed to the drug at least once

min_chance

The probability of the ADR when the drug history has no effect

max_chance

The probability of the ADR when the drug history has the highest possible effect

Value

A list with

drug_history

binary vector of the drug history

adr_history

binary vector of the ADR history

See Also

generate_cohort

Examples

drug_ADR_pair <- expard::generate_drug_ADR_pair()

Generate Drug Prescription History

Description

Returns whether or not the drug is prescribed at the next time point (1) or not (0). The probability depends on the drug prescriptions, the ADR history and the drug_model.

Usage

generate_drug_history(
  simulation_time = 10,
  min_chance,
  avg_duration = 5,
  max_chance = NULL,
  guaranteed_exposed = TRUE,
  ...
)

Arguments

simulation_time

Total number of time points

min_chance

The probability of the drug being prescribed when the drug history and the ADR history have no effect

avg_duration

Average number of time points a patient is exposed once exposed to the drug (Determines max_chance)

max_chance

The probability of the ADR when the drug history and the ADR history have the highest possible effect (Default: NULL)

guaranteed_exposed

If TRUE, the patient is exposed to the drug at least once

Value

1 or 0

Examples

generate_drug_history(simulation_time = 10, 
                      min_chance = .1,
                      avg_duration = 5
                      guaranteed_exposed = TRUE)

Generate a Patient

Description

Generates a patient, which is a collection of different drug-ADR pairs, see function generate_drug_ADR_pair.

Usage

generate_patient(
  simulation_time = 100,
  n_drug_ADR_pairs = 50,
  risk_model = rep("risk_model_current_use()", n_drug_ADR_pairs),
  min_chance_drug = rep(0.1, n_drug_ADR_pairs),
  avg_duration = rep(5, n_drug_ADR_pairs),
  max_chance_drug = rep(NULL, n_drug_ADR_pairs),
  guaranteed_exposed = rep(TRUE, n_drug_ADR_pairs),
  min_chance = rep(0.1, n_drug_ADR_pairs),
  max_chance = rep(0.4, n_drug_ADR_pairs)
)

Arguments

simulation_time

The total number of time steps

n_drug_ADR_pairs

Number of drug-ADR pairs simulated

risk_model

Vector with risk models. Each risk model is given as a string, e.g., "risk_model_current_use()". The vector must have the length n_drug_ADR_pairs#'

min_chance_drug

Vector with the probabilities of the drug being prescribed when the drug history and the ADR history have no effect. Must have a length of n_drug_ADR_pairs.

avg_duration

Average number of time points a patient is exposed once exposed to the drug (Determines max_chance) Must have a length of n_drug_ADR_pairs.

max_chance_drug

The probability of the ADR when the drug history and the ADR history have the highest possible effect (Default: NULL) Must have a length of n_drug_ADR_pairs.

guaranteed_exposed

If TRUE, the patient is exposed to the drug at least once Must have a length of n_drug_ADR_pairs.

min_chance

The probability of the ADR when the drug history has no effect Must have a length of n_drug_ADR_pairs.

max_chance

The probability of the ADR when the drug history has the highest possible effect Must have a length of n_drug_ADR_pairs.

Value

A list of drug-ADR pairs, see generate_drug_ADR_pair

See Also

generate_cohort, generate_drug_ADR_pair, generate_drug_history


Hello, World!

Description

Prints 'Hello, world!'.

Usage

hello()

Examples

hello()

Negative of the Log-Likelihood Function

Description

loglikelihood returns the negative log-likelihood function, defined as

π=exp(β0+risksβ)1+exp(β0+risksβ)\pi = \frac{\exp(\beta_0 + \code{risks}\cdot \beta)}{1 + \exp(\beta_0 + \code{risks}\cdot \beta)}

where π\pi is the probability.

Usage

loglikelihood(betas, risks, adr_history)

Arguments

betas

Vector with two entries: beta0, beta

risks

Risks determined by the risk model. The risk model was applied to the observed drug prescription history


Plot the Fit

Description

Plots the BIC for the different risk models that were fitted by the function fit_all_models.

Usage

plot_fit(
  fit,
  x_label = "model",
  title = "",
  y_range = NULL,
  past_values = NULL
)

Arguments

fit

The fit

past_values

If not NULL, a select number of values for past are used for the plot

xlab

The x-label

Value

ggplot


Plot Risk

Description

Plots the risk function's behavior for a given drug prescription history. The xx-axis denote the drug prescriptions and the yy-axis represent the risk level, i.e., 1 is maximal risk, 0 minimal risk.

Usage

plot_risk(
  drug_history = c(rep(0, 4), rep(1, 6), rep(0, 10)),
  risk_model = risk_model_immediate(),
  simulation_time = NULL,
  title = "",
  ylim = c(0, 1),
  shaded_area = TRUE,
  fill = "black",
  alpha = 0.3
)

Arguments

drug_history

Binary vector denoting the drug prescription history. (Default: 0 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0)

risk_model

One of the risk models

simulation_time

If not NULL, total number of time points, i.e., 0 0 0 0 1 1 1 1 1 1 0 0 0 0 .... (Default: NULL)

title

Title of the plot

ylim

The limits of the y-axis: c(ymin, ymax) (Default: c(0,1))

shaded_area

If TRUE, periods in which drugs were prescribed are shaded in a gray tone. Otherwise, the drug prescription periods are denoted by vertical dashed red lines (Default: TRUE)

fill

Color used for the shaded area (Default: black)

alpha

Alpha value for shaded area (Default: .3)

Value

A ggplot2 plot

Examples

drug_history <- c(rep(0, 4), rep(1, 6), rep(0, 10))
risk_model <- risk_model_immediate() 

# create the plot
p <- plot_risk(drug_history, 
               risk_model, 
               title = "Direct effect model")
p

Print function for generate_cohort

Description

Print function for generate_cohort

Usage

## S3 method for class 'cohort'
print(cohort)

Print function for 2x2 tables

Description

Print function for 2x2 tables

Usage

## S3 method for class 'cont_table'
print(table)

Function for printing a drug-ADR pair

Description

Function for printing a drug-ADR pair

Usage

## S3 method for class 'drug_ADR_pair'
print(drug_ADR_pair)

Print function for the hccd fit_model

Description

Print function for the hccd fit_model

Usage

## S3 method for class 'expardfit2'
print(fit)

Function for printing a patient

Description

Function for printing a patient

Usage

## S3 method for class 'patient'
print(patient)

Risk Model 'Immediate'

Description

A risk model reflects how the probability of suffering the ADR changes with the drug exposures of a patient. It returns 0 when the drug prescription history has no effect, and 1 when the patient is at maximal risk. In this case, the probability of the ADR is maximal only when the patient is currently exposed.

Usage

risk_model_current_use()

Value

A risk model

See Also

Other Risk models: risk_model_decaying(), risk_model_delayed(), risk_model_duration(), risk_model_long_term(), risk_model_no_association(), risk_model_past(), risk_model_withdrawal()

Examples

drug_history <- c(1, 0, 1, 0, 0)
risk_model <- risk_model_immediate() 
risk_model(drug_history)

Risk Model 'Decaying'

Description

Risk Model 'Decaying'

Usage

risk_model_decaying(rate)

Arguments

rate

The rate with which the risk dissipates

Value

A risk model

See Also

Other Risk models: risk_model_current_use(), risk_model_delayed(), risk_model_duration(), risk_model_long_term(), risk_model_no_association(), risk_model_past(), risk_model_withdrawal()

Examples

drug_history <- c(1, 0, 1, 0, 0)

risk_model <- risk_model_withdrawal(rate = 1.2) 
risk_model(drug_history)

Risk Model 'Delayed'

Description

Risk Model 'Delayed'

Usage

risk_model_delayed(mu, sigma)

Arguments

rate

The rate with which the risk dissipates

Value

A risk model

See Also

Other Risk models: risk_model_current_use(), risk_model_decaying(), risk_model_duration(), risk_model_long_term(), risk_model_no_association(), risk_model_past(), risk_model_withdrawal()

Examples

drug_history <- c(1, 0, 1, 0, 0)

risk_model <- risk_model_withdrawal(rate = 1.2) 
risk_model(drug_history)

Risk Model 'Withdrawal'

Description

A risk model reflects how the probability of suffering the ADR changes with the drug exposures of a patient. It returns 0 when the drug prescription history has no effect, and 1 when the patient is at maximal risk. In this case, once the patient is no longer exposed to the drug, the probability of the ADR peaks and then dissipates exponentially. Let τ\tau be the number of time points since the patient was prescribed the drug last. The return value is the given by

exp(γ(τ1))\exp(-\gamma \cdot (\tau - 1))

where γ\gamma is rate.

Usage

risk_model_duration(duration)

Arguments

rate

The rate with which the risk dissipates

Value

A risk model

See Also

Other Risk models: risk_model_current_use(), risk_model_decaying(), risk_model_delayed(), risk_model_long_term(), risk_model_no_association(), risk_model_past(), risk_model_withdrawal()

Examples

drug_history <- c(1, 0, 1, 0, 0)

risk_model <- risk_model_withdrawal(rate = 1.2) 
risk_model(drug_history)

Risk Model 'Long Time After'

Description

A risk model reflects how the probability of suffering the ADR changes with the drug exposures of a patient. It returns 0 when the drug prescription history has no effect, and 1 when the patient is at maximal risk. In this case, the risk of the ADR increases only after a certain moment in time before it reaches the maximal risk. Let t0t_0 be the time point that the drug was prescribed for the first time, and δ\delta be the number of time points since first description that the function returns 0.5 ("half way"). The return value is

1/(1+exp(γ(t0δ)))1 / (1 + \exp(-\gamma \cdot (t_0 - \delta)))

where γ\gamma is rate. Note that this is a sigmoid function.

Usage

risk_model_long_term(rate, delay)

Arguments

rate

The rate with which the risk increases

delay

How long it takes before the risk is .5

Value

A risk model

See Also

Other Risk models: risk_model_current_use(), risk_model_decaying(), risk_model_delayed(), risk_model_duration(), risk_model_no_association(), risk_model_past(), risk_model_withdrawal()

Examples

drug_history <- c(1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1)

risk_model <- risk_model_long_time_after(rate = .5, delay = 9) 
risk_model(drug_history)

Risk Model 'No Association'

Description

A risk model reflects how the probability of suffering the ADR changes with the drug exposures of a patient. It returns 0 when the drug prescription history has no effect, and 1 when the patient is at maximal risk. In this case, the drug has no effect on the ADR what so ever.

Usage

risk_model_no_association()

Value

A risk model

See Also

Other Risk models: risk_model_current_use(), risk_model_decaying(), risk_model_delayed(), risk_model_duration(), risk_model_long_term(), risk_model_past(), risk_model_withdrawal()

Examples

drug_history <- c(1, 0, 1, 0, 0)
risk_model <- risk_model_no_effect() 
risk_model() 
# -> 0

Risk Model 'Withdrawal'

Description

A risk model reflects how the probability of suffering the ADR changes with the drug exposures of a patient. It returns 0 when the drug prescription history has no effect, and 1 when the patient is at maximal risk. In this case, once the patient is no longer exposed to the drug, the probability of the ADR peaks and then dissipates exponentially. Let τ\tau be the number of time points since the patient was prescribed the drug last. The return value is the given by

exp(γ(τ1))\exp(-\gamma \cdot (\tau - 1))

where γ\gamma is rate.

Usage

risk_model_past(past)

Arguments

rate

The rate with which the risk dissipates

Value

A risk model

See Also

Other Risk models: risk_model_current_use(), risk_model_decaying(), risk_model_delayed(), risk_model_duration(), risk_model_long_term(), risk_model_no_association(), risk_model_withdrawal()

Examples

drug_history <- c(1, 0, 1, 0, 0)

risk_model <- risk_model_withdrawal(rate = 1.2) 
risk_model(drug_history)

Risk Model 'Withdrawal'

Description

A risk model reflects how the probability of suffering the ADR changes with the drug exposures of a patient. It returns 0 when the drug prescription history has no effect, and 1 when the patient is at maximal risk. In this case, once the patient is no longer exposed to the drug, the probability of the ADR peaks and then dissipates exponentially. Let τ\tau be the number of time points since the patient was prescribed the drug last. The return value is the given by

exp(γ(τ1))\exp(-\gamma \cdot (\tau - 1))

where γ\gamma is rate.

Usage

risk_model_withdrawal(rate)

Arguments

rate

The rate with which the risk dissipates

Value

A risk model

See Also

Other Risk models: risk_model_current_use(), risk_model_decaying(), risk_model_delayed(), risk_model_duration(), risk_model_long_term(), risk_model_no_association(), risk_model_past()

Examples

drug_history <- c(1, 0, 1, 0, 0)

risk_model <- risk_model_withdrawal(rate = 1.2) 
risk_model(drug_history)