The experimental design and respondent choices are required. These may be provided together (as an Experiment question or Sawtooth CHO format file), or separately with the design as an experimental design R output, Sawtooth dual file or JMP file, plus respondent choices and tasks as variables. Simulated responses may be used in place of respondent choices.

## Example

The table below shows the output of the analysis, containing histograms of the estimated parameters of the respondents:

## Options

**Design source** The source of the experimental design. Choices include Data set, Experimental design R output, Sawtooth CHO format, Sawtooth dual file format as data set, JMP format as data set and Experiment question.

**Version** A variable containing the version indices (first column) from the (Sawtooth or JMP) design file, which has been uploaded as a data set.

**Task** A variable containing the task indices (second column) from the (Sawtooth or JMP) design file, which has been uploaded as a data set.

**Attributes** Variables containing the attributes from the (Sawtooth or JMP) design file, which has been uploaded as a data set.

**Experimental design** A Choice Model Design output.

**CHO file text variable** A text variable of lines from the CHO file, which has been uploaded as a data set. Note that the CHO file first needs to be renamed to have a file extension of .txt instead of .cho, so that it can be uploaded to Q as a data set.

**Enter attribute levels** Attribute levels for the design that are entered into a spreadsheet-style data editor. Each column begins with an attribute name and is followed by its attribute levels.

**Code some categorical attributes as numeric** Whether to treat some categorical attributes as numeric. If checked, a text box will appear below to allow the attribute and numeric coding to be specified as a comma-separated list, e.g. Weight, 1, 2, 3, 4. When one text box is filled, another text box will appear for another attribute to be specified.

**Experiment question** A choice-based conjoint Experiment question.

**Data source** The respondent choice data to use, where the options differ based on which *Design source* was chosen. One option is to use simulated choices from priors. If this is checked, a button called "Enter priors" will appear immediately below, allowing priors to be entered. The format of the priors needs to follow those for Choice Modeling - Experimental Design.

**Respondent IDs** A variable containing respondent IDs corresponding to those in the CHO file.

**Prior source** Choose between using priors from the choice model design output or manually entering the priors. If the design output contains no priors, prior means and standard deviations of 0 are assumed. Available when *Experimental Design* is selected as the *Data source*.

**Simulated sample size** The number of simulated respondents to generate.

**Choices** Variables containing the choices made by respondents.

**Tasks** Variables containing the sets of tasks that have been presented to respondents.

**Version** A variable containing the versions of tasks presented to respondents.

**Missing data** See Missing Data Options.

**Type** The type of model to fit. The options are *Latent Class Analysis* and *Hierarchical Bayes*.

**Number of classes** The number of classes in the latent class analysis over respondents.

**Questions left out for cross-validation** The number of questions to leave out per respondent to be used for cross-validation.

**Alternative-specific constants** Whether to include alternative-specific constants in the model.

**Iterations** The number of iterations used in the Hierarchical Bayes analysis.

**Chains** The number of chains used in the Hierarchical Bayes analysis.

**Respondent-specific covariates** Variables containing respondent-specific covariates to be included in the model.

**Maximum tree depth** The maximum tree depth parameter. Only increase this if warnings about "tree depth" are shown.

**Iterations saved per individual** The number of Hierarchical Bayes utility draws to be saved per individual respondent. Draws are used in simulation. The maximum permitted number is *Iterations* * *Chains* / 2.

## Technical Details

An R package called `flipChoice` is used to run the Hierarchical Bayes analysis. `flipChoice` uses `rstan` to fit the underlying Bayesian statistical model, which is itself an R interface for Stan.

## Next

A worked example including video is available in this blog post

For further information on Hierarchical Bayes modeling, please refer to chapter 5 from *Bayesian Statistics and Marketing*.