As described in How to Create a Simulator for a Choice Model, a simulator can be automatically constructed from a Displayr choice model. There are three basic ways of modifying a simulator:
- Changing the visual appearance
- Better predicting market share
- Modifying the underlying code (e.g., to create a simulator for two models)
Please note these steps require a Displayr license.
Changing the visual appearance
A simulator is no different from any other Displayr document. Each of the controls in the simulator can be modified in the object inspector (see below), and all the other tools for controlling the appearance of a document (E.g., a dashboard) can also be used to modify the simulator. See Design Your Report for more information.
Better predicting market share
A simulator also contains options, such as calibration, to improve its accuracy. See How to Adjust a Simulator to Better Predict Market Share.
Modifying the underlying code (e.g., to create a simulator for two models)
When a simulator is created, a calculation automatically appears below the page. When selected, this simulator contains code (see below).
This code can be modified. For example:
- Code from simulator 1 shows the code from a simulator automatically created by Displayr, where the choice model was shown to a group of people that were not able able to work from home. The model used to create the simulator has three attributes, as does the simulator.
- Code from simulator 2 contains the code from the second group of respondents, who saw the same attributes as the respondents in simulator 1 but also saw an additional attribute relating to working from home.
-
Combined code shows code that was used to create a single simulator using both models. A few key features:
- This code replaced the code that was used for Simulator 2. That is, the code was hooked up to the controls used in the second simulator.
- The code from the two simulators are just pasted on top of each other.
- The code from the first simulator is modified, replacing the names of the controls in the first simulator with the names of the controls in the second simulator. For example, cSalary__compared_to_current_.2 has been replaced with cSalary__compared_to_current_.2.1.
- The final line of code contains the results of the two simulators, weighting the first simulator to 60% and the second to 40%.
Code from simulator 1
scenario = list('Alternative 1' = list('Salary (compared to current)' = cSalary__compared_to_current_.1,'When company commits to become carbon neutral' = cWhen_company_commits_to_become_carbon_neutral.1,'Software you will use in your role' = cSoftware_you_will_use_in_your_role.1), 'Alternative 2' = list('Salary (compared to current)' = cSalary__compared_to_current_.2,'When company commits to become carbon neutral' = cWhen_company_commits_to_become_carbon_neutral.2,'Software you will use in your role' = cSoftware_you_will_use_in_your_role.2), 'Alternative 3' = list('Salary (compared to current)' = cSalary__compared_to_current_.3,'When company commits to become carbon neutral' = cWhen_company_commits_to_become_carbon_neutral.3,'Software you will use in your role' = cSoftware_you_will_use_in_your_role.3), 'Alternative 4' = list('Salary (compared to current)' = cSalary__compared_to_current_.4,'When company commits to become carbon neutral' = cWhen_company_commits_to_become_carbon_neutral.4,'Software you will use in your role' = cSoftware_you_will_use_in_your_role.4)) preference.shares <- PreferenceShares(formChoiceModel, scenario = scenario, rule = formRule, share.adjustment = c(formScaleToShares, formCalibrateToShares), shares = get0("formShares"), scale = get0("formScale"), offset = get0("formOffset"), availability = formAvailability, subset = QFilter, weights = QPopulationWeight, optimx.controls = list(abstol = 1e-7, maxit = 1000), warn.once = TRUE)
Code from simulator 2
scenario = list('Alternative 1' = list('Salary (compared to current)' = cSalary__compared_to_current_.1.1,'When company commits to become carbon neutral' = cWhen_company_commits_to_become_carbon_neutral.1.1,'Software you will use in your role' = cSoftware_you_will_use_in_your_role.1.1,'Work location' = cWork_location.1), 'Alternative 2' = list('Salary (compared to current)' = cSalary__compared_to_current_.2.1,'When company commits to become carbon neutral' = cWhen_company_commits_to_become_carbon_neutral.2.1,'Software you will use in your role' = cSoftware_you_will_use_in_your_role.2.1,'Work location' = cWork_location.2), 'Alternative 3' = list('Salary (compared to current)' = cSalary__compared_to_current_.3.1,'When company commits to become carbon neutral' = cWhen_company_commits_to_become_carbon_neutral.3.1,'Software you will use in your role' = cSoftware_you_will_use_in_your_role.3.1,'Work location' = cWork_location.3), 'Alternative 4' = list('Salary (compared to current)' = cSalary__compared_to_current_.4.1,'When company commits to become carbon neutral' = cWhen_company_commits_to_become_carbon_neutral.4.1,'Software you will use in your role' = cSoftware_you_will_use_in_your_role.4.1,'Work location' = cWork_location.4)) preference.shares.1 <- PreferenceShares(formChoiceModel, scenario = scenario, rule = formRule, share.adjustment = c(formScaleToShares, formCalibrateToShares), shares = get0("formShares"), scale = get0("formScale"), offset = get0("formOffset"), availability = formAvailability, subset = QFilter, weights = QPopulationWeight, optimx.controls = list(abstol = 1e-7, maxit = 1000), warn.once = TRUE)
Combined code
scenario = list('Alternative 1' = list('Salary (compared to current)' = cSalary__compared_to_current_.1.1,'When company commits to become carbon neutral' = cWhen_company_commits_to_become_carbon_neutral.1.1,'Software you will use in your role' = cSoftware_you_will_use_in_your_role.1.1,'Work location' = cWork_location.1), 'Alternative 2' = list('Salary (compared to current)' = cSalary__compared_to_current_.2.1,'When company commits to become carbon neutral' = cWhen_company_commits_to_become_carbon_neutral.2.1,'Software you will use in your role' = cSoftware_you_will_use_in_your_role.2.1,'Work location' = cWork_location.2), 'Alternative 3' = list('Salary (compared to current)' = cSalary__compared_to_current_.3.1,'When company commits to become carbon neutral' = cWhen_company_commits_to_become_carbon_neutral.3.1,'Software you will use in your role' = cSoftware_you_will_use_in_your_role.3.1,'Work location' = cWork_location.3), 'Alternative 4' = list('Salary (compared to current)' = cSalary__compared_to_current_.4.1,'When company commits to become carbon neutral' = cWhen_company_commits_to_become_carbon_neutral.4.1,'Software you will use in your role' = cSoftware_you_will_use_in_your_role.4.1,'Work location' = cWork_location.4)) preference.shares.1 <- PreferenceShares(formChoiceModel, scenario = scenario, rule = formRule, share.adjustment = c(formScaleToShares, formCalibrateToShares), shares = get0("formShares"), scale = get0("formScale"), offset = get0("formOffset"), availability = formAvailability, subset = QFilter, weights = QPopulationWeight, optimx.controls = list(abstol = 1e-7, maxit = 1000), warn.once = TRUE) scenario = list('Alternative 1' = list('Salary (compared to current)' = cSalary__compared_to_current_.1.1,'When company commits to become carbon neutral' = cWhen_company_commits_to_become_carbon_neutral.1.1,'Software you will use in your role' = cSoftware_you_will_use_in_your_role.1.1), 'Alternative 2' = list('Salary (compared to current)' = cSalary__compared_to_current_.2.1,'When company commits to become carbon neutral' = cWhen_company_commits_to_become_carbon_neutral.2.1,'Software you will use in your role' = cSoftware_you_will_use_in_your_role.2.1), 'Alternative 3' = list('Salary (compared to current)' = cSalary__compared_to_current_.3.1,'When company commits to become carbon neutral' = cWhen_company_commits_to_become_carbon_neutral.3.1,'Software you will use in your role' = cSoftware_you_will_use_in_your_role.3.1), 'Alternative 4' = list('Salary (compared to current)' = cSalary__compared_to_current_.4.1,'When company commits to become carbon neutral' = cWhen_company_commits_to_become_carbon_neutral.4.1,'Software you will use in your role' = cSoftware_you_will_use_in_your_role.4.1)) preference.shares.2 <- PreferenceShares(formChoiceModel, scenario = scenario, rule = formRule, share.adjustment = c(formScaleToShares, formCalibrateToShares), shares = get0("formShares"), scale = get0("formScale"), offset = get0("formOffset"), availability = formAvailability, subset = QFilter, weights = QPopulationWeight, optimx.controls = list(abstol = 1e-7, maxit = 1000), warn.once = TRUE) combined.preference.shares = 0.4 * preference.shares.1 + 0.6 * preference.shares.2