
Plot Method for Mixed-Effects Cross-Price Demand Models
Source:R/cp-methods.R
plot.cp_model_lmer.RdCreates a ggplot2 visualization of a fitted mixed-effects cross-price demand model
(of class cp_model_lmer). This function allows you to plot:
Arguments
- x
A
cp_model_lmerobject (as returned byfit_cp_linear(type = "mixed", ...)).- data
Optional data frame containing columns
xandyto be plotted. If not provided,object$datais used.- inv_fun
Optional function to inverse-transform predictions. Default is
identity. Not typically used for linear models but included for API consistency.- n_points
Number of points to use in creating the prediction grid. Default is
100.- title
Optional title for the plot; default is
NULL.- xlab
Label for the x-axis. Default is
"Price".- ylab
Label for the y-axis. Default is
"Consumption".- x_trans
Transformation for the x-axis; one of
"identity","log10", or"pseudo_log". Default is"identity".- y_trans
Transformation for the y-axis; one of
"identity","log10", or"pseudo_log". Default is"identity".- point_size
Size of the observed data points. Default is
3.- pred_type
Character string specifying which prediction components to plot:
"fixed"Plot only the fixed-effects (population) prediction.
"random"Plot only the subject-specific predictions.
"all"Plot both the fixed-effects and the subject-specific predictions.
The default is
"fixed".- ...
Additional arguments passed to
predict.cp_model_lmer.