plot_fit {plsmmLasso}R Documentation

Visualization of estimated mean trajectories and nonlinear functions from a PLSMM

Description

This function plots the observed data, the estimated mean trajectories, and the estimated nonlinear functions from the output of plsmm_lasso.

Usage

plot_fit(x, y, series, t, name_group_var, plsmm_output, predicted = FALSE)

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.

plsmm_output

Output object obtained from the plsmm_lasso function.

predicted

Logical indicating whether to plot predicted values. If FALSE only the observed time points are used.

Details

If predicted is TRUE the function uses the model from plsmm_output to predict unobserved time points on a continuous grid of time.

Value

Two plots:

Examples


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)
lambda <- 0.0046
gamma <- 0.00000001
plsmm_output <- plsmm_lasso(x, y, series, t,
  name_group_var = "group", bases$bases,
  gamma = gamma, lambda = lambda, timexgroup = TRUE,
  criterion = "BIC"
)
plot_fit(x, y, series, t, name_group_var = "group", plsmm_output)


[Package plsmmLasso version 1.0.0 Index]