cat_lmm_tune: Catalytic Linear Mixed Model (LMM) Fitting Function by Tuning...

View source: R/cat_lmm_tune.R

cat_lmm_tuneR Documentation

Catalytic Linear Mixed Model (LMM) Fitting Function by Tuning tau from a Sequence of tau Values

Description

This function tunes a catalytic linear mixed model by performing cross-validation to estimate the optimal value of the tuning parameter tau. It finally uses the optimal tau value in the lmer function from the lme4 package for model fitting. (Only consider one random effect variance)

Usage

cat_lmm_tune(cat_init, tau_seq = NULL, cross_validation_fold_num = 5)

Arguments

cat_init

A list generated from cat_lmm_initialization.

tau_seq

A numeric vector specifying the sequence of tau values to be tested. If NULL, a default sequence is generated based on the number of predictors.

cross_validation_fold_num

An integer representing the number of folds for cross-validation. Defaults to 5.

Value

A list containing the values of all the arguments and the following components:

tau

The optimal tau value determined from cross-validation.

model

The fitted lmer model object by using the optimal tau value.

coefficients

Coefficients of the fitted model by using the optimal tau value.

risk_estimate_list

Average prediction errors for each tau value.

Examples

data(mtcars)
cat_init <- cat_lmm_initialization(
  formula = mpg ~ wt + (1 | cyl), # formula for simple model
  data = mtcars,
  x_cols = c("wt"), # Fixed effects
  y_col = "mpg", # Response variable
  z_cols = c("disp", "hp", "drat", "qsec", "vs", "am", "gear", "carb"), # Random effects
  group_col = "cyl", # Grouping column
  syn_size = 100, # Synthetic data size
  resample_by_group = FALSE, # Resampling option
  resample_only = FALSE, # Resampling method
  na_replace = mean # NA replacement method
)

cat_model <- cat_lmm_tune(
  cat_init = cat_init, # Only accept object generated from cat_lmm_initialization
  tau_seq = c(1, 2), # Vector of weights for synthetic data
  cross_validation_fold_num = 3 # number of folds for cross-validation
)
cat_model


catalytic documentation built on April 4, 2025, 5:51 a.m.