Package 'JMbamlss'

Title: Multivariate Joint Models with bamlss
Description: Multivariate joint models of longitudinal and time-to-event data based on functional principal components implemented with bamlss.
Authors: Nikolaus Umlauf [aut, cre] (ORCID: <https://orcid.org/0000-0003-2160-9803>), Alexander Volkmann [aut]
Maintainer: Nikolaus Umlauf <[email protected]>
License: GPL-3
Version: 0.1.0
Built: 2026-11-25 11:52:05 UTC
Source: https://codeberg.org/zeileis/JMbamlss

Help Index


Multivariate Joint Models with bamlss

Description

Multivariate joint models of longitudinal and time-to-event data based on functional principal components implemented with bamlss.

Details

The DESCRIPTION file:

Package: JMbamlss
Type: Package
Title: Multivariate Joint Models with bamlss
Version: 0.1.0
Authors@R: c(person(given = "Nikolaus", family = "Umlauf", role = c("aut", "cre"), email = "[email protected]", comment = c(ORCID = "0000-0003-2160-9803")), person("Alexander", "Volkmann", email = "[email protected]", role = c("aut")))
Description: Multivariate joint models of longitudinal and time-to-event data based on functional principal components implemented with bamlss.
License: GPL-3
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.2.0
Depends: R (>= 3.5), bamlss
LinkingTo: Rcpp, RcppEigen
Imports: Rcpp, sparseFLMM, refund, MFPCA, gamm4, Matrix, mgcv
Suggests: testthat (>= 3.0.0), splines
Config/testthat/edition: 3
Config/pak/sysreqs: cmake libfftw3-dev libgmp3-dev make libssl-dev
Repository: https://freezenik.r-universe.dev
Date/Publication: 2023-11-23 10:41:38 UTC
RemoteUrl: https://codeberg.org/zeileis/JMbamlss
RemoteRef: HEAD
RemoteSha: 7d95c858d738a91924ad176352eb98a73672809b
Author: Nikolaus Umlauf [aut, cre] (ORCID: <https://orcid.org/0000-0003-2160-9803>), Alexander Volkmann [aut]
Maintainer: Nikolaus Umlauf <[email protected]>

Index of help topics:

attach_wfpc             Attach Weighted Functional Principal Components
                        to the Data
fpca                    Functional principal components analysis by
                        smoothed covariance
JMbamlss-package        Multivariate Joint Models with bamlss
MFPCA_cov               Function to calculate the multivariate FPCA for
                        a given covariance matrix and univariate basis
                        functions
MJM_predict             Prediction of MJM model
Predict.matrix.unc_pcre.random.effect
                        mgcv-style constructor for prediction of
                        PC-basis functional random effects
preproc_MFPCA           Preprocessing step to create MFPCA object
sim_bamlss_predict      Simulation Helper Function - Predict the
                        Results for bamlss-Models
sim_jmb_predict         Simulation Helper Function - Predict the
                        Results for JMbayes-Models
sim_jmbamlss_eval       Simulation Helper Function - Evaluate the
                        Simulation for JMbamlss Setting
sim_jmbayes_eval        Simulation Helper Function - Evaluate the
                        Simulation for JMbayes Setting
simJM                   New Simulation Function Based On FPCs
simMultiJM              New Simulation Function For Multivariate JMs
                        Based On FPCs
smooth.construct.unc_pcre.smooth.spec
                        mgcv-style constructor for PC-basis functional
                        random effects (no constraint)
survint_C               Survival Integral

An overview of how to use the package, including the most important ~~ ~~ functions ~~

Author(s)

Nikolaus Umlauf [aut, cre] (ORCID: <https://orcid.org/0000-0003-2160-9803>), Alexander Volkmann [aut]

Maintainer: Nikolaus Umlauf <[email protected]>

References

~~ Literature or other references for background information ~~

See Also

~~ Optional links to other man pages, e.g. ~~ ~~ <pkg> ~~

Examples

~~ simple examples of the most important functions ~~

Attach Weighted Functional Principal Components to the Data

Description

Attach Weighted Functional Principal Components to the Data

Usage

attach_wfpc(
  mfpca,
  data,
  n = NULL,
  obstime = "obstime",
  marker = "marker",
  eval_weight = FALSE
)

Arguments

data

Data set to which the weighted FPCS are to be attached.

n

Number of FPCs to attach. Defaults to NULL which corresponds to all FPCs in mfpc.

obstime

Name of the time variable in data set at which points to evaluate.

marker

Name of the marker variable in the data set which separates the data.

eval_weight

Weight the FPC by the square root of its eigenvalue (then variance comparable throughout all FPCs). Defaults to FALSE.

mfpc

MFPCA object from which to extract the weighted FPCS.


Functional principal components analysis by smoothed covariance

Description

Decomposes functional observations using functional principal components analysis. A mixed model framework is used to estimate scores and obtain variance estimates.

Usage

fpca(
  Y = NULL,
  ydata = NULL,
  Y.pred = NULL,
  argvals = NULL,
  argvals_obs = FALSE,
  argvals_pred = seq(0, 1, by = 0.01),
  random.int = FALSE,
  nbasis = 10,
  nbasis_cov = nbasis,
  bs_cov = "symm",
  pve = 0.99,
  npc = NULL,
  useSymm = FALSE,
  makePD = FALSE,
  center = TRUE,
  cov.est.method = 1,
  integration = "trapezoidal"
)

Arguments

Y, ydata

the user must supply either Y, a matrix of functions observed on a regular grid, or a data frame ydata representing irregularly observed functions. See Details.

Y.pred

if desired, a matrix of functions to be approximated using the FPC decomposition.

argvals

the argument values of the function evaluations in Y, defaults to a equidistant grid from 0 to 1. @param argvals_obs Should the timepoints of the original observations be used to evaluate the FPCs. Defaults to FALSE. @param argvals_pred Vector of timepoints on which to evaluate the FPCs. Defaults to a sequence from 0 to 1.

random.int

If TRUE, the mean is estimated by gamm4 with random intercepts. If FALSE (the default), the mean is estimated by gam treating all the data as independent.

nbasis

number of B-spline basis functions used for estimation of the mean function.

nbasis_cov

number of basis functions used for the bivariate smoothing of the covariance surface.

bs_cov

type of spline for the bivariate smoothing of the covariance surface. Default is symmetric fast covariance smoothing proposed by Cederbaum.

pve

proportion of variance explained: used to choose the number of principal components.

npc

prespecified value for the number of principal components (if given, this overrides pve).

useSymm

logical, indicating whether to smooth only the upper triangular part of the naive covariance (when cov.est.method==2). This can save computation time for large data sets, and allows for covariance surfaces that are very peaked on the diagonal.

makePD

logical: should positive definiteness be enforced for the covariance surface estimate?

center

logical: should an estimated mean function be subtracted from Y? Set to FALSE if you have already demeaned the data using your favorite mean function estimate.

cov.est.method

covariance estimation method. If set to 1 (the default), a one-step method that applies a bivariate smooth to the y(s1)y(s2)y(s_1)y(s_2) values. This can be very slow. If set to 2, a two-step method that obtains a naive covariance estimate which is then smoothed.

integration

quadrature method for numerical integration; only 'trapezoidal' is currently supported.

Details

This function computes a FPC decomposition for a set of observed curves, which may be sparsely observed and/or measured with error. A mixed model framework is used to estimate curve-specific scores and variances.

FPCA via kernel smoothing of the covariance function, with the diagonal treated separately, was proposed in Staniswalis and Lee (1998) and much extended by Yao et al. (2005), who introduced the 'PACE' method. fpca.sc uses penalized splines to smooth the covariance function, as developed by Di et al. (2009) and Goldsmith et al. (2013). This implementation uses REML and Cederbaum et al. (2018) for smoothing the covariance function

The functional data must be supplied as either

  • an n×dn \times d matrix Y, each row of which is one functional observation, with missing values allowed; or

  • a data frame ydata, with columns '.id' (which curve the point belongs to, say ii), '.index' (function argument such as time point tt), and '.value' (observed function value Yi(t)Y_i(t)).

Value

An object of class fpca containing:

Yhat

FPC approximation (projection onto leading components) of Y.pred if specified, or else of Y.

Y

the observed data

scores

n×npcn \times npc matrix of estimated FPC scores.

mu

estimated mean function (or a vector of zeroes if center==FALSE).

efunctions

d×npcd \times npc matrix of estimated eigenfunctions of the functional covariance, i.e., the FPC basis functions.

evalues

estimated eigenvalues of the covariance operator, i.e., variances of FPC scores.

npc

number of FPCs: either the supplied npc, or the minimum number of basis functions needed to explain proportion pve of the variance in the observed curves.

argvals

argument values of eigenfunction evaluations

sigma2

estimated measurement error variance.

diag.var

diagonal elements of the covariance matrices for each estimated curve.

VarMats

a list containing the estimated covariance matrices for each curve in Y.

crit.val

estimated critical values for constructing simultaneous confidence intervals.

Author(s)

Jeff Goldsmith [email protected], Sonja Greven [email protected], Lan Huo [email protected], Lei Huang [email protected], and Philip Reiss [email protected], Alexander Volkmann

References

Cederbaum, J. Scheipl, F. and Greven, S. (2018). Fast symmetric additive covariance smoothing. Computational Statistics & Data Analysis, 120, 25–41.

Di, C., Crainiceanu, C., Caffo, B., and Punjabi, N. (2009). Multilevel functional principal component analysis. Annals of Applied Statistics, 3, 458–488.

Goldsmith, J., Greven, S., and Crainiceanu, C. (2013). Corrected confidence bands for functional data using principal components. Biometrics, 69(1), 41–51.

Staniswalis, J. G., and Lee, J. J. (1998). Nonparametric regression analysis of longitudinal data. Journal of the American Statistical Association, 93, 1403–1418.

Yao, F., Mueller, H.-G., and Wang, J.-L. (2005). Functional data analysis for sparse longitudinal data. Journal of the American Statistical Association, 100, 577–590.

Examples

## Not run: 
library(ggplot2)
library(reshape2)
data(cd4)

Fit.MM = fpca.sc(cd4, var = TRUE, simul = TRUE)

Fit.mu = data.frame(mu = Fit.MM$mu,
                    d = as.numeric(colnames(cd4)))
Fit.basis = data.frame(phi = Fit.MM$efunctions,
                       d = as.numeric(colnames(cd4)))

## for one subject, examine curve estimate, pointwise and simultaneous itervals
EX = 1
EX.MM = data.frame(fitted = Fit.MM$Yhat[EX,],
           ptwise.UB = Fit.MM$Yhat[EX,] + 1.96 * sqrt(Fit.MM$diag.var[EX,]),
           ptwise.LB = Fit.MM$Yhat[EX,] - 1.96 * sqrt(Fit.MM$diag.var[EX,]),
           simul.UB = Fit.MM$Yhat[EX,] + Fit.MM$crit.val[EX] * sqrt(Fit.MM$diag.var[EX,]),
           simul.LB = Fit.MM$Yhat[EX,] - Fit.MM$crit.val[EX] * sqrt(Fit.MM$diag.var[EX,]),
           d = as.numeric(colnames(cd4)))

## plot data for one subject, with curve and interval estimates
EX.MM.m = melt(EX.MM, id = 'd')
ggplot(EX.MM.m, aes(x = d, y = value, group = variable, color = variable, linetype = variable)) +
  geom_path() +
  scale_linetype_manual(values = c(fitted = 1, ptwise.UB = 2,
                        ptwise.LB = 2, simul.UB = 3, simul.LB = 3)) +
  scale_color_manual(values = c(fitted = 1, ptwise.UB = 2,
                     ptwise.LB = 2, simul.UB = 3, simul.LB = 3)) +
  labs(x = 'Months since seroconversion', y = 'Total CD4 Cell Count')

## plot estimated mean function
ggplot(Fit.mu, aes(x = d, y = mu)) + geom_path() +
  labs(x = 'Months since seroconversion', y = 'Total CD4 Cell Count')

## plot the first two estimated basis functions
Fit.basis.m = melt(Fit.basis, id = 'd')
ggplot(subset(Fit.basis.m, variable %in% c('phi.1', 'phi.2')), aes(x = d,
y = value, group = variable, color = variable)) + geom_path()

## input a dataframe instead of a matrix
nid <- 20
nobs <- sample(10:20, nid, rep=TRUE)
ydata <- data.frame(
    .id = rep(1:nid, nobs),
    .index = round(runif(sum(nobs), 0, 1), 3))
ydata$.value <- unlist(tapply(ydata$.index,
                              ydata$.id,
                              function(x)
                                  runif(1, -.5, .5) +
                                  dbeta(x, runif(1, 6, 8), runif(1, 3, 5))
                              )
                       )

Fit.MM = fpca.sc(ydata=ydata, var = TRUE, simul = FALSE)


## End(Not run)

Function to calculate the multivariate FPCA for a given covariance matrix and univariate basis functions

Description

Function to calculate the multivariate FPCA for a given covariance matrix and univariate basis functions

Usage

MFPCA_cov(cov, basis_funs, scores = NULL, weights = NULL)

Arguments

cov

Covariance matrix of the basis functions coefficients.

basis_funs

List with basis functions on each dimension. The basis functions are funData objects

scores

Matrix (n rows, B columns) containing the basis functions coefficients. Defaults to NULL which does not calculate the multivariate scores.

weights

Vector of weights, defaults to 1 for each element


Prediction of MJM model

Description

Note: Writing a predict function is a bit tricky. For longitudinal prediction, if subject specific predictions are wanted, then the PCRE terms must be attached to newdata and already evaluated. If the model uses standardized survival matrices, the different linear predictors should be predicted using different data sets.

Usage

MJM_predict(
  object,
  newdata,
  type = c("link", "parameter", "probabilities", "cumhaz"),
  dt,
  id,
  FUN = function(x) {
     mean(x, na.rm = TRUE)
 },
  subdivisions = 7,
  cores = NULL,
  chunks = 1,
  verbose = FALSE,
  ...
)

mgcv-style constructor for prediction of PC-basis functional random effects

Description

mgcv-style constructor for prediction of PC-basis functional random effects

Usage

## S3 method for class 'unc_pcre.random.effect'
Predict.matrix(object, data)

Arguments

object

a smooth specification object, see smooth.construct

data

see smooth.construct

Value

design matrix for PC-based functional random effects

Author(s)

Alexander Volkmann, adapted from 'Predict.matrix.pcre.random.effect by F. Scheipl (adapted from 'Predict.matrix.random.effect' by S.N. Wood).


Preprocessing step to create MFPCA object

Description

This function takes the data und uses the residuals of marker-specific additive models to estimate the covariance structure for a MFPCA

Usage

preproc_MFPCA(
  data,
  uni_mean = "y ~ s(obstime) + s(x2)",
  time = "obstime",
  id = "id",
  marker = "marker",
  M = NULL,
  weights = FALSE,
  remove_obs = NULL,
  method = c("fpca", "fpca.sc", "FPCA", "PACE"),
  nbasis = 10,
  nbasis_cov = nbasis,
  bs_cov = "symm",
  npc = NULL,
  fve_uni = 0.99,
  pve_uni = 0.99,
  fit = FALSE,
  max_time = NULL,
  save_uniFPCA = FALSE,
  save_uniGAM = FALSE
)

Arguments

data

Data.frame such as returned by function simMultiJM.

uni_mean

String to crate a formula for the univariate addtive models.

time

String giving the name of the longitudinal time variable.

id

String giving the name of the identifier.

marker

String giving the name of the longitudinal marker variable.

M

Number of mFPCs to compute in the MFPCA. If not supplied, it defaults to the maximum number of computable mFPCs.

weights

TRUE if inverse sum of univariate eigenvals should be used as weights in the scalar product of the MFPCA. Defaults to FALSE (weights 1).

remove_obs

Minimal number of observations per individual and marker to be included in the FPC estimation. Defaults to NULL (all observations). Not removing observations can lead to problems if the univariate variance estimate is negative and has to be truncated, then the scores for IDs with few observations cannot be estimated.

method

Which package to use for the univariate FPCA. Either function adapted function 'fpca', 'FPCA' from package fdapace, 'fpca.sc' from package refund, or function 'PACE' from package MFPCA.

nbasis

Number of B-spline basis functions for mean estimate for methods fpca, fpca.sc, PACE. For fpca.sc, PACE also bivariate smoothing of covariance estimate.

nbasis_cov

Number of basis functions used for the bivariate smoothing of the covariance surface for method fpca.

bs_cov

Type of spline for the bivariate smoothing of the covariance surface for method fpca. Default is symmetric fast covariance smoothing proposed by Cederbaum.

npc

Number of univariate principal components to use in fpca.sc, PACE.

fve_uni

Fraction of univariate variance explained for method FPCA.

pve_uni

Proportion of univariate variance explained for methods fpca, fpca.sc, PACE.

fit

MFPCA argument to return a truncated KL fit to the data. Defaults to FALSE.

max_time

If supplied, forces the evaluation of the MFPCs up to maxtime. Only implemented for method = 'fpca'.

save_uniFPCA

TRUE to attach list of univariate FPCAs as attribute to output. Defaults to FALSE.

save_uniGAM

TRUE to attach list of univariate additive models used to calculate the residuals. Defaults to FALSE.

var_names

Vector of variable names corresponding to ID and MARKER. Needed to remove observations.


Simulation Helper Function - Predict the Results for bamlss-Models

Description

This function takes all the models listed in a folder and predicts the fit.

Usage

sim_bamlss_predict(m, wd, model_wd, data_wd, rds = TRUE, old = FALSE)

Arguments

m

Vector containing all the file names of the models.

wd

Path to simulations folder.

model_wd

Simulation setting folder where the models are saved.

data_wd

Simulation data folder.

rds

Objects are saved as .rds files (for backwards compatibility when .Rdata files were used). Defaults to TRUE.

old

Simulated data sets before Version 0.0.3 (samples need to be adapted for standardized survival matrices). Defaults to FALSE.


Simulation Helper Function - Predict the Results for JMbayes-Models

Description

This function takes all the models listed in a folder and predicts the fit.

Usage

sim_jmb_predict(m, wd, model_wd, data_wd, rds = TRUE, gamma_timeconst = TRUE)

Arguments

m

Vector containing all the file names of the models.

wd

Path to simulations folder.

model_wd

Simulation setting folder where the models are saved.

data_wd

Simulation data folder.

rds

Objects are saved as .rds files (for backwards compatibility when .Rdata files were used). Defaults to TRUE.

gamma_timeconst

Only implemented for timeconstant gamma predictors. If FALSE a warning message is returned.


Simulation Helper Function - Evaluate the Simulation for JMbamlss Setting

Description

This function evaluates the results for a given folder of JMbamlss model fits.

Usage

sim_jmbamlss_eval(wd, model_wd, data_wd, name, rds = TRUE)

Arguments

wd

Path to simulations folder.

model_wd

Simulation setting folder where the models are saved.

data_wd

Simulation data folder.

name

Name for description of the simulation setting.

rds

Objects are saved as .rds files (for backwards compatibility when .Rdata files were used). Defaults to TRUE.


Simulation Helper Function - Evaluate the Simulation for JMbayes Setting

Description

This function evaluates the results for a given folder of JMbayes model fits.

Usage

sim_jmbayes_eval(wd, model_wd, data_wd, name, rds = TRUE)

Arguments

wd

Path to simulations folder.

model_wd

Simulation setting folder where the models are saved.

data_wd

Simulation data folder.

name

Name for description of the simulation setting.

rds

Objects are saved as .rds files (for backwards compatibility when .Rdata files were used). Defaults to TRUE.


New Simulation Function Based On FPCs

Description

Extend the structure given by simJM function in bamlss Add arguments efun_type = "Poly", character string specifying the type of eigenfcts (eFun) ignoreDeg = NULL, vector of numerics specifying the ignored degrees (eFun) eval_type = "linear", character string specifying the type of eigenvals (eVal) eval_scale = 1, numeric to scale the eigenvalues

Usage

simJM(
  nsub = 300,
  times = seq(0, 120, 1),
  probmiss = 0.75,
  long_setting = "functional",
  alpha_setting = if (nonlinear) "linear" else "nonlinear",
  dalpha_setting = "zero",
  sigma = 0.3,
  long_df = 6,
  tmax = NULL,
  seed = NULL,
  full = FALSE,
  file = NULL,
  nonlinear = FALSE,
  fac = FALSE,
  efun_type = "Poly",
  ignoreDeg = NULL,
  eval_type = "linear",
  eval_scale = 1
)

New Simulation Function For Multivariate JMs Based On FPCs

Description

Adapt the structure given by simJM function in bamlss.

Usage

simMultiJM(
  nsub = 300,
  times = seq(0, 120, 1),
  probmiss = 0.75,
  max_obs = length(times),
  maxfac = 1.5,
  nmark = 2,
  long_assoc = c("FPC", "splines", "param"),
  M = 6,
  FPC_bases = NULL,
  FPC_evals = NULL,
  mfpc_args = list(type = "split", eFunType = "Poly", ignoreDeg = NULL, eValType =
    "linear", eValScale = 1),
  re_cov_mat = NULL,
  ncovar = 2,
  lambda = function(t, x) {
     1.4 * log((t + 10)/1000)
 },
  gamma = function(x) {
     -1.5 + 0.3 * x[, 1]
 },
  alpha = rep(list(function(t, x) {
     0.3 + 0 * t
 }), nmark),
  mu = rep(list(function(t, x) {
     1.25 + 0.6 * sin(x[, 2]) + (-0.01) * t
 }),
    nmark),
  sigma = function(t, x) {
     0.3 + 0 * t + I(x$marker == "m2") * 0.2
 },
  tmax = NULL,
  seed = NULL,
  full = FALSE,
  file = NULL
)

Arguments

nsub

Number of subjects.

times

Vector of time points.

probmiss

Probability of missingness.

max_obs

Maximal number of observations per individual and marker. Defaults to no upper limit.

maxfac

Factor changing the uniform censoring interval.

nmark

Number of markers.

long_assoc

Longitudinal association between the markers (Defaults to "FPC"). If "splines" or "param", then specify the normal covariance matrix with argument 're_cov_mat' and include the random effects in argument mu. If "FPC", then principal components are used to model the association structure.

M

Number of principal components.

FPC_bases

FunData object. If supplied, use the contained FPC as basis for the association structure.

FPC_evals

Vector of eigenvalues. If supplied, use the provided eigenvalues for the association structure.

mfpc_args

List containing the named arguments "type", "eFunType", "ignoreDeg", "eValType" of function simMultiFunData and "eValScale" for scaling the eigenvalues.

re_cov_mat

If supplied, a covariance matrix to use for drawing the random effects needed for the association structure.

ncovar

Number of covariates.

lambda

Additive predictor of time-varying survival covariates.

gamma

Additive predictor of time-constant survival covariates.

alpha

List of length nmark containing the additive predictors of the association.

mu

List of length nmark containing the additive predictors of the longitudinal part.

sigma

Additive predictor of the variance.

tmax

Maximal time point of observations.

seed

Seed for reproducibility.

full

Create a wide-format data.frame and a short one containing only survival info.


mgcv-style constructor for PC-basis functional random effects (no constraint)

Description

Sets up design matrix for functional random effects based on the PC scores of the covariance operator of the random effect process. Note that there is no constraint on the smoother. See smooth.construct.re.smooth.spec for more details on mgcv-style smoother specification and smooth.construct.pcre.smooth.spec for the corresponding refund implementation.

Usage

## S3 method for class 'unc_pcre.smooth.spec'
smooth.construct(object, data, knots)

Arguments

object

a smooth specification object, see smooth.construct

data

see smooth.construct

knots

see smooth.construct

Value

An object of class "random.effect". See smooth.construct for the elements that this object will contain.

Author(s)

Alexander Volkmann; adapted from 'pcre' constructor by F. Scheipl (adapted from 're' constructor by S.N. Wood).


Survival Integral

Description

This function is a wrapper function for calculating the survival integral in C needed in the calculation of the score vector and Hessian.

Usage

survint_C(
  pred = c("lambda", "gamma", "long", "fpc_re"),
  pre_fac,
  pre_vec = NULL,
  omega,
  int_fac = NULL,
  int_vec = NULL,
  weights,
  survtime
)

Arguments

pred

String to define for which predictor the survival integral is calculated.

pre_fac

Vector serving as factor before the survival integral. Corresponds to the gamma predictor.

pre_vec

Matrix serving as row vectors before the survival integral. Only needed if pred = "gamma".

omega

Vector serving as additive predictor placeholder within the survival integral. Present for all pred.

int_fac

Vector serving as factor within the survival integral. Only needed for the longitudinal predictors.

int_vec

Matrix serving as row vectors within the survival integral. NULL only if pred = "gamma".

weights

Vector containing the Gaussian integration weights.

survtime

Vector containing the survival times for weighting of the integral.

Details

The survival integral has a similar structure for the different model predictors. It is always a sum over all individuals, followed by the multiplication with a pre-integral factor (pre_fac). For the gamma predictor a pre-integral vector is next. Then, the integral itself consists of a weighted sum (weights) of gauss-quadrature integration points weighted by the survival time of the individuals (survtime). Inside the integral, the current additive predictor (omega) is multiplied with an in-integral vector (int_vec), except for predictor gamma. All longitudinal predictors addtitionally include an in-integration factor (int_fac).

The difference between predictors "long" and "fpc_re" is that the latter makes efficient use of the block structure of the design matrix for unconstrained functional principal component random effects. The outputs also differ as the Hessian for "fpc_re" is a diagonal matrix, so only the diagonal elements are returned.