preproc_MFPCA {MJMbamlss} | R Documentation |
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 |
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. |
Value
An object of class MFPCAfit
with additional attributes
depending on the arguments save_uniFPCA
, save_uniGAM
,
fit
.
Examples
data(pbc_subset)
mfpca <- preproc_MFPCA(pbc_subset, uni_mean = paste0(
"logy ~ 1 + sex + drug + s(obstime, k = 10, bs = 'ps') + ",
"s(age, k = 10, bs = 'ps')"),
pve_uni = 0.99, nbasis = 5, weights = TRUE, save_uniFPCA = TRUE)