| Title: | Progression Models for Repeated Measures |
|---|---|
| Description: | A progression model for repeated measures (PMRM) is a continuous-time nonlinear mixed-effects model for longitudinal clinical trials in progressive diseases. Unlike mixed models for repeated measures (MMRMs), which estimate treatment effects as linear combinations of additive effects on the outcome scale, PMRMs characterize treatment effects in terms of the underlying disease trajectory. This framing yields clinically interpretable quantities such as average time saved and percent reduction in decline due to treatment. This package implements frequentist PMRMs by Raket (2022) <doi:10.1002/sim.9581> using 'RTMB' by Kristensen (2016) <doi:10.18637/jss.v070.i05>. |
| Authors: | William Michael Landau [aut, cre] (ORCID: <https://orcid.org/0000-0003-1878-3253>), Lars Lau Raket [aut] (ORCID: <https://orcid.org/0000-0001-7099-2314>), Kasper Kristensen [aut] (ORCID: <https://orcid.org/0000-0003-3425-3762>), Eli Lilly and Company [cph, fnd] |
| Maintainer: | William Michael Landau <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.0.4.9000 |
| Built: | 2026-06-02 09:06:51 UTC |
| Source: | https://github.com/openpharma/pmrm |
Extract the Akaike information criterion (AIC) of a progression model for repeated measures (PMRM).
## S3 method for class 'pmrm_fit' AIC(object, ..., k = NULL)## S3 method for class 'pmrm_fit' AIC(object, ..., k = NULL)
object |
A fitted model object of class |
... |
Not used. |
k |
Not used. Must be |
Numeric scalar, the Akaike information criterion (AIC) of the fitted model.
Other model comparison:
BIC.pmrm_fit(),
confint.pmrm_fit(),
deviance.pmrm_fit(),
glance.pmrm_fit(),
logLik.pmrm_fit(),
summary.pmrm_fit()
set.seed(0L) simulation <- pmrm_simulate_decline_proportional( visit_times = seq_len(5L) - 1, gamma = c(1, 2) ) fit <- pmrm_model_decline_proportional( data = simulation, outcome = "y", time = "t", patient = "patient", visit = "visit", arm = "arm", covariates = ~ w_1 + w_2 ) AIC(fit)set.seed(0L) simulation <- pmrm_simulate_decline_proportional( visit_times = seq_len(5L) - 1, gamma = c(1, 2) ) fit <- pmrm_model_decline_proportional( data = simulation, outcome = "y", time = "t", patient = "patient", visit = "visit", arm = "arm", covariates = ~ w_1 + w_2 ) AIC(fit)
Extract the Bayesian information criterion (BIC) of a progression model for repeated measures (PMRM).
## S3 method for class 'pmrm_fit' BIC(object, ..., k = NULL)## S3 method for class 'pmrm_fit' BIC(object, ..., k = NULL)
object |
A fitted model object of class |
... |
Not used. |
k |
Not used. Must be |
Numeric scalar, the Bayesian information criterion (BIC) of the fitted model.
Other model comparison:
AIC.pmrm_fit(),
confint.pmrm_fit(),
deviance.pmrm_fit(),
glance.pmrm_fit(),
logLik.pmrm_fit(),
summary.pmrm_fit()
set.seed(0L) simulation <- pmrm_simulate_decline_proportional( visit_times = seq_len(5L) - 1, gamma = c(1, 2) ) fit <- pmrm_model_decline_proportional( data = simulation, outcome = "y", time = "t", patient = "patient", visit = "visit", arm = "arm", covariates = ~ w_1 + w_2 ) BIC(fit)set.seed(0L) simulation <- pmrm_simulate_decline_proportional( visit_times = seq_len(5L) - 1, gamma = c(1, 2) ) fit <- pmrm_model_decline_proportional( data = simulation, outcome = "y", time = "t", patient = "patient", visit = "visit", arm = "arm", covariates = ~ w_1 + w_2 ) BIC(fit)
Extract the theta parameter
from a progression model for repeated measures.
## S3 method for class 'pmrm_fit' coef(object, ...)## S3 method for class 'pmrm_fit' coef(object, ...)
object |
A fitted model object of class |
... |
Not used. |
See vignette("models", package = "pmrm") for details.
For proportional models, a named vector of theta estimates
with one element for each active study arm.
For non-proportional models, a named matrix of theta with one
row for each active study arm and one column for each
post-baseline scheduled visit. Elements, rows, and columns are
named with arm/visit names as appropriate.
Other estimates:
VarCorr.pmrm_fit(),
pmrm_marginals(),
tidy.pmrm_fit(),
vcov.pmrm_fit()
set.seed(0L) simulation <- pmrm_simulate_decline_proportional( visit_times = seq_len(5L) - 1, gamma = c(1, 2) ) fit <- pmrm_model_decline_proportional( data = simulation, outcome = "y", time = "t", patient = "patient", visit = "visit", arm = "arm", covariates = ~ w_1 + w_2 ) coef(fit)set.seed(0L) simulation <- pmrm_simulate_decline_proportional( visit_times = seq_len(5L) - 1, gamma = c(1, 2) ) fit <- pmrm_model_decline_proportional( data = simulation, outcome = "y", time = "t", patient = "patient", visit = "visit", arm = "arm", covariates = ~ w_1 + w_2 ) coef(fit)
Compute confidence intervals of the family of model
parameters specified in parm.
## S3 method for class 'pmrm_fit' confint(object, parm = NULL, level = 0.95, ...)## S3 method for class 'pmrm_fit' confint(object, parm = NULL, level = 0.95, ...)
object |
a fitted model object. |
parm |
a specification of which parameters are to be given confidence intervals, either a vector of numbers or a vector of names. If missing, all parameters are considered. |
level |
the confidence level required. |
... |
additional argument(s) for methods. |
See vignette("models", package = "pmrm") for details.
A numeric matrix with one row for each treatment effect
parameter (theta) and named columns with the lower and upper
bounds of 2-sided confidence intervals on the parameters.
Other model comparison:
AIC.pmrm_fit(),
BIC.pmrm_fit(),
deviance.pmrm_fit(),
glance.pmrm_fit(),
logLik.pmrm_fit(),
summary.pmrm_fit()
set.seed(0L) simulation <- pmrm_simulate_decline_proportional( visit_times = seq_len(5L) - 1, gamma = c(1, 2) ) fit <- pmrm_model_decline_proportional( data = simulation, outcome = "y", time = "t", patient = "patient", visit = "visit", arm = "arm", covariates = ~ w_1 + w_2 ) confint(fit)set.seed(0L) simulation <- pmrm_simulate_decline_proportional( visit_times = seq_len(5L) - 1, gamma = c(1, 2) ) fit <- pmrm_model_decline_proportional( data = simulation, outcome = "y", time = "t", patient = "patient", visit = "visit", arm = "arm", covariates = ~ w_1 + w_2 ) confint(fit)
Extract the deviance
(defined here as -2 * log_likelihood)
of a fitted progression model for repeated measures.
## S3 method for class 'pmrm_fit' deviance(object, ...)## S3 method for class 'pmrm_fit' deviance(object, ...)
object |
A fitted model object of class |
... |
Not used. |
Numeric scalar, the deviance.
Other model comparison:
AIC.pmrm_fit(),
BIC.pmrm_fit(),
confint.pmrm_fit(),
glance.pmrm_fit(),
logLik.pmrm_fit(),
summary.pmrm_fit()
set.seed(0L) simulation <- pmrm_simulate_decline_proportional( visit_times = seq_len(5L) - 1, gamma = c(1, 2) ) fit <- pmrm_model_decline_proportional( data = simulation, outcome = "y", time = "t", patient = "patient", visit = "visit", arm = "arm", covariates = ~ w_1 + w_2 ) deviance(fit)set.seed(0L) simulation <- pmrm_simulate_decline_proportional( visit_times = seq_len(5L) - 1, gamma = c(1, 2) ) fit <- pmrm_model_decline_proportional( data = simulation, outcome = "y", time = "t", patient = "patient", visit = "visit", arm = "arm", covariates = ~ w_1 + w_2 ) deviance(fit)
Compute the fitted values of a fitted progression model for repeated measures.
## S3 method for class 'pmrm_fit' fitted(object, adjust = TRUE, ...)## S3 method for class 'pmrm_fit' fitted(object, adjust = TRUE, ...)
object |
A fitted model object of class |
adjust |
|
... |
Not used. |
For pmrm, fitted() is much faster than predict()
for large datasets, but the output only includes the estimates
(no measures of uncertainty).
A numeric vector of fitted values corresponding to the
rows of the data in object$data.
Other predictions:
predict.pmrm_fit(),
residuals.pmrm_fit()
set.seed(0L) simulation <- pmrm_simulate_decline_proportional( visit_times = seq_len(5L) - 1, gamma = c(1, 2) ) fit <- pmrm_model_decline_proportional( data = simulation, outcome = "y", time = "t", patient = "patient", visit = "visit", arm = "arm", covariates = ~ w_1 + w_2 ) str(fitted(fit))set.seed(0L) simulation <- pmrm_simulate_decline_proportional( visit_times = seq_len(5L) - 1, gamma = c(1, 2) ) fit <- pmrm_model_decline_proportional( data = simulation, outcome = "y", time = "t", patient = "patient", visit = "visit", arm = "arm", covariates = ~ w_1 + w_2 ) str(fitted(fit))
Return a one-row tibble of model comparison metrics
for a fitted PMRM.
## S3 method for class 'pmrm_fit' glance(x, ...)## S3 method for class 'pmrm_fit' glance(x, ...)
x |
A fitted model x of class |
... |
Not used. |
A tibble with one row and columns with the following columns:
model: "decline" or "slowing".
parameterization: "proportional" or "nonproportional".
n_observations: number of non-missing observations in the data.
n_parameters: number of true model parameters.
log_likelihood: maximized log likelihood of the model fit.
deviance: deviance of the fitted model, defined here as
-2 * log_likelihood.
aic: Akaike information criterion.
bic: Bayesian information criterion.
This format is designed for easy comparison of multiple fitted models.
Other model comparison:
AIC.pmrm_fit(),
BIC.pmrm_fit(),
confint.pmrm_fit(),
deviance.pmrm_fit(),
logLik.pmrm_fit(),
summary.pmrm_fit()
set.seed(0L) simulation <- pmrm_simulate_decline_proportional( visit_times = seq_len(5L) - 1, gamma = c(1, 2) ) fit <- pmrm_model_decline_proportional( data = simulation, outcome = "y", time = "t", patient = "patient", visit = "visit", arm = "arm", covariates = ~ w_1 + w_2 ) glance(fit)set.seed(0L) simulation <- pmrm_simulate_decline_proportional( visit_times = seq_len(5L) - 1, gamma = c(1, 2) ) fit <- pmrm_model_decline_proportional( data = simulation, outcome = "y", time = "t", patient = "patient", visit = "visit", arm = "arm", covariates = ~ w_1 + w_2 ) glance(fit)
Extract the maximized log likelihood of a progression model for repeated measures (PMRM).
## S3 method for class 'pmrm_fit' logLik(object, ...)## S3 method for class 'pmrm_fit' logLik(object, ...)
object |
A fitted model object of class |
... |
Not used. |
Numeric scalar, the maximized log likelihood of the fitted model.
Other model comparison:
AIC.pmrm_fit(),
BIC.pmrm_fit(),
confint.pmrm_fit(),
deviance.pmrm_fit(),
glance.pmrm_fit(),
summary.pmrm_fit()
set.seed(0L) simulation <- pmrm_simulate_decline_proportional( visit_times = seq_len(5L) - 1, gamma = c(1, 2) ) fit <- pmrm_model_decline_proportional( data = simulation, outcome = "y", time = "t", patient = "patient", visit = "visit", arm = "arm", covariates = ~ w_1 + w_2 ) logLik(fit)set.seed(0L) simulation <- pmrm_simulate_decline_proportional( visit_times = seq_len(5L) - 1, gamma = c(1, 2) ) fit <- pmrm_model_decline_proportional( data = simulation, outcome = "y", time = "t", patient = "patient", visit = "visit", arm = "arm", covariates = ~ w_1 + w_2 ) logLik(fit)
Plot a fitted progression model for repeated measures (PMRM) against the data.
## S3 method for class 'pmrm_fit' plot( x, y = NULL, ..., confidence = 0.95, show_data = TRUE, show_marginals = TRUE, show_predictions = FALSE, facet = TRUE, alpha = 0.25 )## S3 method for class 'pmrm_fit' plot( x, y = NULL, ..., confidence = 0.95, show_data = TRUE, show_marginals = TRUE, show_predictions = FALSE, facet = TRUE, alpha = 0.25 )
x |
A fitted model object of class |
y |
Not used. |
... |
Not used. |
confidence |
Numeric between 0 and 1, the confidence level to use in the 2-sided confidence intervals. |
show_data |
|
show_marginals |
|
show_predictions |
|
facet |
|
alpha |
Numeric between 0 and 1, opacity level of the model-based confidence bands. |
The plot shows the following elements:
Raw estimates and confidence intervals on the data, as boxes
(if show_data is TRUE).
Model-based estimates and confidence intervals as points and error
bars, respectively
(if show_marginals is TRUE).
Continuous model-based estimates and confidence bands as lines
and shaded regions, respectively
(if show_predictions is TRUE).
A ggplot object with the plot.
Other visualization:
print.pmrm_fit()
set.seed(0L) simulation <- pmrm_simulate_decline_proportional( visit_times = seq_len(5L) - 1, gamma = c(1, 2) ) fit <- pmrm_model_decline_proportional( data = simulation, outcome = "y", time = "t", patient = "patient", visit = "visit", arm = "arm", covariates = ~ w_1 + w_2 ) plot(fit)set.seed(0L) simulation <- pmrm_simulate_decline_proportional( visit_times = seq_len(5L) - 1, gamma = c(1, 2) ) fit <- pmrm_model_decline_proportional( data = simulation, outcome = "y", time = "t", patient = "patient", visit = "visit", arm = "arm", covariates = ~ w_1 + w_2 ) plot(fit)
Report parameter estimates and confidence intervals for a progression model for repeated measures (PMRM).
pmrm_estimates( fit, parameter = c("theta", "beta", "alpha", "gamma", "sigma", "phi", "rho", "Sigma", "Lambda"), confidence = 0.95 )pmrm_estimates( fit, parameter = c("theta", "beta", "alpha", "gamma", "sigma", "phi", "rho", "Sigma", "Lambda"), confidence = 0.95 )
fit |
A fitted model object of class |
parameter |
Character string, name of the type of model
parameter to summarize. Must be one of |
confidence |
Numeric between 0 and 1, the confidence level to use in 2-sided normal confidence intervals. |
A tibble with one row for each scalar element of the
selected model parameter and columns with estimates,
standard errors, lower and upper bounds of two-sided
normal confidence intervals, and indexing variables.
If applicable, the indexing variables are arm and/or visit
to indicate the study arm and study visit.
If there is no obvious indexing factor in the data,
then a generic integer index column is used.
For covariance matrices, elements are identified with the
visit_row and visit_column columns.
beta is not a true parameter.
Instead, it is a function of theta and fixed at zero
for the control arm and at baseline.
At these marginals,
the standard errors and confidence intervals for beta are NA_real_.
set.seed(0L) simulation <- pmrm_simulate_decline_nonproportional( visit_times = seq_len(5L) - 1, gamma = c(1, 2) ) fit <- pmrm_model_decline_nonproportional( data = simulation, outcome = "y", time = "t", patient = "patient", visit = "visit", arm = "arm", covariates = ~ w_1 + w_2 ) pmrm_estimates(fit, parameter = "beta") pmrm_estimates(fit, parameter = "alpha")set.seed(0L) simulation <- pmrm_simulate_decline_nonproportional( visit_times = seq_len(5L) - 1, gamma = c(1, 2) ) fit <- pmrm_model_decline_nonproportional( data = simulation, outcome = "y", time = "t", patient = "patient", visit = "visit", arm = "arm", covariates = ~ w_1 + w_2 ) pmrm_estimates(fit, parameter = "beta") pmrm_estimates(fit, parameter = "alpha")
Report the estimates and standard errors of marginal means
at each study arm and visit. The assumed visit times should have been
given in the marginals argument of the model-fitting function.
Use the type argument to choose
marginal means of the outcomes, marginal estimates of change from
baseline, and marginal estimates of treatment effects.
pmrm_marginals(fit, type = c("outcome", "change", "effect"), confidence = 0.95)pmrm_marginals(fit, type = c("outcome", "change", "effect"), confidence = 0.95)
fit |
A |
type |
Character string, type of marginal mean to report. Choices:
|
confidence |
A numeric from 0 to 1 with the confidence level for confidence intervals. |
A tibble with one row per marginal mean and columns with the
estimate, standard error, 2-sided confidence bounds, and indicator
columns.
Some estimates, standard errors, and confidence bounds may be NA_real_
if they correspond to the reference level subtracted out in
change-from-baseline or treatment effect calculations.
Other estimates:
VarCorr.pmrm_fit(),
coef.pmrm_fit(),
tidy.pmrm_fit(),
vcov.pmrm_fit()
set.seed(0L) simulation <- pmrm_simulate_decline_proportional( visit_times = seq_len(5L) - 1, gamma = c(1, 2) ) fit <- pmrm_model_decline_proportional( data = simulation, outcome = "y", time = "t", patient = "patient", visit = "visit", arm = "arm", covariates = ~ w_1 + w_2 ) pmrm_marginals(fit)set.seed(0L) simulation <- pmrm_simulate_decline_proportional( visit_times = seq_len(5L) - 1, gamma = c(1, 2) ) fit <- pmrm_model_decline_proportional( data = simulation, outcome = "y", time = "t", patient = "patient", visit = "visit", arm = "arm", covariates = ~ w_1 + w_2 ) pmrm_marginals(fit)
Fit the non-proportional decline model to a clinical dataset on a progressive disease.
pmrm_model_decline_nonproportional( data, outcome, time, patient, visit, arm, covariates = ~0, visit_times = NULL, spline_knots = visit_times, spline_method = c("natural", "fmm"), reml = FALSE, hessian = c("divergence", "never", "always"), saddle = FALSE, control = list(eval.max = 4000L, iter.max = 4000L), initial_method = c("regression", "regression_control", "zero"), initial = NULL, silent = TRUE )pmrm_model_decline_nonproportional( data, outcome, time, patient, visit, arm, covariates = ~0, visit_times = NULL, spline_knots = visit_times, spline_method = c("natural", "fmm"), reml = FALSE, hessian = c("divergence", "never", "always"), saddle = FALSE, control = list(eval.max = 4000L, iter.max = 4000L), initial_method = c("regression", "regression_control", "zero"), initial = NULL, silent = TRUE )
data |
A data frame or |
outcome |
Character string, name of the column in the data
with the numeric outcome variable on the continuous scale.
Could be a clinical measure of healthy or of disease severity.
Baseline is part of the model, so the |
time |
Character string, name of the column in the data with the numeric time variable on the continuous scale. This time is the time since enrollment/randomization of each patient. A time value of 0 should indicate baseline. |
patient |
Character string, name of the column in the data
with the patient ID.
This vector could be a numeric, integer, factor, or character vector.
|
visit |
Character string, name of the column in the
data which indicates the study visit of each row.
This column could be a numeric, integer, factor, or character vector.
An ordered factor is highly recommended because |
arm |
Character string, name of the column in the
data which indicates the study arm of each row.
This column could be a numeric, integer, factor, or character vector.
An ordered factor is highly recommended because |
covariates |
Partial right-sided formula
of concomitant terms in the model
for covariate adjustment (e.g. by age, gender, biomarker status, etc.).
Usually does not include main variables such as the values of
The columns in the data referenced in the formula must not have any missing values. Set |
visit_times |
Numeric vector, the continuous scheduled time
of each study visit (since baseline/randomization).
If |
spline_knots |
Numeric vector of spline knots on the continuous scale, including boundary knots. |
spline_method |
Character string, spline method to use for the base model.
Must be |
reml |
|
hessian |
Character string controlling
when to supply the Hessian matrix
of the objective function to the optimizer The The
|
saddle |
|
control |
A named list of control parameters passed directly to the
|
initial_method |
Character string, name of the method
for computing initial values.
Ignored unless
|
initial |
If If
You can generate an example of the format of this list
by fitting a test model
(e.g. |
silent |
As MakeADFun. |
See vignette("models", package = "pmrm") for details.
A pmrm fit object of class c("pmrm_fit_decline", "pmrm_fit").
For details, see the "pmrm fit objects" section of this help file.
A "pmrm_fit" object is a classed list returned by modeling functions.
It has the following named elements:
data: a tibble, the input data with
the missing outcomes removed and the remaining rows
sorted by patient and visit within patient.
The data has a special "pmrm_data" class and should
not be modified by the user.
constants: a list of fixed quantities from the data
that the objective function uses in the optimization.
Most of these quantities are defined in the modeling and
simulation vignettes in the pmrm package.
n_visits is a positive integer vector with the number
of non-missing outcomes for each patient.
options: a list of low-level model-fitting options for RTMB.
objective: the objective function for the optimization.
Returns the minus log likelihood of the model.
The arguments are (1) a list of constants,
and (2) a list of model parameters.
Both arguments have strict formatting requirements.
For (1), see the constants element of the fitted model object.
For (2), see initial or final.
model$fn (from the model element of the fitted model object)
contains a copy of the objective function that only takes
a parameter list.
(The constants are in the closure of model$fn.)
model: model object returned by RTMB::MakeADFun()
with the compiled objective function and gradient.
The elements can be supplied to an optimization routine in R
such as stats::nlminb().
optimization: the object returned by stats::nlminb() to perform
the optimization that estimates the parameters.
optimization$convergence equals 0
if an only if the model converges.
report: object returned by RTMB::sdreport() which has information
on the standard deviations of model parameters.
initial: a list of model parameters initial values.
Includes true parameters like theta and alpha but does not
include derived parameters like beta or sigma.
You can supply your own list of similarly formatted initial values
to the initial argument of the modeling function you choose.
final: a list of model parameter estimates after optimization,
but not including derived parameters like beta or sigma.
The format is exactly the same as initial (see above)
to help deal with divergent model fits.
If your model fit diverged and you want to try resume the optimization
with slightly better values, you can modify values in final
and supply the result to the initial argument of the modeling function.
estimates: a full list of parameter estimates, including derived
parameters
standard_errors: a list of parameter standard errors.
metrics: a list of high-level model metrics, including:
n_observations: positive integer scalar,
number of non-missing observations in the data.
n_parameters: positive integer scalar,
number of model parameters in the data.
Includes true parameters like theta
but excludes downstream functions
of parameters such as beta.
log_likelihood: numeric scalar,
the maximized log likelihood of the fitted model.
deviance: deviance of the fitted model,
defined here as -2 * log_likelihood.
aic: numeric scalar, the Akaike information
criterion of the fitted model.
bic: numeric scalar, the Bayesian information
criterion of the fitted model.
spline: a vectorized function that accepts continuous time x
and returns the value of the fitted spline f(x | spline_knots, alpha) at time x
given the user-specified knots spline_knots and the
maximum likelihood estimates of alpha.
Useful for diagnosing strange behavior in the fitted spline.
If the spline behaves oddly,
especially extrapolating beyond the range of the
time points, please consider adjusting
the knots spline_knots or the initial values of alpha
when refitting the model.
Other models:
pmrm_model_decline_proportional(),
pmrm_model_slowing_nonproportional(),
pmrm_model_slowing_proportional()
set.seed(0L) simulation <- pmrm_simulate_decline_nonproportional( visit_times = seq_len(5L) - 1, gamma = c(1, 2) ) fit <- pmrm_model_decline_nonproportional( data = simulation, outcome = "y", time = "t", patient = "patient", visit = "visit", arm = "arm", covariates = ~ w_1 + w_2 ) str(fit$estimates) names(fit)set.seed(0L) simulation <- pmrm_simulate_decline_nonproportional( visit_times = seq_len(5L) - 1, gamma = c(1, 2) ) fit <- pmrm_model_decline_nonproportional( data = simulation, outcome = "y", time = "t", patient = "patient", visit = "visit", arm = "arm", covariates = ~ w_1 + w_2 ) str(fit$estimates) names(fit)
Fit the proportional decline model to a clinical dataset on a progressive disease.
pmrm_model_decline_proportional( data, outcome, time, patient, visit, arm, covariates = ~0, visit_times = NULL, spline_knots = visit_times, spline_method = c("natural", "fmm"), reml = FALSE, hessian = c("divergence", "never", "always"), saddle = FALSE, control = list(eval.max = 4000L, iter.max = 4000L), initial_method = c("regression", "regression_control", "zero"), initial = NULL, silent = TRUE )pmrm_model_decline_proportional( data, outcome, time, patient, visit, arm, covariates = ~0, visit_times = NULL, spline_knots = visit_times, spline_method = c("natural", "fmm"), reml = FALSE, hessian = c("divergence", "never", "always"), saddle = FALSE, control = list(eval.max = 4000L, iter.max = 4000L), initial_method = c("regression", "regression_control", "zero"), initial = NULL, silent = TRUE )
data |
A data frame or |
outcome |
Character string, name of the column in the data
with the numeric outcome variable on the continuous scale.
Could be a clinical measure of healthy or of disease severity.
Baseline is part of the model, so the |
time |
Character string, name of the column in the data with the numeric time variable on the continuous scale. This time is the time since enrollment/randomization of each patient. A time value of 0 should indicate baseline. |
patient |
Character string, name of the column in the data
with the patient ID.
This vector could be a numeric, integer, factor, or character vector.
|
visit |
Character string, name of the column in the
data which indicates the study visit of each row.
This column could be a numeric, integer, factor, or character vector.
An ordered factor is highly recommended because |
arm |
Character string, name of the column in the
data which indicates the study arm of each row.
This column could be a numeric, integer, factor, or character vector.
An ordered factor is highly recommended because |
covariates |
Partial right-sided formula
of concomitant terms in the model
for covariate adjustment (e.g. by age, gender, biomarker status, etc.).
Usually does not include main variables such as the values of
The columns in the data referenced in the formula must not have any missing values. Set |
visit_times |
Numeric vector, the continuous scheduled time
of each study visit (since baseline/randomization).
If |
spline_knots |
Numeric vector of spline knots on the continuous scale, including boundary knots. |
spline_method |
Character string, spline method to use for the base model.
Must be |
reml |
|
hessian |
Character string controlling
when to supply the Hessian matrix
of the objective function to the optimizer The The
|
saddle |
|
control |
A named list of control parameters passed directly to the
|
initial_method |
Character string, name of the method
for computing initial values.
Ignored unless
|
initial |
If If
You can generate an example of the format of this list
by fitting a test model
(e.g. |
silent |
As MakeADFun. |
See vignette("models", package = "pmrm") for details.
A pmrm fit object of class c("pmrm_fit_decline", "pmrm_fit").
For details, see the "pmrm fit objects" section of this help file.
A "pmrm_fit" object is a classed list returned by modeling functions.
It has the following named elements:
data: a tibble, the input data with
the missing outcomes removed and the remaining rows
sorted by patient and visit within patient.
The data has a special "pmrm_data" class and should
not be modified by the user.
constants: a list of fixed quantities from the data
that the objective function uses in the optimization.
Most of these quantities are defined in the modeling and
simulation vignettes in the pmrm package.
n_visits is a positive integer vector with the number
of non-missing outcomes for each patient.
options: a list of low-level model-fitting options for RTMB.
objective: the objective function for the optimization.
Returns the minus log likelihood of the model.
The arguments are (1) a list of constants,
and (2) a list of model parameters.
Both arguments have strict formatting requirements.
For (1), see the constants element of the fitted model object.
For (2), see initial or final.
model$fn (from the model element of the fitted model object)
contains a copy of the objective function that only takes
a parameter list.
(The constants are in the closure of model$fn.)
model: model object returned by RTMB::MakeADFun()
with the compiled objective function and gradient.
The elements can be supplied to an optimization routine in R
such as stats::nlminb().
optimization: the object returned by stats::nlminb() to perform
the optimization that estimates the parameters.
optimization$convergence equals 0
if an only if the model converges.
report: object returned by RTMB::sdreport() which has information
on the standard deviations of model parameters.
initial: a list of model parameters initial values.
Includes true parameters like theta and alpha but does not
include derived parameters like beta or sigma.
You can supply your own list of similarly formatted initial values
to the initial argument of the modeling function you choose.
final: a list of model parameter estimates after optimization,
but not including derived parameters like beta or sigma.
The format is exactly the same as initial (see above)
to help deal with divergent model fits.
If your model fit diverged and you want to try resume the optimization
with slightly better values, you can modify values in final
and supply the result to the initial argument of the modeling function.
estimates: a full list of parameter estimates, including derived
parameters
standard_errors: a list of parameter standard errors.
metrics: a list of high-level model metrics, including:
n_observations: positive integer scalar,
number of non-missing observations in the data.
n_parameters: positive integer scalar,
number of model parameters in the data.
Includes true parameters like theta
but excludes downstream functions
of parameters such as beta.
log_likelihood: numeric scalar,
the maximized log likelihood of the fitted model.
deviance: deviance of the fitted model,
defined here as -2 * log_likelihood.
aic: numeric scalar, the Akaike information
criterion of the fitted model.
bic: numeric scalar, the Bayesian information
criterion of the fitted model.
spline: a vectorized function that accepts continuous time x
and returns the value of the fitted spline f(x | spline_knots, alpha) at time x
given the user-specified knots spline_knots and the
maximum likelihood estimates of alpha.
Useful for diagnosing strange behavior in the fitted spline.
If the spline behaves oddly,
especially extrapolating beyond the range of the
time points, please consider adjusting
the knots spline_knots or the initial values of alpha
when refitting the model.
Other models:
pmrm_model_decline_nonproportional(),
pmrm_model_slowing_nonproportional(),
pmrm_model_slowing_proportional()
set.seed(0L) simulation <- pmrm_simulate_decline_proportional( visit_times = seq_len(5L) - 1, gamma = c(1, 2) ) fit <- pmrm_model_decline_proportional( data = simulation, outcome = "y", time = "t", patient = "patient", visit = "visit", arm = "arm", covariates = ~ w_1 + w_2 ) str(fit$estimates) names(fit)set.seed(0L) simulation <- pmrm_simulate_decline_proportional( visit_times = seq_len(5L) - 1, gamma = c(1, 2) ) fit <- pmrm_model_decline_proportional( data = simulation, outcome = "y", time = "t", patient = "patient", visit = "visit", arm = "arm", covariates = ~ w_1 + w_2 ) str(fit$estimates) names(fit)
Fit the non-proportional slowing model to a clinical dataset on a progressive disease.
pmrm_model_slowing_nonproportional( data, outcome, time, patient, visit, arm, covariates = ~0, visit_times = NULL, spline_knots = visit_times, spline_method = c("natural", "fmm"), reml = FALSE, hessian = c("divergence", "never", "always"), saddle = FALSE, control = list(eval.max = 4000L, iter.max = 4000L), initial_method = c("regression", "regression_control", "zero"), initial = NULL, silent = TRUE )pmrm_model_slowing_nonproportional( data, outcome, time, patient, visit, arm, covariates = ~0, visit_times = NULL, spline_knots = visit_times, spline_method = c("natural", "fmm"), reml = FALSE, hessian = c("divergence", "never", "always"), saddle = FALSE, control = list(eval.max = 4000L, iter.max = 4000L), initial_method = c("regression", "regression_control", "zero"), initial = NULL, silent = TRUE )
data |
A data frame or |
outcome |
Character string, name of the column in the data
with the numeric outcome variable on the continuous scale.
Could be a clinical measure of healthy or of disease severity.
Baseline is part of the model, so the |
time |
Character string, name of the column in the data with the numeric time variable on the continuous scale. This time is the time since enrollment/randomization of each patient. A time value of 0 should indicate baseline. |
patient |
Character string, name of the column in the data
with the patient ID.
This vector could be a numeric, integer, factor, or character vector.
|
visit |
Character string, name of the column in the
data which indicates the study visit of each row.
This column could be a numeric, integer, factor, or character vector.
An ordered factor is highly recommended because |
arm |
Character string, name of the column in the
data which indicates the study arm of each row.
This column could be a numeric, integer, factor, or character vector.
An ordered factor is highly recommended because |
covariates |
Partial right-sided formula
of concomitant terms in the model
for covariate adjustment (e.g. by age, gender, biomarker status, etc.).
Usually does not include main variables such as the values of
The columns in the data referenced in the formula must not have any missing values. Set |
visit_times |
Numeric vector, the continuous scheduled time
of each study visit (since baseline/randomization).
If |
spline_knots |
Numeric vector of spline knots on the continuous scale, including boundary knots. |
spline_method |
Character string, spline method to use for the base model.
Must be |
reml |
|
hessian |
Character string controlling
when to supply the Hessian matrix
of the objective function to the optimizer The The
|
saddle |
|
control |
A named list of control parameters passed directly to the
|
initial_method |
Character string, name of the method
for computing initial values.
Ignored unless
|
initial |
If If
You can generate an example of the format of this list
by fitting a test model
(e.g. |
silent |
As MakeADFun. |
See vignette("models", package = "pmrm") for details.
A pmrm fit object of class c("pmrm_fit_slowing", "pmrm_fit").
For details, see the "pmrm fit objects" section of this help file.
A "pmrm_fit" object is a classed list returned by modeling functions.
It has the following named elements:
data: a tibble, the input data with
the missing outcomes removed and the remaining rows
sorted by patient and visit within patient.
The data has a special "pmrm_data" class and should
not be modified by the user.
constants: a list of fixed quantities from the data
that the objective function uses in the optimization.
Most of these quantities are defined in the modeling and
simulation vignettes in the pmrm package.
n_visits is a positive integer vector with the number
of non-missing outcomes for each patient.
options: a list of low-level model-fitting options for RTMB.
objective: the objective function for the optimization.
Returns the minus log likelihood of the model.
The arguments are (1) a list of constants,
and (2) a list of model parameters.
Both arguments have strict formatting requirements.
For (1), see the constants element of the fitted model object.
For (2), see initial or final.
model$fn (from the model element of the fitted model object)
contains a copy of the objective function that only takes
a parameter list.
(The constants are in the closure of model$fn.)
model: model object returned by RTMB::MakeADFun()
with the compiled objective function and gradient.
The elements can be supplied to an optimization routine in R
such as stats::nlminb().
optimization: the object returned by stats::nlminb() to perform
the optimization that estimates the parameters.
optimization$convergence equals 0
if an only if the model converges.
report: object returned by RTMB::sdreport() which has information
on the standard deviations of model parameters.
initial: a list of model parameters initial values.
Includes true parameters like theta and alpha but does not
include derived parameters like beta or sigma.
You can supply your own list of similarly formatted initial values
to the initial argument of the modeling function you choose.
final: a list of model parameter estimates after optimization,
but not including derived parameters like beta or sigma.
The format is exactly the same as initial (see above)
to help deal with divergent model fits.
If your model fit diverged and you want to try resume the optimization
with slightly better values, you can modify values in final
and supply the result to the initial argument of the modeling function.
estimates: a full list of parameter estimates, including derived
parameters
standard_errors: a list of parameter standard errors.
metrics: a list of high-level model metrics, including:
n_observations: positive integer scalar,
number of non-missing observations in the data.
n_parameters: positive integer scalar,
number of model parameters in the data.
Includes true parameters like theta
but excludes downstream functions
of parameters such as beta.
log_likelihood: numeric scalar,
the maximized log likelihood of the fitted model.
deviance: deviance of the fitted model,
defined here as -2 * log_likelihood.
aic: numeric scalar, the Akaike information
criterion of the fitted model.
bic: numeric scalar, the Bayesian information
criterion of the fitted model.
spline: a vectorized function that accepts continuous time x
and returns the value of the fitted spline f(x | spline_knots, alpha) at time x
given the user-specified knots spline_knots and the
maximum likelihood estimates of alpha.
Useful for diagnosing strange behavior in the fitted spline.
If the spline behaves oddly,
especially extrapolating beyond the range of the
time points, please consider adjusting
the knots spline_knots or the initial values of alpha
when refitting the model.
Other models:
pmrm_model_decline_nonproportional(),
pmrm_model_decline_proportional(),
pmrm_model_slowing_proportional()
set.seed(0L) simulation <- pmrm_simulate_slowing_nonproportional( visit_times = seq_len(5L) - 1, gamma = c(1, 2) ) fit <- pmrm_model_slowing_nonproportional( data = simulation, outcome = "y", time = "t", patient = "patient", visit = "visit", arm = "arm", covariates = ~ w_1 + w_2 ) str(fit$estimates) names(fit)set.seed(0L) simulation <- pmrm_simulate_slowing_nonproportional( visit_times = seq_len(5L) - 1, gamma = c(1, 2) ) fit <- pmrm_model_slowing_nonproportional( data = simulation, outcome = "y", time = "t", patient = "patient", visit = "visit", arm = "arm", covariates = ~ w_1 + w_2 ) str(fit$estimates) names(fit)
Fit the proportional slowing model to a clinical dataset on a progressive disease.
pmrm_model_slowing_proportional( data, outcome, time, patient, visit, arm, covariates = ~0, visit_times = NULL, spline_knots = visit_times, spline_method = c("natural", "fmm"), reml = FALSE, hessian = c("divergence", "never", "always"), saddle = FALSE, control = list(eval.max = 4000L, iter.max = 4000L), initial_method = c("regression", "regression_control", "zero"), initial = NULL, silent = TRUE )pmrm_model_slowing_proportional( data, outcome, time, patient, visit, arm, covariates = ~0, visit_times = NULL, spline_knots = visit_times, spline_method = c("natural", "fmm"), reml = FALSE, hessian = c("divergence", "never", "always"), saddle = FALSE, control = list(eval.max = 4000L, iter.max = 4000L), initial_method = c("regression", "regression_control", "zero"), initial = NULL, silent = TRUE )
data |
A data frame or |
outcome |
Character string, name of the column in the data
with the numeric outcome variable on the continuous scale.
Could be a clinical measure of healthy or of disease severity.
Baseline is part of the model, so the |
time |
Character string, name of the column in the data with the numeric time variable on the continuous scale. This time is the time since enrollment/randomization of each patient. A time value of 0 should indicate baseline. |
patient |
Character string, name of the column in the data
with the patient ID.
This vector could be a numeric, integer, factor, or character vector.
|
visit |
Character string, name of the column in the
data which indicates the study visit of each row.
This column could be a numeric, integer, factor, or character vector.
An ordered factor is highly recommended because |
arm |
Character string, name of the column in the
data which indicates the study arm of each row.
This column could be a numeric, integer, factor, or character vector.
An ordered factor is highly recommended because |
covariates |
Partial right-sided formula
of concomitant terms in the model
for covariate adjustment (e.g. by age, gender, biomarker status, etc.).
Usually does not include main variables such as the values of
The columns in the data referenced in the formula must not have any missing values. Set |
visit_times |
Numeric vector, the continuous scheduled time
of each study visit (since baseline/randomization).
If |
spline_knots |
Numeric vector of spline knots on the continuous scale, including boundary knots. |
spline_method |
Character string, spline method to use for the base model.
Must be |
reml |
|
hessian |
Character string controlling
when to supply the Hessian matrix
of the objective function to the optimizer The The
|
saddle |
|
control |
A named list of control parameters passed directly to the
|
initial_method |
Character string, name of the method
for computing initial values.
Ignored unless
|
initial |
If If
You can generate an example of the format of this list
by fitting a test model
(e.g. |
silent |
As MakeADFun. |
See vignette("models", package = "pmrm") for details.
A pmrm fit object of class c("pmrm_fit_slowing", "pmrm_fit").
For details, see the "pmrm fit objects" section of this help file.
A "pmrm_fit" object is a classed list returned by modeling functions.
It has the following named elements:
data: a tibble, the input data with
the missing outcomes removed and the remaining rows
sorted by patient and visit within patient.
The data has a special "pmrm_data" class and should
not be modified by the user.
constants: a list of fixed quantities from the data
that the objective function uses in the optimization.
Most of these quantities are defined in the modeling and
simulation vignettes in the pmrm package.
n_visits is a positive integer vector with the number
of non-missing outcomes for each patient.
options: a list of low-level model-fitting options for RTMB.
objective: the objective function for the optimization.
Returns the minus log likelihood of the model.
The arguments are (1) a list of constants,
and (2) a list of model parameters.
Both arguments have strict formatting requirements.
For (1), see the constants element of the fitted model object.
For (2), see initial or final.
model$fn (from the model element of the fitted model object)
contains a copy of the objective function that only takes
a parameter list.
(The constants are in the closure of model$fn.)
model: model object returned by RTMB::MakeADFun()
with the compiled objective function and gradient.
The elements can be supplied to an optimization routine in R
such as stats::nlminb().
optimization: the object returned by stats::nlminb() to perform
the optimization that estimates the parameters.
optimization$convergence equals 0
if an only if the model converges.
report: object returned by RTMB::sdreport() which has information
on the standard deviations of model parameters.
initial: a list of model parameters initial values.
Includes true parameters like theta and alpha but does not
include derived parameters like beta or sigma.
You can supply your own list of similarly formatted initial values
to the initial argument of the modeling function you choose.
final: a list of model parameter estimates after optimization,
but not including derived parameters like beta or sigma.
The format is exactly the same as initial (see above)
to help deal with divergent model fits.
If your model fit diverged and you want to try resume the optimization
with slightly better values, you can modify values in final
and supply the result to the initial argument of the modeling function.
estimates: a full list of parameter estimates, including derived
parameters
standard_errors: a list of parameter standard errors.
metrics: a list of high-level model metrics, including:
n_observations: positive integer scalar,
number of non-missing observations in the data.
n_parameters: positive integer scalar,
number of model parameters in the data.
Includes true parameters like theta
but excludes downstream functions
of parameters such as beta.
log_likelihood: numeric scalar,
the maximized log likelihood of the fitted model.
deviance: deviance of the fitted model,
defined here as -2 * log_likelihood.
aic: numeric scalar, the Akaike information
criterion of the fitted model.
bic: numeric scalar, the Bayesian information
criterion of the fitted model.
spline: a vectorized function that accepts continuous time x
and returns the value of the fitted spline f(x | spline_knots, alpha) at time x
given the user-specified knots spline_knots and the
maximum likelihood estimates of alpha.
Useful for diagnosing strange behavior in the fitted spline.
If the spline behaves oddly,
especially extrapolating beyond the range of the
time points, please consider adjusting
the knots spline_knots or the initial values of alpha
when refitting the model.
Other models:
pmrm_model_decline_nonproportional(),
pmrm_model_decline_proportional(),
pmrm_model_slowing_nonproportional()
set.seed(0L) simulation <- pmrm_simulate_slowing_proportional( visit_times = seq_len(5L) - 1, gamma = c(1, 2) ) fit <- pmrm_model_slowing_proportional( data = simulation, outcome = "y", time = "t", patient = "patient", visit = "visit", arm = "arm", covariates = ~ w_1 + w_2 ) str(fit$estimates) names(fit)set.seed(0L) simulation <- pmrm_simulate_slowing_proportional( visit_times = seq_len(5L) - 1, gamma = c(1, 2) ) fit <- pmrm_model_slowing_proportional( data = simulation, outcome = "y", time = "t", patient = "patient", visit = "visit", arm = "arm", covariates = ~ w_1 + w_2 ) str(fit$estimates) names(fit)
Simulate a dataset from the non-proportional decline model.
pmrm_simulate_decline_nonproportional( patients = 300, visit_times = seq(from = 0, to = 4, by = 1), spline_knots = visit_times, spline_method = c("natural", "fmm"), tau = 0, alpha = log(spline_knots + 1), beta = cbind(0, rbind(0, rep(0.2, length(visit_times) - 1L), rep(0.3, length(visit_times) - 1L))), gamma = numeric(0L), sigma = rep(1, length(visit_times)), rho = rep(0, length(visit_times) * (length(visit_times) - 1L)/2L) )pmrm_simulate_decline_nonproportional( patients = 300, visit_times = seq(from = 0, to = 4, by = 1), spline_knots = visit_times, spline_method = c("natural", "fmm"), tau = 0, alpha = log(spline_knots + 1), beta = cbind(0, rbind(0, rep(0.2, length(visit_times) - 1L), rep(0.3, length(visit_times) - 1L))), gamma = numeric(0L), sigma = rep(1, length(visit_times)), rho = rep(0, length(visit_times) * (length(visit_times) - 1L)/2L) )
patients |
Positive integer scalar, total number of patients in the output dataset. Patients are allocated (roughly) uniformly across the study arms. |
visit_times |
Numeric vector, the continuous scheduled time after randomization of each study visit. |
spline_knots |
Numeric vector of spline knots on the continuous scale, including boundary knots. |
spline_method |
Character string, spline method to use for the base model.
Must be |
tau |
Positive numeric scalar, standard deviation for jittering the simulated time points. Defaults to 0 so that the observed continuous times are just the scheduled visit times. |
alpha |
Numeric vector of spline coefficients for simulating
the mean function |
beta |
Numeric matrix with one row for each study arm
(including the control arm)
and one column for each study visit (including baseline).
See |
gamma |
Numeric vector of model coefficients for covariate adjustment.
The simulation functions in |
sigma |
A positive numeric vector of visit-level standard deviation parameters. |
rho |
A finite numeric vector of correlation parameters.
Must have length |
See vignette("models", package = "pmrm") for details.
A tibble of clinical data simulated from the model.
See the "Simulated data" section of this help file for details.
The datasets returned from the simulation functions
have one row per patient visit and the following columns
which conform to the notation from vignette("models", package = "pmrm"):
patient: Character vector of patient ID labels.
visit: Ordered factor of clinical visits with labels included.
min(visit) indicates the baseline visit.
arm: Ordered factor of study arms with visits included.
min(arm) indicates the control arm.
i: integer ID of each patient.
j: integer ID of each clinical visit.
j == 1 at baseline.
k: integer ID of the study arm of patient i.
k == 1 for the control arm.
y: clinical outcomes.
t: observed continuous time since baseline.
beta: the scalar component of the treatment effect parameter
beta defined for patient i.
mu: expected clinical outcome at the given patient visit.
w_*: columns of the covariate adjustment model matrix W.
e: residuals.
Other simulations:
pmrm_simulate_decline_proportional(),
pmrm_simulate_slowing_nonproportional(),
pmrm_simulate_slowing_proportional()
pmrm_simulate_decline_nonproportional()pmrm_simulate_decline_nonproportional()
Simulate a dataset from the proportional decline model.
pmrm_simulate_decline_proportional( patients = 300, visit_times = seq(from = 0, to = 4, by = 1), spline_knots = visit_times, spline_method = c("natural", "fmm"), tau = 0, alpha = log(spline_knots + 1), beta = c(0, 0.1, 0.2), gamma = numeric(0L), sigma = rep(1, length(visit_times)), rho = rep(0, length(visit_times) * (length(visit_times) - 1L)/2L) )pmrm_simulate_decline_proportional( patients = 300, visit_times = seq(from = 0, to = 4, by = 1), spline_knots = visit_times, spline_method = c("natural", "fmm"), tau = 0, alpha = log(spline_knots + 1), beta = c(0, 0.1, 0.2), gamma = numeric(0L), sigma = rep(1, length(visit_times)), rho = rep(0, length(visit_times) * (length(visit_times) - 1L)/2L) )
patients |
Positive integer scalar, total number of patients in the output dataset. Patients are allocated (roughly) uniformly across the study arms. |
visit_times |
Numeric vector, the continuous scheduled time after randomization of each study visit. |
spline_knots |
Numeric vector of spline knots on the continuous scale, including boundary knots. |
spline_method |
Character string, spline method to use for the base model.
Must be |
tau |
Positive numeric scalar, standard deviation for jittering the simulated time points. Defaults to 0 so that the observed continuous times are just the scheduled visit times. |
alpha |
Numeric vector of spline coefficients for simulating
the mean function |
beta |
Numeric vector with one element per study arm
(including the control arm).
See |
gamma |
Numeric vector of model coefficients for covariate adjustment.
The simulation functions in |
sigma |
A positive numeric vector of visit-level standard deviation parameters. |
rho |
A finite numeric vector of correlation parameters.
Must have length |
See vignette("models", package = "pmrm") for details.
A tibble of clinical data simulated from the model.
See the "Simulated data" section of this help file for details.
The datasets returned from the simulation functions
have one row per patient visit and the following columns
which conform to the notation from vignette("models", package = "pmrm"):
patient: Character vector of patient ID labels.
visit: Ordered factor of clinical visits with labels included.
min(visit) indicates the baseline visit.
arm: Ordered factor of study arms with visits included.
min(arm) indicates the control arm.
i: integer ID of each patient.
j: integer ID of each clinical visit.
j == 1 at baseline.
k: integer ID of the study arm of patient i.
k == 1 for the control arm.
y: clinical outcomes.
t: observed continuous time since baseline.
beta: the scalar component of the treatment effect parameter
beta defined for patient i.
mu: expected clinical outcome at the given patient visit.
w_*: columns of the covariate adjustment model matrix W.
e: residuals.
Other simulations:
pmrm_simulate_decline_nonproportional(),
pmrm_simulate_slowing_nonproportional(),
pmrm_simulate_slowing_proportional()
pmrm_simulate_decline_proportional()pmrm_simulate_decline_proportional()
Simulate a dataset from the non-proportional slowing model.
pmrm_simulate_slowing_nonproportional( patients = 300, visit_times = seq(from = 0, to = 4, by = 1), spline_knots = visit_times, spline_method = c("natural", "fmm"), tau = 0, alpha = log(spline_knots + 1), beta = cbind(0, rbind(0, rep(0.2, length(visit_times) - 1L), rep(0.3, length(visit_times) - 1L))), gamma = numeric(0L), sigma = rep(1, length(visit_times)), rho = rep(0, length(visit_times) * (length(visit_times) - 1L)/2L) )pmrm_simulate_slowing_nonproportional( patients = 300, visit_times = seq(from = 0, to = 4, by = 1), spline_knots = visit_times, spline_method = c("natural", "fmm"), tau = 0, alpha = log(spline_knots + 1), beta = cbind(0, rbind(0, rep(0.2, length(visit_times) - 1L), rep(0.3, length(visit_times) - 1L))), gamma = numeric(0L), sigma = rep(1, length(visit_times)), rho = rep(0, length(visit_times) * (length(visit_times) - 1L)/2L) )
patients |
Positive integer scalar, total number of patients in the output dataset. Patients are allocated (roughly) uniformly across the study arms. |
visit_times |
Numeric vector, the continuous scheduled time after randomization of each study visit. |
spline_knots |
Numeric vector of spline knots on the continuous scale, including boundary knots. |
spline_method |
Character string, spline method to use for the base model.
Must be |
tau |
Positive numeric scalar, standard deviation for jittering the simulated time points. Defaults to 0 so that the observed continuous times are just the scheduled visit times. |
alpha |
Numeric vector of spline coefficients for simulating
the mean function |
beta |
Numeric matrix with one row for each study arm
(including the control arm)
and one column for each study visit (including baseline).
See |
gamma |
Numeric vector of model coefficients for covariate adjustment.
The simulation functions in |
sigma |
A positive numeric vector of visit-level standard deviation parameters. |
rho |
A finite numeric vector of correlation parameters.
Must have length |
See vignette("models", package = "pmrm") for details.
A tibble of clinical data simulated from the slowing model.
See the "Simulated data" section of this help file for details.
The datasets returned from the simulation functions
have one row per patient visit and the following columns
which conform to the notation from vignette("models", package = "pmrm"):
patient: Character vector of patient ID labels.
visit: Ordered factor of clinical visits with labels included.
min(visit) indicates the baseline visit.
arm: Ordered factor of study arms with visits included.
min(arm) indicates the control arm.
i: integer ID of each patient.
j: integer ID of each clinical visit.
j == 1 at baseline.
k: integer ID of the study arm of patient i.
k == 1 for the control arm.
y: clinical outcomes.
t: observed continuous time since baseline.
beta: the scalar component of the treatment effect parameter
beta defined for patient i.
mu: expected clinical outcome at the given patient visit.
w_*: columns of the covariate adjustment model matrix W.
e: residuals.
Other simulations:
pmrm_simulate_decline_nonproportional(),
pmrm_simulate_decline_proportional(),
pmrm_simulate_slowing_proportional()
pmrm_simulate_slowing_nonproportional()pmrm_simulate_slowing_nonproportional()
Simulate a dataset from the proportional slowing model.
pmrm_simulate_slowing_proportional( patients = 300, visit_times = seq(from = 0, to = 4, by = 1), spline_knots = visit_times, spline_method = c("natural", "fmm"), tau = 0, alpha = log(spline_knots + 1), beta = c(0, 0.1, 0.2), gamma = numeric(0L), sigma = rep(1, length(visit_times)), rho = rep(0, length(visit_times) * (length(visit_times) - 1L)/2L) )pmrm_simulate_slowing_proportional( patients = 300, visit_times = seq(from = 0, to = 4, by = 1), spline_knots = visit_times, spline_method = c("natural", "fmm"), tau = 0, alpha = log(spline_knots + 1), beta = c(0, 0.1, 0.2), gamma = numeric(0L), sigma = rep(1, length(visit_times)), rho = rep(0, length(visit_times) * (length(visit_times) - 1L)/2L) )
patients |
Positive integer scalar, total number of patients in the output dataset. Patients are allocated (roughly) uniformly across the study arms. |
visit_times |
Numeric vector, the continuous scheduled time after randomization of each study visit. |
spline_knots |
Numeric vector of spline knots on the continuous scale, including boundary knots. |
spline_method |
Character string, spline method to use for the base model.
Must be |
tau |
Positive numeric scalar, standard deviation for jittering the simulated time points. Defaults to 0 so that the observed continuous times are just the scheduled visit times. |
alpha |
Numeric vector of spline coefficients for simulating
the mean function |
beta |
Numeric vector with one element per study arm
(including the control arm).
See |
gamma |
Numeric vector of model coefficients for covariate adjustment.
The simulation functions in |
sigma |
A positive numeric vector of visit-level standard deviation parameters. |
rho |
A finite numeric vector of correlation parameters.
Must have length |
See vignette("models", package = "pmrm") for details.
A tibble of clinical data simulated from the slowing model.
See the "Simulated data" section of this help file for details.
The datasets returned from the simulation functions
have one row per patient visit and the following columns
which conform to the notation from vignette("models", package = "pmrm"):
patient: Character vector of patient ID labels.
visit: Ordered factor of clinical visits with labels included.
min(visit) indicates the baseline visit.
arm: Ordered factor of study arms with visits included.
min(arm) indicates the control arm.
i: integer ID of each patient.
j: integer ID of each clinical visit.
j == 1 at baseline.
k: integer ID of the study arm of patient i.
k == 1 for the control arm.
y: clinical outcomes.
t: observed continuous time since baseline.
beta: the scalar component of the treatment effect parameter
beta defined for patient i.
mu: expected clinical outcome at the given patient visit.
w_*: columns of the covariate adjustment model matrix W.
e: residuals.
Other simulations:
pmrm_simulate_decline_nonproportional(),
pmrm_simulate_decline_proportional(),
pmrm_simulate_slowing_nonproportional()
pmrm_simulate_slowing_proportional()pmrm_simulate_slowing_proportional()
Return the expected values, standard errors, and confidence intervals of new outcomes.
## S3 method for class 'pmrm_fit' predict(object, data = object$data, adjust = TRUE, confidence = 0.95, ...)## S3 method for class 'pmrm_fit' predict(object, data = object$data, adjust = TRUE, confidence = 0.95, ...)
object |
A fitted model object of class |
data |
A |
adjust |
|
confidence |
Numeric between 0 and 1, the confidence level to use in the 2-sided confidence intervals. |
... |
Not used. |
A tibble with one row for each row in the data argument and
columns "estimate", "standard_error", "lower", and "upper".
Columns "lower" and "upper" are lower and upper bounds of 2-sided
confidence intervals on the means.
(The confidence intervals are not actually truly prediction intervals
because they do not include variability from residuals.)
Other predictions:
fitted.pmrm_fit(),
residuals.pmrm_fit()
set.seed(0L) simulation <- pmrm_simulate_decline_proportional( visit_times = seq_len(5L) - 1, gamma = c(1, 2) ) fit <- pmrm_model_decline_proportional( data = simulation, outcome = "y", time = "t", patient = "patient", visit = "visit", arm = "arm", covariates = ~ w_1 + w_2 ) new_data <- pmrm_simulate_decline_proportional( patients = 1, visit_times = seq_len(5L) - 1, gamma = c(1, 2) ) new_data$y <- NULL # Permitted but not strictly necessary. predict(fit, new_data)set.seed(0L) simulation <- pmrm_simulate_decline_proportional( visit_times = seq_len(5L) - 1, gamma = c(1, 2) ) fit <- pmrm_model_decline_proportional( data = simulation, outcome = "y", time = "t", patient = "patient", visit = "visit", arm = "arm", covariates = ~ w_1 + w_2 ) new_data <- pmrm_simulate_decline_proportional( patients = 1, visit_times = seq_len(5L) - 1, gamma = c(1, 2) ) new_data$y <- NULL # Permitted but not strictly necessary. predict(fit, new_data)
Print a fitted progression model for repeated measures (PMRM).
## S3 method for class 'pmrm_fit' print(x, digits = 3L, ...)## S3 method for class 'pmrm_fit' print(x, digits = 3L, ...)
x |
A fitted progression model for repeated measures (PMRM). |
digits |
Non-negative integer, number of digits for rounding. |
... |
Not used. |
Invisibly returns x, the fitted PMRM object.
Other visualization:
plot.pmrm_fit()
set.seed(0L) simulation <- pmrm_simulate_decline_proportional( visit_times = seq_len(5L) - 1, gamma = c(1, 2) ) fit <- pmrm_model_decline_proportional( data = simulation, outcome = "y", time = "t", patient = "patient", visit = "visit", arm = "arm", covariates = ~ w_1 + w_2 ) print(fit)set.seed(0L) simulation <- pmrm_simulate_decline_proportional( visit_times = seq_len(5L) - 1, gamma = c(1, 2) ) fit <- pmrm_model_decline_proportional( data = simulation, outcome = "y", time = "t", patient = "patient", visit = "visit", arm = "arm", covariates = ~ w_1 + w_2 ) print(fit)
pmrm residuals.Compute the residuals (responses minus fitted values) of a fitted progression model for repeated measures.
## S3 method for class 'pmrm_fit' residuals(object, ..., data = object$data, adjust = TRUE)## S3 method for class 'pmrm_fit' residuals(object, ..., data = object$data, adjust = TRUE)
object |
A fitted model object of class |
... |
Not used. |
data |
A |
adjust |
|
A numeric vector of residuals corresponding to the
rows of the data supplied in the data argument.
Other predictions:
fitted.pmrm_fit(),
predict.pmrm_fit()
set.seed(0L) simulation <- pmrm_simulate_decline_proportional( visit_times = seq_len(5L) - 1, gamma = c(1, 2) ) fit <- pmrm_model_decline_proportional( data = simulation, outcome = "y", time = "t", patient = "patient", visit = "visit", arm = "arm", covariates = ~ w_1 + w_2 ) str(residuals(fit))set.seed(0L) simulation <- pmrm_simulate_decline_proportional( visit_times = seq_len(5L) - 1, gamma = c(1, 2) ) fit <- pmrm_model_decline_proportional( data = simulation, outcome = "y", time = "t", patient = "patient", visit = "visit", arm = "arm", covariates = ~ w_1 + w_2 ) str(residuals(fit))
Summarize a progression model for repeated measures (PMRM).
## S3 method for class 'pmrm_fit' summary(object, ...)## S3 method for class 'pmrm_fit' summary(object, ...)
object |
A fitted model object of class |
... |
Not used. |
A tibble with one row and columns with the following columns:
model: "decline" or "slowing".
parameterization: "proportional" or "nonproportional".
n_observations: number of non-missing observations in the data.
n_parameters: number of true model parameters.
log_likelihood: maximized log likelihood of the model fit.
deviance: deviance of the fitted model, defined here as
-2 * log_likelihood.
aic: Akaike information criterion.
bic: Bayesian information criterion.
This format is designed for easy comparison of multiple fitted models.
Other model comparison:
AIC.pmrm_fit(),
BIC.pmrm_fit(),
confint.pmrm_fit(),
deviance.pmrm_fit(),
glance.pmrm_fit(),
logLik.pmrm_fit()
set.seed(0L) simulation <- pmrm_simulate_decline_proportional( visit_times = seq_len(5L) - 1, gamma = c(1, 2) ) fit <- pmrm_model_decline_proportional( data = simulation, outcome = "y", time = "t", patient = "patient", visit = "visit", arm = "arm", covariates = ~ w_1 + w_2 ) summary(fit)set.seed(0L) simulation <- pmrm_simulate_decline_proportional( visit_times = seq_len(5L) - 1, gamma = c(1, 2) ) fit <- pmrm_model_decline_proportional( data = simulation, outcome = "y", time = "t", patient = "patient", visit = "visit", arm = "arm", covariates = ~ w_1 + w_2 ) summary(fit)
Return tidy parameter summaries of a progression model for repeated measures (PMRM).
## S3 method for class 'pmrm_fit' tidy(x, ...)## S3 method for class 'pmrm_fit' tidy(x, ...)
x |
A fitted progression model for repeated measures (PMRM). |
... |
Not used. |
A tidy tibble with one row for each treatment effect
model parameter (theta) and columns with the parameter name
(study arm and/or visit it corresponds to), estimate,
and standard error. This format aligns with the tidy()
method of similar fitted models in R.
Other estimates:
VarCorr.pmrm_fit(),
coef.pmrm_fit(),
pmrm_marginals(),
vcov.pmrm_fit()
set.seed(0L) simulation <- pmrm_simulate_decline_proportional( visit_times = seq_len(5L) - 1, gamma = c(1, 2) ) fit <- pmrm_model_decline_proportional( data = simulation, outcome = "y", time = "t", patient = "patient", visit = "visit", arm = "arm", covariates = ~ w_1 + w_2 ) tidy(fit)set.seed(0L) simulation <- pmrm_simulate_decline_proportional( visit_times = seq_len(5L) - 1, gamma = c(1, 2) ) fit <- pmrm_model_decline_proportional( data = simulation, outcome = "y", time = "t", patient = "patient", visit = "visit", arm = "arm", covariates = ~ w_1 + w_2 ) tidy(fit)
Extract estimated covariance matrix among visits within patients.
## S3 method for class 'pmrm_fit' VarCorr(x, sigma = NA, ...)## S3 method for class 'pmrm_fit' VarCorr(x, sigma = NA, ...)
x |
A fitted model object of class |
sigma |
Not used for |
... |
Not used. |
A matrix J rows and J columns, where J is the number
of scheduled visits in the clinical trial.
Other estimates:
coef.pmrm_fit(),
pmrm_marginals(),
tidy.pmrm_fit(),
vcov.pmrm_fit()
set.seed(0L) simulation <- pmrm_simulate_decline_proportional( visit_times = seq_len(5L) - 1, gamma = c(1, 2) ) fit <- pmrm_model_decline_proportional( data = simulation, outcome = "y", time = "t", patient = "patient", visit = "visit", arm = "arm", covariates = ~ w_1 + w_2 ) VarCorr(fit)set.seed(0L) simulation <- pmrm_simulate_decline_proportional( visit_times = seq_len(5L) - 1, gamma = c(1, 2) ) fit <- pmrm_model_decline_proportional( data = simulation, outcome = "y", time = "t", patient = "patient", visit = "visit", arm = "arm", covariates = ~ w_1 + w_2 ) VarCorr(fit)
Extract the covariance matrix of the treatment effect parameters of a progression model for repeated measures.
## S3 method for class 'pmrm_fit' vcov(object, ...)## S3 method for class 'pmrm_fit' vcov(object, ...)
object |
A fitted model object of class |
... |
Not used. |
A matrix with covariance of each pair of theta parameters.
Rows and columns are labeled (by just study arm for proportional models,
arm and visit for non-proportional models.)
Other estimates:
VarCorr.pmrm_fit(),
coef.pmrm_fit(),
pmrm_marginals(),
tidy.pmrm_fit()
set.seed(0L) simulation <- pmrm_simulate_decline_proportional( visit_times = seq_len(5L) - 1, gamma = c(1, 2) ) fit <- pmrm_model_decline_proportional( data = simulation, outcome = "y", time = "t", patient = "patient", visit = "visit", arm = "arm", covariates = ~ w_1 + w_2 ) vcov(fit)set.seed(0L) simulation <- pmrm_simulate_decline_proportional( visit_times = seq_len(5L) - 1, gamma = c(1, 2) ) fit <- pmrm_model_decline_proportional( data = simulation, outcome = "y", time = "t", patient = "patient", visit = "visit", arm = "arm", covariates = ~ w_1 + w_2 ) vcov(fit)