joint_ms_format: Formats the Parameter Vector

View source: R/joint_surv_VA.R

joint_ms_formatR Documentation

Formats the Parameter Vector

Description

Formats a parameter vector by putting the model parameters into a list with elements for each type of parameter.

Usage

joint_ms_format(object, par = object$start_val)

Arguments

object

a joint_ms object from joint_ms_ptr.

par

parameter vector to be formatted.

Value

A list with the following elements:

markers

list with an element for each marker. The lists contains an element called fixef for non-time-varying fixed effects and an element called fixef_vary time-varying fixed effects.

survival

list with an element for each survival outcome. The lists contains an element called fixef for non-time-varying fixed effects, an element called fixef_vary time-varying fixed effects, and an element called associations for the association parameters.

vcov

contains three covariance matrices called vcov_marker, vcov_vary and vcov_surv for the covariance matrix of the markers error term, the time-varying random effects, and the frailties, respectively.

Examples

# load in the data
library(survival)
data(pbc, package = "survival")

# re-scale by year
pbcseq <- transform(pbcseq, day_use = day / 365.25)
pbc <- transform(pbc, time_use = time / 365.25)

# create the marker terms
m1 <- marker_term(
  log(bili) ~ 1, id = id, data = pbcseq,
  time_fixef = bs_term(day_use, df = 5L),
  time_rng = poly_term(day_use, degree = 1L, raw = TRUE, intercept = TRUE))
m2 <- marker_term(
  albumin ~ 1, id = id, data = pbcseq,
  time_fixef = bs_term(day_use, df = 5L),
  time_rng = poly_term(day_use, degree = 1L, raw = TRUE, intercept = TRUE))

# base knots on observed event times
bs_term_knots <-
  with(pbc, quantile(time_use[status == 2], probs = seq(0, 1, by = .2)))

boundary <- c(bs_term_knots[ c(1, length(bs_term_knots))])
interior <- c(bs_term_knots[-c(1, length(bs_term_knots))])

# create the survival term
s_term <- surv_term(
  Surv(time_use, status == 2) ~ 1, id = id, data = pbc,
  time_fixef = bs_term(time_use, Boundary.knots = boundary, knots = interior))

# create the C++ object to do the fitting
model_ptr <- joint_ms_ptr(
  markers = list(m1, m2), survival_terms = s_term,
  max_threads = 2L, ders = list(0L, c(0L, -1L)))

# find the starting values
start_vals <- joint_ms_start_val(model_ptr)

# format the starting values
joint_ms_format(model_ptr,start_vals)

VAJointSurv documentation built on Aug. 14, 2022, 9:05 a.m.