| fit_cp_linear | R Documentation |
Fit a Linear Cross-Price Demand Model
fit_cp_linear(
data,
type = c("fixed", "mixed"),
x_var = "x",
y_var = "y",
id_var = "id",
group_var = "group",
target_var = "target",
filter_target = TRUE,
target_level = "alt",
formula = NULL,
log10x = FALSE,
group_effects = FALSE,
random_slope = FALSE,
return_all = TRUE,
...
)
fit_cp_linear.default(
data,
formula = NULL,
log10x = FALSE,
return_all = FALSE,
...
)
fit_cp_linear.mixed(
data,
formula = NULL,
log10x = FALSE,
return_all = FALSE,
...
)
data |
A data frame containing columns for price, consumption, and optionally target indicator, subject identifier, and group. |
type |
The type of model: |
x_var |
Character string; name of the price column. Default is |
y_var |
Character string; name of the consumption column. Default is
|
id_var |
Character string; name of the subject identifier column.
Default is |
group_var |
Character string; name of the group column. Default is
|
target_var |
Character string; name of the target indicator column.
Default is |
filter_target |
Logical; if TRUE (default), filters to rows where the
target column equals |
target_level |
Character string; value of the target column to retain
when |
formula |
Optional formula override. If NULL, a formula will be
constructed based on other parameters. If non-NULL and any |
log10x |
Logical; if TRUE and formula is NULL, uses |
group_effects |
Logical or character; if TRUE, includes group as a factor
with interactions. Can also be |
random_slope |
Logical; for mixed models, if TRUE, includes random slopes for x. Default is FALSE. |
return_all |
Logical; if TRUE, returns additional model metadata. |
... |
Additional arguments passed to underlying modeling functions. |
Fitted linear model.
data(etm)
## Fixed-effects linear cross-price model
fit_fixed <- fit_cp_linear(etm, type = "fixed", group_effects = TRUE)
summary(fit_fixed)
## Mixed-effects linear cross-price model
fit_mixed <- fit_cp_linear(etm, type = "mixed", group_effects = TRUE)
summary(fit_mixed)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.