Creates a tibble containing all possible combinations of predictor values from a fitted conjoint task model. For numeric predictors, equidistant points are used, while for categorical predictors, all levels are included.
Arguments
- model
A fitted conjoint task model object of class
cjt_model- n_numeric_points
Number of equidistant points to use for numeric predictors (default: 5). For example, if a numeric predictor ranges from 1 to 5, with n_numeric_points = 5, the values 1, 2, 3, 4, and 5 will be used.
- max_combinations
Maximum allowed number of combinations (default: 1e7) to prevent memory issues with very large combinations.
Value
A tibble containing all possible combinations of predictor values, with columns:
- concept_id
Unique identifier for each combination
- ...
One column for each predictor in the model
Examples
library(dplyr)
# Create example data
example_cjt_flat_data <-
example_cjt_fp_drn_flat_data |>
select(-c("country", "m3_customer", "m3_sub_interest")) |>
mutate(price = runif(n(), 5, 12))
# Create a conjoint model with example data
mod <- cjt_model(
nn_choice + allows_none(drn_sub_buy_choice) ~ scenario + service + price,
data = example_cjt_flat_data,
id_col = id,
task_col = task
)
#> 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
#> Attribute 15 Linear 1
#>
#> 15 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: 15
#> 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.345 0.384 0.217 0.15 0.26 0:02
#> 200 0.303 0.485 0.404 0.55 0.67 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
#>
# Generate all possible combinations
concepts <- generate_concepts(mod, n_numeric_points = 3)
#> ℹ Using 3 equidistant points for numeric predictors
#> ℹ For custom numeric values, consider building concepts manually using
#> tidyr::crossing()
#> ℹ and joining with your desired numeric sequences
concepts
#> # A tibble: 162 × 4
#> concept_id scenario service price
#> <int> <chr> <chr> <dbl>
#> 1 1 Scenario 1 Apple Music 5.00
#> 2 2 Scenario 1 Apple Music 8.50
#> 3 3 Scenario 1 Apple Music 12.0
#> 4 4 Scenario 1 Apple One Family and AppleCare+ 5.00
#> 5 5 Scenario 1 Apple One Family and AppleCare+ 8.50
#> 6 6 Scenario 1 Apple One Family and AppleCare+ 12.0
#> 7 7 Scenario 1 Apple One Premier 5.00
#> 8 8 Scenario 1 Apple One Premier 8.50
#> 9 9 Scenario 1 Apple One Premier 12.0
#> 10 10 Scenario 1 AppleCare+ and iCloud+ 200GB 5.00
#> # ℹ 152 more rows