# NOT RUN {
# generate example data
set.seed(123)
n.items = c(4,2,2,3,4,2)
simdata = simulate_prcmlpmm_data(n = 100, p = length(n.items),
p.relev = 3, n.items = n.items,
type = 'u+b', seed = 1)
# specify options for cluster bootstrap optimism correction
# procedure and for parallel computing
do.bootstrap = FALSE
# IMPORTANT: set do.bootstrap = TRUE to compute the optimism correction!
n.boots = ifelse(do.bootstrap, 100, 0)
parallelize = TRUE
# IMPORTANT: set parallelize = TRUE to speed computations up!
if (!parallelize) n.cores = 1
if (parallelize) {
# identify number of available cores on your machine
n.cores = parallel::detectCores()
if (is.na(n.cores)) n.cores = 1
}
# step 1 of PRC-MLPMM: estimate the MLPMMs
y.names = vector('list', length(n.items))
for (i in 1:length(n.items)) {
y.names[[i]] = paste('marker', i, '_', 1:n.items[i], sep = '')
}
step1 = fit_mlpmms(y.names, fixefs = ~ contrast(age),
ranef.time = age, randint.items = TRUE,
long.data = simdata$long.data,
surv.data = simdata$surv.data,
t.from.base = t.from.base,
n.boots = n.boots, n.cores = n.cores)
# step 2 of PRC-MLPMM: compute the summaries
step2 = summarize_mlpmms(object = step1, n.cores = n.cores)
# step 3 of PRC-LMM: fit the penalized Cox models
step3 = fit_prcmlpmm(object = step2, surv.data = simdata$surv.data,
baseline.covs = ~ baseline.age,
include.b0s = TRUE,
penalty = 'ridge', n.cores = n.cores)
# }
Run the code above in your browser using DataLab