Fits a conjoint task model to the provided data using the specified method.
Usage
cjt_model(x, ...)
# Default S3 method
cjt_model(x, ...)
# S3 method for class 'formula'
cjt_model(formula, id_col, task_col, data, formula_covariates = NULL, ...)Arguments
- x
An object. See the method specific implementation.
- ...
Additional arguments passed to the model implementation depending on the method. Currently, only the
ChoiceModelR::choicemodelr()method is implemented. The parameter you'd most often use ismcmc(e.g.,mcmc = list(R = 500, use = 500)).- formula
A formula specifying the model. Wrap outcome names into
allows_none()to mark that they allow the "none" response. For example:nn_choice + allows_none(drn_sub_buy_choice) ~ service + scenario.- id_col
Quoted or unquoted name of the column in
datathat contains unique respondent identifiers.- task_col
Quoted or unquoted name of the column in
datathat contains unique identifiers of tasks within each respondent.- data
A dataframe containing the conjoint task data in tall flat format:
Each row corresponds to an alternative.
Respondents and tasks within respondents are distinguished using the
id_colandtask_colcolumns.Alternative attributes are described in other columns and can be numerics or factors. There are no restrictions on other columns.
See an example data example_cjt_fp_drn_flat_data.
Examples
my_model <- 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.359 0.388 0.219 0.39 0.44 0:02
#> 200 0.299 0.504 0.431 1.62 1.16 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
#>