This function generates probability-based summaries for each simple factor term
in a conjoint task model. A "simple factor term" is a factor that appears in the model
formula as a main effect (e.g., service in response ~ service + scenario). Even
if a factor also participates in interactions, we still produce level probabilities
for its main term, but highlight that these summaries may not capture interaction effects.
Level summaries work as follows:
For each respondent, we extract the part-worth utility (pwu) for each level of that factor.
We convert these PWUs to probabilities, normalize them by respondent, and average across respondents.
Levels are sorted in descending order by this aggregated probability.
We calculate p-values for each level in two ways:
vs. the “below” level (the next highest probability), using a paired test across respondents.
vs. a “median” or “middle” level. If the number of levels is odd, we use the central level’s probability vector; if even, we average the two middle vectors.
We also compute attribute importance for these factors by:
Calculating each respondent’s range of PWU (max - min) per attribute.
Scaling these ranges within each respondent so that they sum to 100%.
Averaging the scaled percentages, yielding an overall importance with p-values similar to the level comparisons.
Note that attribute importance is only truly meaningful when all predictors are simple factor terms without interactions or continuous variables. We still calculate importance if interactions or continuous predictors exist, but please interpret these values with caution.
Arguments
- model
A fitted conjoint task model object of class
cjt_model- cohorts
A
cohortorcohort_setobject for analyzing specific respondent cohorts, orNULLfor full dataset analysis. Create cohorts usingcreate_cohort()orcreate_cohort_set().- attributes
Character. Attribute levels to show summary for. If set to NULL (default), all attribute are shown.
Value
A tibble containing:
For model-only or single
cohort: level summaries with probabilities and significance testsFor
cohort_set: nested level summaries for each cohort in the set
Examples
library(dplyr)
#>
#> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’:
#>
#> filter, lag
#> The following objects are masked from ‘package:base’:
#>
#> intersect, setdiff, setequal, union
library(g6tr.cohorts)
#>
#> Attaching package: ‘g6tr.cohorts’
#> The following objects are masked from ‘package:base’:
#>
#> intersect, setdiff, union
# Create a model
mod <- cjt_model(
nn_choice + allows_none(drn_sub_buy_choice) ~ service + scenario,
data = example_cjt_fp_drn_flat_data,
id_col = id,
task_col = task,
mcmc = list(R = 200, use = 200)
)
#> Logit Data
#> ==================================================
#> Attribute Type Levels
#> -----------------------------------
#> Attribute 1 Linear 1
#> Attribute 2 Linear 1
#> Attribute 3 Linear 1
#> Attribute 4 Linear 1
#> Attribute 5 Linear 1
#> Attribute 6 Linear 1
#> Attribute 7 Linear 1
#> Attribute 8 Linear 1
#> Attribute 9 Linear 1
#> Attribute 10 Linear 1
#> Attribute 11 Linear 1
#> Attribute 12 Linear 1
#> Attribute 13 Linear 1
#> Attribute 14 Linear 1
#>
#> 14 parameters to be estimated.
#>
#> 843 total units.
#> Average of 3.5 alternatives in each of 24 sets per unit.
#> 20232 tasks in total.
#>
#> Table of choice data pooled across units:
#> Choice Count Pct.
#> --------------------
#> 1 5224 25.82%
#> 2 6575 32.5%
#> 3 4399 21.74%
#> 4 4034 19.94%
#>
#> MCMC Inference for Hierarchical Logit
#> ==================================================
#> Total Iterations: 200
#> Draws used in estimation: 200
#> Units: 843
#> Parameters per unit: 14
#> Constraints not in effect.
#> Draws are to be saved.
#> Prior degrees of freedom: 5
#> Prior variance: 2
#>
#> MCMC Iteration Beginning...
#> Iteration Acceptance RLH Pct. Cert. Avg. Var. RMS Time to End
#> 100 0.357 0.389 0.220 0.40 0.45 0:02
#> 200 0.302 0.505 0.432 1.55 1.15 0:00
#>
#> Total Time Elapsed: 0:04
#>
#> Writing estimated unit-level betas to Rbetas.csv in the working directory
#>
#> Writing RLH, the geometric mean of the likelihood of the choices made,
#>
#> across the choice sets of each unit to RLH.csv in the working directory
#>
# Get level summaries for full dataset
cjt_level_summary(mod)
#> ℹ No weights provided. Using equal weights of 1.
#> # A tibble: 2 × 6
#> term level_summaries importance attr_pval_vs_below attr_pval_vs_median
#> <chr> <list> <dbl> <dbl> <dbl>
#> 1 service <tibble [9 × 5]> 0.750 4.46e-314 4.46e-314
#> 2 scenario <tibble [6 × 5]> 0.250 NA 4.46e-314
#> # ℹ 1 more variable: indiv_importance <named list>
## Get level summaries for a specific attribute
cjt_level_summary(mod, attributes = "service")
#> ℹ No weights provided. Using equal weights of 1.
#> Warning: Using provided subset of `attributes`: "service"
#> ! Attribute importance statistics will likely be misleading.
#> # A tibble: 1 × 6
#> term level_summaries importance attr_pval_vs_below attr_pval_vs_median
#> <chr> <list> <dbl> <dbl> <dbl>
#> 1 service <tibble [9 × 5]> 1 NA NaN
#> # ℹ 1 more variable: indiv_importance <named list>
# Get level summaries for a specific cohort (Italy)
italy_cohort <-
example_cjt_fp_drn_survey |>
filter(country == "Italy") |>
create_cohort(
id_col = response_id,
weight_col = weight
)
cjt_level_summary(mod, italy_cohort)
#> # A tibble: 2 × 6
#> term level_summaries importance attr_pval_vs_below attr_pval_vs_median
#> <chr> <list> <dbl> <dbl> <dbl>
#> 1 service <tibble [9 × 5]> 0.744 9.71e-146 9.71e-146
#> 2 scenario <tibble [6 × 5]> 0.256 NA 9.71e-146
#> # ℹ 1 more variable: indiv_importance <named list>
# Get level summaries for multiple cohorts
my_cohort_set <- create_cohort_set(
example_cjt_fp_drn_survey,
id_col = response_id,
grp_cols = c(country, m3_customer),
weight_col = weight
)
cjt_level_summary(mod, my_cohort_set)
#> # A tibble: 5 × 4
#> column label level summaries
#> <chr> <chr> <chr> <list>
#> 1 population Overall population population <tibble [2 × 6]>
#> 2 country NA Italy <tibble [2 × 6]>
#> 3 country NA Spain <tibble [2 × 6]>
#> 4 m3_customer NA Customer <tibble [2 × 6]>
#> 5 m3_customer NA Non-Customer <tibble [2 × 6]>