tune_plsmm | R Documentation |

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.

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

`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 |

`criterion` |
A character string specifying the criterion to be optimized ( |

`...` |
Additional arguments to be passed to the |

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.

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

`plsmm_lasso`

```
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"
)
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.