Model Attribute Effects With Respondent-Level Utilities and Stability Rounds
Source:R/brand_model_attribute_effect.R
brand_model_attribute_effect.Rdbrand_model_attribute_effect() fits a hierarchical Stan model with
one respondent-specific utility for each attribute, optional group-level
utility shifts, and optional baseline respondent / brand intercept controls.
The fitted respondent-level utilities can then be sliced with
brand_summarize_effect() across cohorts and cohort sets.
Usage
brand_model_attribute_effect(
brand,
filter_expr = NULL,
dep_var,
family = c("bernoulli_logit", "cumulative_logit", "gaussian"),
group_vars = NULL,
control_brand = TRUE,
control_respondent = FALSE,
attr_set_name = "default",
attr_score_name = "score",
na_replace = NA,
scale = TRUE,
remove_response_bias = FALSE,
remove_brand_bias = FALSE,
name = dep_var,
warmup = 750,
iter = 1000,
stable_prop = 0.5,
stable_max_rounds = 0,
chains = 4,
parallel_chains = 4,
seed = 777,
refresh = 400,
include_draws = FALSE,
include_stanfit = FALSE,
...
)Arguments
- brand
A
g6tr_brandobject created withbrand_create().- filter_expr
Optional filter expression applied before modeling. This can refer to packed funnel stages as
funnel$awarenessor to unpacked stage columns such asawareness.- dep_var
Outcome to model. Use
funnel$stage_namefor packed funnel stages or a column name stored directly inbrand$data.- family
Outcome family. Supported values are
"bernoulli_logit","cumulative_logit", and"gaussian". Defaults to"bernoulli_logit".- group_vars
Optional character vector of respondent-level columns in
brand$dataused for partially pooled attribute-utility shifts. When more than one column is supplied, the columns are combined into one segment key.- control_brand
Logical. If
TRUE, include brand-specific intercepts. Defaults toFALSE.- control_respondent
Logical. If
TRUE, include respondent-specific baseline intercepts in addition to respondent-specific attribute utilities. Defaults toFALSE.- attr_set_name
Attribute set to use. Defaults to
"default".- attr_score_name
Numeric score column inside
brand$attributes[[attr_set_name]]. Defaults to"score". Feature engineering (scale,remove_response_bias,remove_brand_bias) is applied to this raw score on the filtered modeling rows.- na_replace
Value used to impute attribute cells that are missing on otherwise-rated rows. Rows with no attribute ratings are always dropped first. If
NA(default), rows with any remaining missing attribute are dropped explicitly instead of imputed. Applied before scaling.- scale
Logical. If
TRUE(default), z-scale each attribute on the filtered modeling rows so attribute effects are comparable.- remove_response_bias
Logical. If
TRUE, subtract each respondent's mean from their attribute scores before scaling. Defaults toFALSE.- remove_brand_bias
Logical. If
TRUE, subtract each brand's mean from the attribute scores before scaling. Defaults toFALSE.- name
Model name stored in
brand$models$effect. Defaults todep_var.- warmup
Number of warmup iterations per chain.
- iter
Number of base post-warmup sampling iterations per chain.
- stable_prop
Proportion of
iteradded in each stability round. Defaults to0.5.- stable_max_rounds
Maximum number of additional stability rounds. Defaults to
1. Use0to disable stability rounds.- chains
Number of chains.
- parallel_chains
Number of parallel chains.
- seed
Random seed.
- refresh
Progress refresh interval passed to CmdStan.
- include_draws
If
TRUE, store posterior draws from the last sampling round in the model registry.- include_stanfit
If
TRUE, store the last CmdStan fit object in the model registry.- ...
Additional arguments forwarded to
cmdstanr::sample().