
Simulate non-proportional slowing model.
Source:R/pmrm_simulate_slowing_nonproportional.R
pmrm_simulate_slowing_nonproportional.RdSimulate a dataset from the non-proportional slowing model.
Usage
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)
)Arguments
- 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
"natural"or"fmm". Seestats::splinefun()for details.- 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
f(t_{ij} | spline_knots, alpha). Must havelength(spline_knots)elements.- beta
Numeric matrix with one row for each study arm (including the control arm) and one column for each study visit (including baseline). See
vignette("models", package = "pmrm")for details on this parameter.- gamma
Numeric vector of model coefficients for covariate adjustment. The simulation functions in
pmrmsimulatelength(gamma)columns for the covariate adjustment model matrixW. Set tonumeric(0)to omit covariates.- sigma
A positive numeric vector of visit-level standard deviation parameters.
- rho
A finite numeric vector of correlation parameters. Must have length
J * (J - 1) / 2, whereJislength(visit_times). The full covariance matrixSigmais given bydiag(sigma) %*% RTMB::unstructured(length(sigma))$corr(rho) %*% diag(sigma).
Value
A tibble of clinical data simulated from the slowing model.
See the "Simulated data" section of this help file for details.
Details
See vignette("models", package = "pmrm") for details.
Simulated data
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 == 1at baseline.k: integer ID of the study arm of patienti.k == 1for the control arm.y: clinical outcomes.t: observed continuous time since baseline.beta: the scalar component of the treatment effect parameterbetadefined for patienti.mu: expected clinical outcome at the given patient visit.w_*: columns of the covariate adjustment model matrixW.e: residuals.
Examples
pmrm_simulate_slowing_nonproportional()
#> # A tibble: 1,500 × 11
#> patient visit arm i j k y t beta mu e
#> <chr> <ord> <ord> <int> <int> <int> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 patient_1 visit_1 arm_1 1 1 1 -1.09 0 0 0 -1.09
#> 2 patient_1 visit_2 arm_1 1 2 1 0.873 1 0 0.693 0.180
#> 3 patient_1 visit_3 arm_1 1 3 1 1.06 2 0 1.10 -0.0359
#> 4 patient_1 visit_4 arm_1 1 4 1 2.01 3 0 1.39 0.620
#> 5 patient_1 visit_5 arm_1 1 5 1 1.50 4 0 1.61 -0.114
#> 6 patient_2 visit_1 arm_2 2 1 2 0.379 0 0 0 0.379
#> 7 patient_2 visit_2 arm_2 2 2 2 2.36 1 0.2 0.575 1.78
#> 8 patient_2 visit_3 arm_2 2 3 2 0.843 2 0.2 0.963 -0.120
#> 9 patient_2 visit_4 arm_2 2 4 2 0.871 3 0.2 1.22 -0.351
#> 10 patient_2 visit_5 arm_2 2 5 2 -0.325 4 0.2 1.43 -1.76
#> # ℹ 1,490 more rows