Title: | Automatic Estimation of the Most Likely Drug Combination using Smooth Algorithm |
---|---|
Description: | A flexible moving average algorithm for modeling drug exposure in pharmacoepidemiology studies as presented in the article: Ouchi, D., Giner-Soriano, M., Gómez-Lumbreras, A., Vedia Urgell, C.,Torres, F., & Morros, R. (2022). "Automatic Estimation of the Most Likely Drug Combination in Electronic Health Records Using the Smooth Algorithm : Development and Validation Study." JMIR medical informatics, 10(11), e37976. <doi:10.2196/37976>. |
Authors: | Dan Ouchi [aut, cre, cph] , Alvaro Franquet [aut] |
Maintainer: | Dan Ouchi <[email protected]> |
License: | GPL (>= 3) |
Version: | 1.0.0 |
Built: | 2024-12-24 06:43:59 UTC |
Source: | CRAN |
This dataset contains information about drug administration. Each row represents a unique drug administration event.
drugstreatment
drugstreatment
A data frame with the following columns:
Unique identifier for each drug administration event.
The start date of drug administration.
The end date of drug administration.
The name of the drug administered.
data("drugstreatment") head(drugstreatment)
data("drugstreatment") head(drugstreatment)
Description part
smooth_algorithm(id, treatment, day, N, width = 61)
smooth_algorithm(id, treatment, day, N, width = 61)
id |
Unique identifier of the patient. |
treatment |
Name of the drug used. |
day |
Day of the treatment. |
N |
Number of drugs used in the treatment. |
width |
An integer specifying the window width (in numbers of days, 61 by default). |
A data.frame with the following structure:
A character vector representing the unique identifier for each patient.
A character vector representing the date when the treatment was administered to the patients.
A character vector representing the type of treatment given to each patient.
A character vector representing the smoothed treatment given to each patient.
library(smoothy) library(dplyr) data(drugstreatment) df <- drugstreatment |> filter(id == "01f13c15-d9f1-4106-a04f-976c457edd0a") structured_df <- smooth_parse( id = df$id, start_date = df$start_date, end_date = df$end_date, drug = df$drug, study_from = "1970-01-01", study_to = "1975-01-01" ) head(structured_df) id = structured_df$id treatment = structured_df$treatment day = structured_df$day N = structured_df$N width = 61 smoothed <- smooth_algorithm(id = id, treatment = treatment, day = day, N = N, width = width) head(smoothed)
library(smoothy) library(dplyr) data(drugstreatment) df <- drugstreatment |> filter(id == "01f13c15-d9f1-4106-a04f-976c457edd0a") structured_df <- smooth_parse( id = df$id, start_date = df$start_date, end_date = df$end_date, drug = df$drug, study_from = "1970-01-01", study_to = "1975-01-01" ) head(structured_df) id = structured_df$id treatment = structured_df$treatment day = structured_df$day N = structured_df$N width = 61 smoothed <- smooth_algorithm(id = id, treatment = treatment, day = day, N = N, width = width) head(smoothed)
Transforms the Data with a Row by Date to a Row by Individual.
smooth_deparse(id, day, treatment)
smooth_deparse(id, day, treatment)
id |
Unique identifier of the patient. |
day |
Day of the treatment. |
treatment |
A character vector representing the type of treatment given to each patient. |
A data.frame with the following structure:
A character vector representing the unique identifier for each patient.
Start date of the treatment.
End date of the treatment.
A character vector representing the type of treatment given to each patient.
library(smoothy) library(dplyr) data(drugstreatment) my_data <- filter(drugstreatment, id == "01f13c15-d9f1-4106-a04f-976c457edd0a") structured_df <- smooth_parse( id = my_data$id, start_date = my_data$start_date, end_date = my_data$end_date, drug = my_data$drug, study_from = "1970-01-01", study_to = "1975-01-01" ) head(structured_df) id = structured_df$id treatment = structured_df$treatment day = structured_df$day N = structured_df$N width = 61 smoothed <- smooth_algorithm(id = id, treatment = treatment, day = day, N = N, width = width) head(smoothed) deparsed_treatment <- smooth_deparse(smoothed$id, smoothed$day, smoothed$treatment) deparsed_smothed <- smooth_deparse(smoothed$id, smoothed$day, smoothed$smoothed_treatment)
library(smoothy) library(dplyr) data(drugstreatment) my_data <- filter(drugstreatment, id == "01f13c15-d9f1-4106-a04f-976c457edd0a") structured_df <- smooth_parse( id = my_data$id, start_date = my_data$start_date, end_date = my_data$end_date, drug = my_data$drug, study_from = "1970-01-01", study_to = "1975-01-01" ) head(structured_df) id = structured_df$id treatment = structured_df$treatment day = structured_df$day N = structured_df$N width = 61 smoothed <- smooth_algorithm(id = id, treatment = treatment, day = day, N = N, width = width) head(smoothed) deparsed_treatment <- smooth_deparse(smoothed$id, smoothed$day, smoothed$treatment) deparsed_smothed <- smooth_deparse(smoothed$id, smoothed$day, smoothed$smoothed_treatment)
This function computes the differences between the initial treatment and the treatment when it's smoothed.
smooth_diff(treatment, smoothed_treatment)
smooth_diff(treatment, smoothed_treatment)
treatment |
a character vector containing the original treatment data.. |
smoothed_treatment |
a character vector containing the smoothed treatment return by |
A data.frame with three columns: diff_type , diff, change and treatment:
A character vector representing indicating the type of difference computed.
The number of different items.
The proportion of difference computed as number of diferent rows over number of rows.
A character vector representing the type of treatment given to each patient.
library(smoothy) library(dplyr) data(drugstreatment) my_data <- filter(drugstreatment, id == "01f13c15-d9f1-4106-a04f-976c457edd0a") structured_df <- smooth_parse( id = my_data$id, start_date = my_data$start_date, end_date = my_data$end_date, drug = my_data$drug, study_from = "1970-01-01", study_to = "1975-01-01" ) head(structured_df) id = structured_df$id treatment = structured_df$treatment day = structured_df$day N = structured_df$N width = 61 smoothed <- smooth_algorithm(id = id, treatment = treatment, day = day, N = N, width = width) head(smoothed) smooth_diff(treatment = smoothed$treatment, smoothed_treatment = smoothed$smoothed_treatment)
library(smoothy) library(dplyr) data(drugstreatment) my_data <- filter(drugstreatment, id == "01f13c15-d9f1-4106-a04f-976c457edd0a") structured_df <- smooth_parse( id = my_data$id, start_date = my_data$start_date, end_date = my_data$end_date, drug = my_data$drug, study_from = "1970-01-01", study_to = "1975-01-01" ) head(structured_df) id = structured_df$id treatment = structured_df$treatment day = structured_df$day N = structured_df$N width = 61 smoothed <- smooth_algorithm(id = id, treatment = treatment, day = day, N = N, width = width) head(smoothed) smooth_diff(treatment = smoothed$treatment, smoothed_treatment = smoothed$smoothed_treatment)
smooth_algorithm()
FunctionThis function transforms the data to obtain the daily treatment.
smooth_parse( id, start_date, end_date, drug, study_from = min(start_date), study_to = max(end_date) )
smooth_parse( id, start_date, end_date, drug, study_from = min(start_date), study_to = max(end_date) )
id |
Unique identifier of the patient. |
start_date |
Start date of the treatment. |
end_date |
End date of the treatment. |
drug |
Name of the drug used. |
study_from |
A date indicating when the study start. |
study_to |
A date indicating when the study finish. |
A data.frame with the following structure:
Unique identifier of the patient.
Name of the drug used.
Day of the treatment.
Number of drugs used in the treatment
library(smoothy) library(dplyr) data(drugstreatment) df <- drugstreatment |> filter(id == "01f13c15-d9f1-4106-a04f-976c457edd0a") structured_df <- smooth_parse( id = df$id, start_date = df$start_date, end_date = df$end_date, drug = df$drug, study_from = "1970-01-01", study_to = "1975-01-01" ) head(structured_df)
library(smoothy) library(dplyr) data(drugstreatment) df <- drugstreatment |> filter(id == "01f13c15-d9f1-4106-a04f-976c457edd0a") structured_df <- smooth_parse( id = df$id, start_date = df$start_date, end_date = df$end_date, drug = df$drug, study_from = "1970-01-01", study_to = "1975-01-01" ) head(structured_df)