View source: R/pmrm_model_slowing_nonproportional.R
| pmrm_model_slowing_nonproportional | R Documentation |
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
)
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 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.