Creates visualizations of fitted demand curves from a hurdle demand model.
# S3 method for beezdemand_hurdle
plot(
x,
type = c("demand", "population", "probability", "parameters", "individual", "both"),
ids = NULL,
subjects = NULL,
parameters = c("Q0", "alpha", "breakpoint", "Pmax", "Omax"),
prices = NULL,
show_population = TRUE,
show_pred = NULL,
show_observed = TRUE,
x_trans = c("log10", "log", "linear", "pseudo_log"),
y_trans = NULL,
free_trans = 0.01,
facet = NULL,
x_limits = NULL,
y_limits = NULL,
x_lab = NULL,
y_lab = NULL,
xlab = NULL,
ylab = NULL,
style = c("modern", "apa"),
observed_point_alpha = 0.5,
observed_point_size = 1.8,
pop_line_alpha = 0.9,
pop_line_size = 1,
ind_line_alpha = 0.35,
ind_line_size = 0.7,
...
)A ggplot2 object.
An object of class beezdemand_hurdle.
Character string specifying the plot type:
"demand"Predicted demand curves (default)
"population"Alias for "demand"
"probability"Probability of zero consumption
"parameters"Distribution of subject-specific parameters
"individual"Individual demand curves for selected subjects
Optional vector of subject IDs to plot (alias of subjects).
Character or numeric vector of subject IDs to plot for
type = "individual". If NULL, plots first 9 subjects.
Character vector specifying which parameters to plot when
type = "parameters". Options are: "Q0", "alpha",
"breakpoint", "Pmax", "Omax". Default is all five.
Numeric vector of prices for plotting. If NULL,
uses a sequence from 0 to max observed price.
Logical; if TRUE, overlay population-level
curve on individual plots. Default is TRUE.
Which prediction layers to plot: "population", "individual", or "both".
Logical; if TRUE, overlay observed data points.
Character. Transformation for x-axis. Default "log".
Character. Transformation for y-axis. Default "log".
Value used to display free (x = 0) on log scales. Use NULL to drop x <= 0 values instead.
Faceting specification (TRUE for ~id or a formula).
Optional numeric vector of length 2 for x-axis limits.
Optional numeric vector of length 2 for y-axis limits.
Optional x-axis label.
Optional y-axis label.
Deprecated alias for x_lab.
Deprecated alias for y_lab.
Plot styling, passed to theme_beezdemand().
Alpha for observed points.
Size for observed points.
Alpha for population curve.
Line size for population curve.
Alpha for individual curves.
Line size for individual curves.
Additional arguments (currently unused).
# \donttest{
data(apt)
fit <- fit_demand_hurdle(apt, y_var = "y", x_var = "x", id_var = "id")
# Plot mean demand curve
plot(fit)
# Plot parameter distributions
plot(fit, type = "parameters")
# }
Run the code above in your browser using DataLab