plot_expirest_osle {expirest} | R Documentation |
Illustrating the ordinary shelf life estimate (osle)
Description
The function plot_expirest_osle()
makes a graphical display of the
shelf life estimate done by the expirest_osle()
function.
Usage
plot_expirest_osle(
model,
show_grouping = "yes",
response_vbl_unit = NULL,
x_range = NULL,
y_range = NULL,
mtbs = "verified",
plot_option = "full",
ci_app = "line"
)
Arguments
model |
An ‘ |
show_grouping |
'r lifecycle::badge("deprecated")'
'show_grouping = \"yes\" or \"no\"' is no longer supported. Use the
|
response_vbl_unit |
A character string that specifies the unit
associated with the response variable. The default is |
x_range |
A numeric vector of the form |
y_range |
A numeric vector of the form |
mtbs |
A character string that specifies the “model to be shown”,
i.e. either |
plot_option |
A character string of either |
ci_app |
A character string of either |
Details
The function plot_expirest_osle()
uses the data and the
information about the linear model that was used for the estimation of
the shelf life by aid of the expirest_osle()
function. It
plots a graph of the time course of a parameter, a linear regression line
fitted to the data and the associated confidence or prediction interval.
In addition, it shows features of the shelf life estimation.
For plotting, the ggplot()
function from the
‘ggplot2
’ package is used. The various arguments can be
used to control the appearance of the plot. The ‘ggplot2
’
object of the generated plot is contained in the Graph
element of
the list that is returned by plot_expirest_osle()
and can be
used to modify the appearance of the graph.
Value
An object of class ‘plot_expirest_osle
’ is returned
invisibly consisting of the following elements:
Model |
The ‘ |
Expiry |
A data frame of type |
Graph |
A ‘ |
Prediction |
A data frame of the predicted values. |
text |
A data frame of the text elements on the plot. |
hlines |
A data frame of the horizontal line elements on the plot. |
vlines |
A data frame of the vertical line elements on the plot. |
See Also
expirest_osle
, expirest_wisle
,
plot_expirest_wisle
.
Examples
# Start by making an "ordinary shelf life estimation" (osle).
res1 <-
expirest_osle(data = exp1[exp1$Batch %in% c("b2", "b5", "b7"), ],
response_vbl = "Potency", time_vbl = "Month",
batch_vbl = "Batch", sl = 95, sl_sf = 3,
srch_range = c(0, 500), sf_option = "loose")
# Pass the 'expirest_osle' object on to the plot_expirest_osle() function.
# This function does not produce any output. It returns a 'plot_expirest_osle'
# object that is essentially an 'expirest_osle' object augmented by a 'ggplot'
# object.
gg1 <- plot_expirest_osle(
model = res1, response_vbl_unit = "%", x_range = NULL, y_range = c(93, 105),
mtbs = "verified", plot_option = "full", ci_app = "line")
## Not run:
gg1
# Since the element gg1$Graph is a 'ggplot' object it can be used for further
# manipulation by aid of 'ggplot2' functions.
if (requireNamespace("ggplot2")) {
library(ggplot2)
gg1$Graph + labs(title = "Ordinary Shelf Life Estimation (OSLE)",
x = "Time [months]", y = "Potency [% LC]") +
scale_x_continuous(limits = c(-1, 31), breaks = seq(0, 30, 6))
}
## End(Not run)
# Repeat this for a different intercept / different slope (dids) model.
res2 <-
expirest_osle(data = exp1[exp1$Batch %in% c("b4", "b5", "b8"), ],
response_vbl = "Potency", time_vbl = "Month",
batch_vbl = "Batch", sl = 95, sl_sf = 3,
srch_range = c(0, 500), sf_option = "loose")
gg2 <- plot_expirest_osle(
model = res2, response_vbl_unit = "%", x_range = c(0, 43),
y_range = c(83, 107), mtbs = "verified", plot_option = "full",
ci_app = "ribbon")
## Not run:
gg2
## End(Not run)
# In case of different intercept / different slope models, individually fit
# linear models are shown by default, i.e. with the 'mtbs' parameter set
# as "verified". To get the different intercept / different slope model
# displayed where the mean square error is pooled across batches, i.e. the
# dids.pmse model, the 'mtbs' parameter has to be set accordingly.
gg3 <- plot_expirest_osle(
model = res2, response_vbl_unit = "%", x_range = c(0, 43),
y_range = c(83, 107), mtbs = "dids.pmse", plot_option = "full",
ci_app = "ribbon")
## Not run:
gg3
## End(Not run)