Title: | Accelerated Stability Kinetic Modelling |
---|---|
Description: | Estimate the Šesták–Berggren kinetic model (degradation model) from experimental data. A A closed-form (analytic) solution to the degradation model is implemented as a non-linear fit, allowing for the extrapolation of the degradation of a drug product - both in time and temperature. Parametric bootstrap, with kinetic parameters drawn from the multivariate t-distribution, and analytical formulae (the delta method) are available options to calculate the confidence and prediction intervals. The results (modelling, extrapolations and statistical intervals) can be visualised with multiple plots. The examples illustrate the accelerated stability modelling in drugs and vaccines development. |
Authors: | Bernard G Franq [aut, cph], Ben Wells [cre], Alex Ball [ctb] |
Maintainer: | Ben Wells <[email protected]> |
License: | AGPL (>= 3) |
Version: | 2.0.1 |
Built: | 2025-02-13 04:43:10 UTC |
Source: | https://github.com/accelstab/accelstab |
An example dataset containing antigenicity concentration data at different temperatures over a period of up to 147 days.
data(antigenicity)
data(antigenicity)
An object of class "data.frame"
with 50 rows and 5 variables
Number of days in years for which the datapoints are gathered.
The concentration at a time.
The temperature in Kelvin.
The temperature in celsius.
Number of days for which the datapoints are gathered.
Predict a temperature excursion for a product.
excursion( step1_down_object, temp_changes, time_changes, CI = TRUE, PI = TRUE, draw = 10000, confidence_interval = 0.95, intercept = NULL, ribbon = TRUE, xname = NULL, yname = NULL, plot_simulations = FALSE )
excursion( step1_down_object, temp_changes, time_changes, CI = TRUE, PI = TRUE, draw = 10000, confidence_interval = 0.95, intercept = NULL, ribbon = TRUE, xname = NULL, yname = NULL, plot_simulations = FALSE )
step1_down_object |
The fit object from the step1.down function (required). |
temp_changes |
A list that represents the order of the temperatures that the product is subjected to. Must be the same length as time_changes. |
time_changes |
List that represents the times at which the temperature changes, Starts from time zero and must be the same length as temp_changes. |
CI |
Show confidence intervals. |
PI |
Show prediction intervals. |
draw |
Number of simulations used to estimate confidence intervals. |
confidence_interval |
Confidence level for the confidence and prediction intervals around the predictions (default 0.95). |
intercept |
Use a forced y-intercept. If null, the fitted value will be used. |
ribbon |
Add shade to confidence and prediction intervals (optional). |
xname |
Label for the x-axis (optional). |
yname |
Label for the y-axis (optional). |
plot_simulations |
If TRUE, randomly selects 100 of the simulations to display on the plot. |
Use the output from step1.down to run a temperature excursion prediction.
An SB class object, a list including the following elements:
prediction - A data frame containing the predictions with the confidence and prediction intervals.
simulations - Matrix of the simulations.
excursion plot - A plot with predictions and statistical intervals.
user_parameters - List of users input parameters which is utilised by other functions in the package.
#load antigenicity data(antigenicity) #run step1.down fit fit1 <- step1_down(data = antigenicity, y = "conc", .time = "time", C = "Celsius", max_time_pred = 3) #run excursion function with fixed intercept. excursion <- excursion(step1_down_object = fit1, temp_changes = c(5,15,10), time_changes = c(0.5,1.5,3), CI = TRUE, PI = TRUE, draw = 4000, confidence_interval = 0.95, intercept = 80, xname = "Time in years", yname = "Concentration", ribbon = TRUE, plot_simulations = TRUE) excursion$excursion_plot
#load antigenicity data(antigenicity) #run step1.down fit fit1 <- step1_down(data = antigenicity, y = "conc", .time = "time", C = "Celsius", max_time_pred = 3) #run excursion function with fixed intercept. excursion <- excursion(step1_down_object = fit1, temp_changes = c(5,15,10), time_changes = c(0.5,1.5,3), CI = TRUE, PI = TRUE, draw = 4000, confidence_interval = 0.95, intercept = 80, xname = "Time in years", yname = "Concentration", ribbon = TRUE, plot_simulations = TRUE) excursion$excursion_plot
An example dataset containing potency data at different temperatures..
data(potency)
data(potency)
An object of class "data.frame"
with 78 rows and 3 variables
Time for which the datapoints are gathered.
Measured potency at a time.
The temperature in celsius.
Fit the one-step Šesták–Berggren kinetic model.
step1_down( data, y, .time, K = NULL, C = NULL, validation = NULL, draw = 10000, parms = NULL, temp_pred_C = NULL, max_time_pred = NULL, confidence_interval = 0.95, by = 101, reparameterisation = FALSE, zero_order = FALSE )
step1_down( data, y, .time, K = NULL, C = NULL, validation = NULL, draw = 10000, parms = NULL, temp_pred_C = NULL, max_time_pred = NULL, confidence_interval = 0.95, by = 101, reparameterisation = FALSE, zero_order = FALSE )
data |
Dataframe containing accelerated stability data (required). |
y |
Name of decreasing variable (e.g. concentration) contained within data (required). |
.time |
Time variable contained within data (required). |
K |
Kelvin variable (numeric or column name) (optional). |
C |
Celsius variable (numeric or column name) (optional). |
validation |
Validation dummy variable (column name) (optional). |
draw |
Number of simulations used to estimate confidence intervals. |
parms |
Starting values for the parameters as a list - k1, k2, k3, and c0. |
temp_pred_C |
Integer or numeric value to predict the response for a given temperature (in Celsius). |
max_time_pred |
Maximum time to predict the response variable. |
confidence_interval |
Confidence level for the confidence and prediction intervals around the predictions (default 0.95). |
by |
Number of points (on the time scale) to smooth the statistical intervals around the predictions. |
reparameterisation |
Use alternative parameterisation of the one-step model which aims to reduce correlation between k1 and k2. |
zero_order |
Set kinetic order, k3, to zero (straight lines). |
Fit the one-step Šesták–Berggren kinetic (non-linear) model using accelerated stability data.
An SB class object, a list including the following elements:
fit - The non-linear fit.
data - The data set.
prediction - A data frame containing the predictions with the confidence and prediction intervals.
user_parameters - List of users input parameters which is utilised by other functions in the package.
#load antigenicity and potency data. data(antigenicity) data(potency) #Basic use of the step1.down function with C column defined. fit1 <- step1_down(data = antigenicity, y = "conc", .time = "time", C = "Celsius", draw = 5000) #Basic use of the step1.down function with K column defined. fit2 <- step1_down(data = antigenicity, y = "conc", .time = "time", K = "K", draw = 5000) #When zero_order = FALSE, the output suggests using zero_order = TRUE for Potency dataset. fit3 <- step1_down(data = potency, y = "Potency", .time = "Time",C = "Celsius", reparameterisation = FALSE, zero_order = TRUE, draw = 5000) #reparameterisation is TRUE. fit4 <- step1_down(data = antigenicity, y = "conc", .time = "time",C = "Celsius", reparameterisation = TRUE, draw = 5000)
#load antigenicity and potency data. data(antigenicity) data(potency) #Basic use of the step1.down function with C column defined. fit1 <- step1_down(data = antigenicity, y = "conc", .time = "time", C = "Celsius", draw = 5000) #Basic use of the step1.down function with K column defined. fit2 <- step1_down(data = antigenicity, y = "conc", .time = "time", K = "K", draw = 5000) #When zero_order = FALSE, the output suggests using zero_order = TRUE for Potency dataset. fit3 <- step1_down(data = potency, y = "Potency", .time = "Time",C = "Celsius", reparameterisation = FALSE, zero_order = TRUE, draw = 5000) #reparameterisation is TRUE. fit4 <- step1_down(data = antigenicity, y = "conc", .time = "time",C = "Celsius", reparameterisation = TRUE, draw = 5000)
Calculate Root Mean Square Error (RMSE) for the one-step Šesták–Berggren kinetic model.
step1_down_rmse( data, y, .time, K = NULL, C = NULL, parms, reparameterisation = FALSE )
step1_down_rmse( data, y, .time, K = NULL, C = NULL, parms, reparameterisation = FALSE )
data |
Dataframe containing accelerated stability data (required). |
y |
Name of decreasing variable (e.g. concentration) contained within data (required). |
.time |
Time variable contained within data (required). |
K |
Kelvin variable (numeric or column name) (optional). |
C |
Celsius variable (numeric or column name) (optional). |
parms |
Values for the parameters as a list - k1, k2, k3, and c0. If multiple are provided all combinations will be used (required). |
reparameterisation |
Use alternative parameterisation of the one-step model which aims to reduce correlation between k1 and k2. |
Calculate RMSE for the one-step Šesták–Berggren kinetic (non-linear) model using user provided parameters.
A data frame containing one row for each RMSE calculation
#load antigenicity and potency data. data(antigenicity) data(potency) #Basic use of the step1_down_rmse function with C column defined. rmse1 <- step1_down_rmse(data = antigenicity, y = "conc", .time = "time", C = "Celsius", parms = list(c0 = c(96,98,100), k1 = c(42,45), k2 = c(12000,12500), k3 = c(8,9,10))) #Basic use of the step1_down_rmse function with K column defined. rmse2 <- step1_down_rmse(data = antigenicity, y = "conc", .time = "time", K = "K", parms = list(c0 = c(98), k1 = c(42,45), k2 = c(12500), k3 = c(8,9))) #reparameterisation is TRUE. rmse3 <- step1_down_rmse(data = antigenicity, y = "conc", .time = "time", C = "Celsius", parms = list(c0 = c(100,95), k1 = c(2,2.5), k2 = c(12000,13000), k3 = c(9,10)), reparameterisation = TRUE)
#load antigenicity and potency data. data(antigenicity) data(potency) #Basic use of the step1_down_rmse function with C column defined. rmse1 <- step1_down_rmse(data = antigenicity, y = "conc", .time = "time", C = "Celsius", parms = list(c0 = c(96,98,100), k1 = c(42,45), k2 = c(12000,12500), k3 = c(8,9,10))) #Basic use of the step1_down_rmse function with K column defined. rmse2 <- step1_down_rmse(data = antigenicity, y = "conc", .time = "time", K = "K", parms = list(c0 = c(98), k1 = c(42,45), k2 = c(12500), k3 = c(8,9))) #reparameterisation is TRUE. rmse3 <- step1_down_rmse(data = antigenicity, y = "conc", .time = "time", C = "Celsius", parms = list(c0 = c(100,95), k1 = c(2,2.5), k2 = c(12000,13000), k3 = c(9,10)), reparameterisation = TRUE)
Plot the stability data and visualise the predictions with confidence intervals.
step1_plot_CI( step1_down_object, xname = NULL, yname = NULL, xlim = NULL, ylim = NULL, ribbon = FALSE )
step1_plot_CI( step1_down_object, xname = NULL, yname = NULL, xlim = NULL, ylim = NULL, ribbon = FALSE )
step1_down_object |
The fit object from the step1.down function (required). |
xname |
Label for the x-axis (optional). |
yname |
Label for the y-axis (optional). |
xlim |
x-axis limits (optional). |
ylim |
y-axis limits (optional). |
ribbon |
Add shade to confidence intervals (optional). |
Use the fit object obtained from the step1.down function to plot the data and visualise the predictions with confidence intervals applied. There is an option to view the confidence intervals as a ribbon. The confidence interval value is chosen in the step1.down function.
Plot of stability data with prediction curves and confidence intervals.
#load antigenciity data data(antigenicity) #run step1.down fit fit1 <- step1_down(data = antigenicity, y = "conc", .time = "time", C = "Celsius", max_time_pred = 3, confidence_interval = 0.9) #plot raw data with prediction curves and confidence intervals. step1_plot_CI(step1_down_object = fit1, xlim = NULL, ylim = NULL, xname = "Time (Years)", yname = "Concentration", ribbon = TRUE)
#load antigenciity data data(antigenicity) #run step1.down fit fit1 <- step1_down(data = antigenicity, y = "conc", .time = "time", C = "Celsius", max_time_pred = 3, confidence_interval = 0.9) #plot raw data with prediction curves and confidence intervals. step1_plot_CI(step1_down_object = fit1, xlim = NULL, ylim = NULL, xname = "Time (Years)", yname = "Concentration", ribbon = TRUE)
Plot raw accelerated stability data.
step1_plot_desc( data, y, .time, K = NULL, C = NULL, validation = NULL, xname = NULL, yname = NULL, xlim = NULL, ylim = NULL )
step1_plot_desc( data, y, .time, K = NULL, C = NULL, validation = NULL, xname = NULL, yname = NULL, xlim = NULL, ylim = NULL )
data |
Dataframe containing accelerated stability data. |
y |
Name of decreasing variable (e.g. concentration) contained within data |
.time |
Time variable contained within data. |
K |
Kelvin variable (numeric or column name) (optional). |
C |
Celsius variable (numeric or column name) (optional). |
validation |
Validation dummy variable (column name) (optional). |
xname |
Label for the x-axis (optional). |
yname |
Label for the y-axis (optional). |
xlim |
x-axis limits (optional). |
ylim |
y-axis limits (optional). |
Plot the raw accelerated stability data by selecting the columns - response, time and temperature.
Plot of raw accelerated stability data.
#load example datasets data(antigenicity) data(potency) step1_plot_desc(data=antigenicity, y="conc", .time="time", C = "Celsius") step1_plot_desc(data=potency, y="Potency", .time="Time", C = "Celsius")
#load example datasets data(antigenicity) data(potency) step1_plot_desc(data=antigenicity, y="conc", .time="time", C = "Celsius") step1_plot_desc(data=potency, y="Potency", .time="Time", C = "Celsius")
Generate residual diagnostic plots from a step1_down fit.
step1_plot_diagnostic(step1_down_object, bins = 7)
step1_plot_diagnostic(step1_down_object, bins = 7)
step1_down_object |
The fit object from the step1_down function (required). |
bins |
The number of bins in the Histogram plot (default 7). |
Use the fit object obtained from the step1_down function to plot the residual diagnostic plots, assess the quality of fit and search for anomalies. Plots created are: Residuals Histogram, Observed Vs Predicted results, Residuals Vs Predicted results and QQplot of Residuals.
A list containing the four ggplot2 plots.
#load antigenicity data data(antigenicity) #run step1_down fit fit1 <- step1_down(data = antigenicity, y = "conc", .time = "time", C = "Celsius", max_time_pred = 3) #plot diagnostic plots to asses the fit step1_plot_diagnostic(fit1)
#load antigenicity data data(antigenicity) #run step1_down fit fit1 <- step1_down(data = antigenicity, y = "conc", .time = "time", C = "Celsius", max_time_pred = 3) #plot diagnostic plots to asses the fit step1_plot_diagnostic(fit1)
Plot the stability data and visualise the predictions with prediction intervals.
step1_plot_PI( step1_down_object, xname = NULL, yname = NULL, xlim = NULL, ylim = NULL, ribbon = FALSE )
step1_plot_PI( step1_down_object, xname = NULL, yname = NULL, xlim = NULL, ylim = NULL, ribbon = FALSE )
step1_down_object |
The fit object from the step1.down function (required). |
xname |
Label for the x-axis (optional). |
yname |
Label for the y-axis (optional). |
xlim |
x-axis limits (optional). |
ylim |
y-axis limits (optional). |
ribbon |
Add shade to prediction intervals (optional). |
Use the fit object obtained from the step1.down function to plot the stability data and visualise the predictions with prediction intervals applied. There is an option to view the prediction intervals as a ribbon. The prediction interval value is chosen in the step1.down function.
Plot of stability data with prediction curves and prediction intervals.
#load antigenicity data data(antigenicity) #run step1.down fit fit1 <- step1_down(data = antigenicity, y = "conc", .time = "time", C = "Celsius", max_time_pred = 3) #plot raw data with prediction curves and prediction intervals. step1_plot_PI(step1_down_object = fit1, xlim = NULL, ylim = NULL, xname = "Time (Years)", yname = "Concentration", ribbon = TRUE)
#load antigenicity data data(antigenicity) #run step1.down fit fit1 <- step1_down(data = antigenicity, y = "conc", .time = "time", C = "Celsius", max_time_pred = 3) #plot raw data with prediction curves and prediction intervals. step1_plot_PI(step1_down_object = fit1, xlim = NULL, ylim = NULL, xname = "Time (Years)", yname = "Concentration", ribbon = TRUE)
Plot the stability data and visualise the predictions.
step1_plot_pred( step1_down_object, xname = NULL, yname = NULL, xlim = NULL, ylim = NULL )
step1_plot_pred( step1_down_object, xname = NULL, yname = NULL, xlim = NULL, ylim = NULL )
step1_down_object |
The fit object from the step1.down function (required). |
xname |
Label for the x-axis (optional). |
yname |
Label for the y-axis (optional). |
xlim |
x-axis limits (optional). |
ylim |
y-axis limits (optional). |
Use the fit object from the step1.down function to plot the accelerated stability data and visualise the predictions.
Plot of accelerated stability data with prediction curves.
#load antigenicity data data(antigenicity) fit1 <- step1_down(data = antigenicity, y = "conc", .time = "time", C = "Celsius", max_time_pred = 3) step1_plot_pred(step1_down_object = fit1, xlim = NULL, ylim = NULL, xname = "Time (Years)", yname = "Concentration")
#load antigenicity data data(antigenicity) fit1 <- step1_down(data = antigenicity, y = "conc", .time = "time", C = "Celsius", max_time_pred = 3) step1_plot_pred(step1_down_object = fit1, xlim = NULL, ylim = NULL, xname = "Time (Years)", yname = "Concentration")
Plot the stability data and visualise the predictions with focus on one temperature.
step1_plot_T( step1_down_object, focus_T = NULL, xname = NULL, yname = NULL, xlim = NULL, ylim = NULL, ribbon = FALSE )
step1_plot_T( step1_down_object, focus_T = NULL, xname = NULL, yname = NULL, xlim = NULL, ylim = NULL, ribbon = FALSE )
step1_down_object |
The fit object from the step1.down function (required). |
focus_T |
Selected temperature to highlight on the plot. |
xname |
Label for the x-axis (optional). |
yname |
Label for the y-axis (optional). |
xlim |
the x-axis limits (optional). |
ylim |
the y-axis limits (optional). |
ribbon |
adds shade to confidence and prediction intervals (optional). |
Plot the stability data and visualise the predictions focusing on one chosen temperature with confidence and prediction intervals.
ggplot2 object with focus on chosen temperature.
#load potency data data(potency) #run step1_down fit fit1 <- step1_down(data = potency, y = "Potency", .time = "Time", C = "Celsius", zero_order = TRUE) #plot raw data with prediction curves with focus on temperature in dataset. step1_plot_T(fit1, focus_T = 5,ribbon = TRUE, xlim = NULL, ylim = c(0,12), xname = "Time (Month)", yname = "Potency") #plot raw data with prediction curves with focus on temperature not in dataset. step1_plot_T(fit1, focus_T = -10,ribbon = TRUE, xlim = NULL, ylim = c(0,12), xname = "Time (Months)", yname = "Potency")
#load potency data data(potency) #run step1_down fit fit1 <- step1_down(data = potency, y = "Potency", .time = "Time", C = "Celsius", zero_order = TRUE) #plot raw data with prediction curves with focus on temperature in dataset. step1_plot_T(fit1, focus_T = 5,ribbon = TRUE, xlim = NULL, ylim = c(0,12), xname = "Time (Month)", yname = "Potency") #plot raw data with prediction curves with focus on temperature not in dataset. step1_plot_T(fit1, focus_T = -10,ribbon = TRUE, xlim = NULL, ylim = c(0,12), xname = "Time (Months)", yname = "Potency")
Take a selected number of samples from the multivariate t distribution (mvt).
step1_sample_mvt( data, y, .time, K = NULL, C = NULL, validation = NULL, draw, parms = NULL, reparameterisation = FALSE, zero_order = FALSE )
step1_sample_mvt( data, y, .time, K = NULL, C = NULL, validation = NULL, draw, parms = NULL, reparameterisation = FALSE, zero_order = FALSE )
data |
Dataframe containing accelerated stability data (required). |
y |
Name of decreasing variable (e.g. concentration) contained within data (required). |
.time |
Time variable contained within data (required). |
K |
Kelvin variable (numeric or column name) (optional). |
C |
Celsius variable (numeric or column name) (optional). |
validation |
Validation dummy variable (column name) (optional). |
draw |
Number of samples to draw from mvt (required). |
parms |
Starting values for the parameters as a list - k1, k2, k3, and c0 (optional). |
reparameterisation |
Use alternative parameterisation of the one-step model which aims to reduce correlation between k1 and k2. |
zero_order |
Set kinetic order, k3, to zero (straight lines). |
Using the provided data the function creates a fit of the Šesták–Berggren kinetic model and then draws a selected number of samples from the mvt of the model parameters.
A matrix containing parameter draws from the mvt distribution.
#load antigenicity data. data(antigenicity) #Basic use of the step1_sample_mvt function with C column defined and 1000 draws. sample1 <- step1_sample_mvt(data = antigenicity, y = "conc", .time = "time", C = "Celsius", draw = 1000) #Basic use of the step1_sample_mvt function with K column defined and 50000 draws sample2 <- step1_sample_mvt(data = antigenicity, y = "conc", .time = "time", K = "K", draw = 50000) #reparameterisation is TRUE and 10000 draws. sample3 <- step1_sample_mvt(data = antigenicity, y = "conc", .time = "time", C = "Celsius", reparameterisation = TRUE, draw = 10000)
#load antigenicity data. data(antigenicity) #Basic use of the step1_sample_mvt function with C column defined and 1000 draws. sample1 <- step1_sample_mvt(data = antigenicity, y = "conc", .time = "time", C = "Celsius", draw = 1000) #Basic use of the step1_sample_mvt function with K column defined and 50000 draws sample2 <- step1_sample_mvt(data = antigenicity, y = "conc", .time = "time", K = "K", draw = 50000) #reparameterisation is TRUE and 10000 draws. sample3 <- step1_sample_mvt(data = antigenicity, y = "conc", .time = "time", C = "Celsius", reparameterisation = TRUE, draw = 10000)