Learn R Programming

plsmmLasso (version 1.1.0)

tune_plsmm: Tune Penalized PLSMM

Description

This function tunes a penalized partial linear semiparametric mixed-model (PLSMM) by performing a grid search over a set of hyperparameters to find the best model based on a given criterion.

Usage

tune_plsmm(
  x,
  y,
  series,
  t,
  name_group_var,
  bases,
  gamma_vec,
  lambda_vec,
  timexgroup,
  criterion,
  ...
)

Value

A PLSMM object representing the best-tuned model based on the specified criterion.

Arguments

x

A matrix of predictors.

y

A continuous vector of response variable.

series

A variable representing different series or groups in the data modeled as a random intercept.

t

A numeric vector indicating the time points.

name_group_var

A character string specifying the name of the grouping variable.

bases

A matrix of bases functions.

gamma_vec

A vector of values for the regularization parameter for the coefficients of the nonlinear functions.

lambda_vec

A vector of values for the regularization parameter for the coefficients of the fixed effects.

timexgroup

Logical indicating whether to use a time-by-group interaction. If TRUE, each group in name_group_var will have its own estimate of the time effect.

criterion

A character string specifying the criterion to be optimized ('BIC', 'BICC', 'EBIC').

...

Additional arguments to be passed to the plsmm_lasso function.

Details

This function performs a grid search over the hyperparameters specified by lambda_vec and gamma_vec to find the best-fitted PLSMM based on the given criterion. It fits PLSMMs using the plsmm_lasso function for each combination of hyperparameters and retains only the models that have converged. The best model is selected based on the minimum value of the specified criterion.

See Also

plsmm_lasso

Examples

Run this code
set.seed(123)
data_sim <- simulate_group_inter(
 N = 50, n_mvnorm = 3, grouped = TRUE,
 timepoints = 3:5, nonpara_inter = TRUE,
 sample_from = seq(0, 52, 13),
 cos = FALSE, A_vec = c(1, 1.5)
)
sim = data_sim$sim
x = as.matrix(sim[,-1:-3])
y = sim$y
series = sim$series
t = sim$t
bases = create_bases(t)
lambdas <- c(0.0046, 0.0001)
gammas <- 0.00000001
tuned_plsmm <- tune_plsmm(x, y, series, t,
                      name_group_var = "group", bases$bases,
                      gamma_vec = gammas, lambda_vec = lambdas, timexgroup = TRUE,
                      criterion = "BIC"
)

Run the code above in your browser using DataLab