plot_fit | R Documentation |
This function plots the observed data, the estimated mean trajectories, and
the estimated nonlinear functions from the output of plsmm_lasso
.
plot_fit(
x,
y,
series,
t,
name_group_var,
plsmm_output,
predicted = FALSE,
show_obs = FALSE
)
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 |
predicted |
Logical indicating whether to plot predicted values. If |
show_obs |
Logical. If |
If predicted
is TRUE
the function uses the model from plsmm_output
to predict unobserved time points on a continuous grid of time.
Two plots:
The first plot shows the observed data and the estimated mean trajectories.
The second plot shows the estimated nonlinear functions.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.