plot_subject: Plot Demand Curve for a Single Subject

View source: R/hurdle-methods.R

plot_subjectR Documentation

Plot Demand Curve for a Single Subject

Description

Creates a demand curve plot for a single subject with optional observed data and population reference curve.

Usage

plot_subject(
  object,
  subject_id,
  prices = NULL,
  show_data = TRUE,
  show_population = TRUE,
  style = c("modern", "apa")
)

Arguments

object

An object of class beezdemand_hurdle.

subject_id

The ID of the subject to plot.

prices

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

show_data

Logical; if TRUE, overlay observed data points. Default is TRUE.

show_population

Logical; if TRUE, show population curve. Default is TRUE.

style

Plot styling, passed to theme_beezdemand().

Value

A ggplot2 object.

Examples


data(apt)
fit <- fit_demand_hurdle(apt, y_var = "y", x_var = "x", id_var = "id")
plot_subject(fit, subject_id = "19")



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