Once a brand object carries funnel stages and scored attributes,
g6tr.brand offers three models. This vignette shows how to
run each on the bundled Sentinel data.
-
brand_model_attribute_effect()– the primary model. It fits a hierarchical Stan model with a respondent-level utility for every attribute, so the fitted effects can be sliced across cohorts withbrand_summarize_effect(). Use it to learn what drives a funnel outcome. -
brand_model_attribute_effect_cohort()– a lightweight per-cohort benchmark. It refits one fast aggregate logistic model per cohort. Use it when there are too few datapoints for respondent-level utilities, or as a check on the sliced heterogeneous model. -
brand_model_attribute_performance()– how each brand performs on the attributes (a brand-level model viabrms), rather than how attributes drive the funnel.
The effect models require cmdstanr and the performance model requires brms; both compile a model on first use. The fitting chunks below are therefore shown but not run when this vignette is built.
A brand ready to model
We build a brand from the bundled Sentinel funnel stages and
attributes, attach respondent segments, and score the attribute ratings.
(See vignette("basic-brand-workflow") for the data-prep
details.)
funnel_stages <- brand_funnel_stages
brand <- brand_create(
respondents = unique(funnel_stages$awareness$response_id),
brands = unique(funnel_stages$awareness$brand)
) |>
brand_add_funnel_stage(funnel_stages$awareness, "awareness", repair = TRUE) |>
brand_add_funnel_stage(
funnel_stages$consideration, "consideration",
parent_stage = "awareness", repair = TRUE
) |>
brand_add_funnel_stage(
funnel_stages$usage, "usage",
parent_stage = "awareness", repair = TRUE
) |>
brand_add_attributes(brand_attributes$default) |>
brand_add_data(brand_additional_data, by = c("response_id", "brand"))
brand$attributes[["default"]] <- brand$attributes[["default"]] |>
mutate(
score = brand_score_attributes(
response,
dont_know_levels = "I don't know"
),
score_integer = brand_score_attributes(
response,
method = "integer",
dont_know_levels = "I don't know"
)
)
brand
#>
#> ── Brand Analysis ──────────────────────────────────────────────────────────────
#> Respondents: 1047
#> Brands: 18 ("Johnson Controls", "Siemens", "Honeywell", "Schneider Electric",
#> "Trane", "Carrier", "Emerson", "Bosch", "IEC", "Daikin", "GEA Heating &
#> Refrigeration", "Edwards", "Potter", "Brightly", "Brainbox AI", "Vertiv",
#> "Stulz", and "Airedale")
#> Funnel stages: 3
#> awareness [OK]
#> ├──▶ consideration [OK]
#> └──▶ usage [OK]
#> NPS attached: FALSE (use `brand_add_nps()` to add NPS data)
#> Attributes: 12
#> • "Delivers high-performing products and solutions"
#> • "Offers reliable products and solutions"
#> • "Is knowledgeable about what really matters for your industry and/or building type"
#> • "Offers products and solutions using the latest cutting-edge technology"
#> • "Provides good value for money"
#> • "Is easy to do business with"
#> • "Delivers strong technical service and support"
#> • "Delivers strong customer service generally"
#> • "Operates in an environmentally responsible way"
#> • "Helps you achieve your energy efficiency goals"
#> • "Helps you achieve your decarbonization goals"
#> • "Provides products, solutions, and services in precision-performance, mission-critical settings"
#> Weights: all 1
#> Data: 15 additional columns attached
#> Effect models: 0
#> Performance models: 0Attribute effect model
brand_model_attribute_effect() fits the heterogeneous
model on the filtered rows. Feature engineering (scale,
remove_response_bias, remove_brand_bias)
happens inside the model, on the modeled rows, so you pass the raw
attribute score.
brand <- brand_model_attribute_effect(
brand = brand,
dep_var = "consideration",
filter_expr = "funnel$awareness == 1"
)Each fit is stored as one row in brand$models$effect.
Replication settings live in a packed parameters column and
diagnostics in measures, including events-per-predictor
(epv).
brand$models$effect
brand$models$effect$measuresWeighted attribute effects come from
brand_summarize_effect(), overall or sliced by a
cohort:
brand_summarize_effect(brand)To partially pool the effects across a respondent segment, pass
group_vars:
brand <- brand_model_attribute_effect(
brand = brand,
dep_var = "usage",
filter_expr = "funnel$awareness == 1",
group_vars = "s_commercial_role",
name = "usage_by_role"
)Per-cohort benchmark
brand_model_attribute_effect_cohort() refits one fast
aggregate logistic model per cohort, so you can compare
attribute effects across respondent groups instead of relying on a
single heterogeneous fit. It takes a cohort set built
with g6tr.cohorts::create_cohort_set() – a table of
respondent groups. Here we split respondents by their commercial
role:
respondent_roles <- brand$data |>
distinct(response_id, s_commercial_role) |>
filter(!is.na(s_commercial_role))
cohorts <- g6tr.cohorts::create_cohort_set(
respondent_roles,
id_col = "response_id",
grp_cols = "s_commercial_role"
)
#> ℹ No weights provided. Using equal weights of 1.
cohorts
#> Cohort Set
#> # A tibble: 5 × 6
#> column label level cohort n weighted_n
#> <chr> <chr> <chr> <list> <int> <dbl>
#> 1 population Overall population popu… <cohort> 1047 1047
#> 2 s_commercial_role Which of the following best… Comm… <cohort> 206 206
#> 3 s_commercial_role Which of the following best… Comm… <cohort> 397 397
#> 4 s_commercial_role Which of the following best… Comm… <cohort> 251 251
#> 5 s_commercial_role Which of the following best… Comm… <cohort> 193 193The set carries an “Overall population” cohort plus one per role. Passing it fits one model per cohort:
brand <- brand_model_attribute_effect_cohort(
brand = brand,
dep_var = "consideration",
filter_expr = "funnel$awareness == 1",
cohort = cohorts,
name = "consideration_by_role"
)The results mirror models$effect, but with one
registry row per cohort and the same packed
parameters and measures (including
epv – watch it fall on the smaller roles) plus an
effects list-column of attribute-level effects.
brand$models$cohort_effect
brand$models$cohort_effect$measures
brand$models$cohort_effect$effects[[1]]Use cohort = NULL instead to fit a single benchmark on
the whole filtered population.
Attribute performance model
brand_model_attribute_performance() models how each
brand performs on the attributes, using the integer-scored ratings.
brand <- brand_model_attribute_performance(
brand = brand,
attr_score_name = "score_integer",
filter_expr = "funnel$usage == 1",
attribute_names = c(
"Offers reliable products and solutions",
"Provides good value for money",
"Is easy to do business with"
),
name = "performance_users"
)The brand-level effects are stored in
brand$models$performance:
brand$models$performance
brand$models$performance$performance_effects[[1]]Once fit, all three registries live on the brand object
and are saved and reloaded with it, so downstream summaries and plots
(brand_summarize_effect(),
brand_plot_attribute_effect(),
brand_plot_attribute_performance()) work without
refitting.