| plot_hyreg2 | R Documentation |
hyreg2 or hyreg2_hetThis function can be used to visualize the classification based on the model for different variables.
ggplot2::ggplot() is used.
plot_hyreg2(
data,
x,
y,
id_col,
id_df_model,
type_to_plot = NULL,
colors = NULL
)
data |
a |
x |
|
y |
|
id_col |
|
id_df_model |
|
type_to_plot |
|
colors |
|
id_col_df has to be provided anyway, even if the model was estimated without grouping variable.
Since there might be no grouping varibale in the data, we recommend to create a new column called "observation"
in data using the rownames/observationnumbers as charachter values and use this column as
input for id_col in plot_hyreg2, additionally you can then use id_df_model = give_id(data,model,"observation"),
see example
ggplot object visualizing x against y by classes from the model
Svenja Elkenkamp & John Grosser
# estimate a model using simulated_data_rnorm
formula <- y ~ -1 + x1 + x2 + x3 | id
k <- 2
stv <- setNames(c(0.2,0.2,0.2,1,1),c(colnames(simulated_data_norm)[3:5],c("sigma","theta")))
control <- list(iter.max = 1000, verbose = 4)
hyflex_mod <- hyreg2(formula = formula,
data = simulated_data_norm,
type = simulated_data_norm$type,
stv = stv,
k = k,
type_cont = "TTO",
type_dich = "DCE_A",
opt_method = "L-BFGS-B",
control = control,
latent = "cont",
id_col = "id"
)
# plotting the variables id against y
plot_hyreg2(data = simulated_data_norm,
x = "id",
y = "y",
id_col = "id",
id_df_model = give_id(data = simulated_data_norm,
model = hyflex_mod,
id = "id"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.