plot_effects {smoothic} | R Documentation |
Plot conditional density curves
Description
This function plots the model-based conditional density curves for
different effect combinations. For example, take a particular covariate that is selected
in the final model. The other selected covariates are fixed at their median values by default
(see covariate_fix
to fix at other values) and then the plotted red and blue densities
correspond to the modification of the chosen covariate as “low” (25th quantile by default) and
“high” (75th quantile by default).
Usage
plot_effects(
obj,
what = "all",
show_average_indiv = TRUE,
p = c(0.25, 0.75),
covariate_fix,
density_range
)
Arguments
obj |
An object of class “ |
what |
The covariate effects to be plotted, default is |
show_average_indiv |
Should a “baseline” or “average” individual be shown,
default is |
p |
The probabilities given to the |
covariate_fix |
Optional values to fix the covariates at that are chosen in the final model. When not supplied, the covariates are fixed at their median values. See the example for more detail. |
density_range |
Optional range for which the density curves should be plotted. |
Value
A plot of the conditional density curves.
Author(s)
Meadhbh O'Neill
Examples
# Sniffer Data --------------------
# MPR Model ----
results <- smoothic(
formula = y ~ .,
data = sniffer,
family = "normal",
model = "mpr"
)
plot_effects(results)
# Only plot gastemp and gaspres
# Do not show the average individual plot
# Plot the lower and upper density curves using 10th quantile (lower) and 90th quantile (upper)
# Fix violent to its violent to 820 and funding to 40
plot_effects(results,
what = c("gastemp", "gaspres"),
show_average_indiv = FALSE,
p = c(0.1, 0.9),
covariate_fix = c("gastemp" = 70,
"gaspres" = 4))
# The curves for the gastemp variable are computed by fixing gaspres = 4 (as is specified
# in the input). The remaining variables that are not specified in covariate_fix are fixed
# to their median values (i.e., tanktemp is fixed at its median). gastemp is then modified
# to be low (10th quantile) and high (90th quantile), as specified by p in the function.