Modern interface for fitting individual demand curves via nonlinear
least squares. Returns a structured S3 object with standard methods
including summary(), tidy(), and glance().
fit_demand_fixed(
data,
equation = c("hs", "koff", "simplified", "linear", "exponential", "exponentiated"),
k = 2,
agg = NULL,
x_var = "x",
y_var = "y",
id_var = "id",
param_space = c("natural", "log10"),
...
)An object of class beezdemand_fixed with components:
Data frame of fitted parameters for each subject
List of model fit objects (if detailed = TRUE internally)
List of prediction data frames
List of data frames used for each fit
The original function call
The equation form used
Description of k specification
Aggregation method used
Total number of subjects/fits attempted
Number of successful fits
Number of failed fits
Data frame in long format with columns: id, x (price), y (consumption).
Character. Equation type: "hs" (Hursh & Silberberg, 2008),
"koff" (Koffarnus et al., 2015), "simplified" (Rzeszutek et al., 2025;
simplified exponential with normalized decay, no k parameter), or
"linear". The modern aliases "exponential" (equivalent to "hs") and
"exponentiated" (equivalent to "koff") are also accepted. Default "hs".
Scaling constant. Numeric value (fixed), "ind" (individual),
"fit" (free parameter), or "range" (data-driven). Default 2.
Character. Aggregation method: "Mean", "Pooled", or NULL
for individual fits. Default NULL.
Character. Name of the price column. Default "x".
Character. Name of the consumption column. Default "y".
Character. Name of the subject identifier column. Default "id".
Character. Parameterization used for fitting. One of:
"natural": fit Q0, alpha (and k if k = "fit") on their natural scale
"log10": fit log10(Q0), log10(alpha) (and log10(k) if k = "fit")
Additional arguments passed to the underlying FitCurves() engine.
This function is a modern wrapper around the legacy FitCurves() function.
It provides the same fitting capabilities but returns a structured S3 object
with standardized methods for model interrogation.
# \donttest{
data(apt)
fit <- fit_demand_fixed(apt, equation = "hs", k = 2)
print(fit)
summary(fit)
tidy(fit)
glance(fit)
# }
Run the code above in your browser using DataLab