plot.beezdemand_hurdle: Plot Demand Curves from Hurdle Demand Model

View source: R/hurdle-methods.R

plot.beezdemand_hurdleR Documentation

Plot Demand Curves from Hurdle Demand Model

Description

Creates visualizations of fitted demand curves from a hurdle demand model.

Usage

## S3 method for class '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,
  ...
)

Arguments

x

An object of class beezdemand_hurdle.

type

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

ids

Optional vector of subject IDs to plot (alias of subjects).

subjects

Character or numeric vector of subject IDs to plot for type = "individual". If NULL, plots first 9 subjects.

parameters

Character vector specifying which parameters to plot when type = "parameters". Options are: "Q0", "alpha", "breakpoint", "Pmax", "Omax". Default is all five.

prices

Numeric vector of prices for plotting. If NULL, uses a sequence from 0 to max observed price.

show_population

Logical; if TRUE, overlay population-level curve on individual plots. Default is TRUE.

show_pred

Which prediction layers to plot: "population", "individual", or "both".

show_observed

Logical; if TRUE, overlay observed data points.

x_trans

Character. Transformation for x-axis. Default "log".

y_trans

Character. Transformation for y-axis. Default "log".

free_trans

Value used to display free (x = 0) on log scales. Use NULL to drop x <= 0 values instead.

facet

Faceting specification (TRUE for ~id or a formula).

x_limits

Optional numeric vector of length 2 for x-axis limits.

y_limits

Optional numeric vector of length 2 for y-axis limits.

x_lab

Optional x-axis label.

y_lab

Optional y-axis label.

xlab

Deprecated alias for x_lab.

ylab

Deprecated alias for y_lab.

style

Plot styling, passed to theme_beezdemand().

observed_point_alpha

Alpha for observed points.

observed_point_size

Size for observed points.

pop_line_alpha

Alpha for population curve.

pop_line_size

Line size for population curve.

ind_line_alpha

Alpha for individual curves.

ind_line_size

Line size for individual curves.

...

Additional arguments (currently unused).

Value

A ggplot2 object.

Examples


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")



beezdemand documentation built on March 3, 2026, 9:07 a.m.