This article describes how to edit the underlying code in an R-based analysis tool.
Requirements
Please note these steps require a Displayr license.
You will need an analysis tool that was created via the menus.
In this example, we will modify a choice model output for Hierarchical Bayes (created via Anything > Advanced Analysis > Choice Modeling > Hierarchical Bayes) by specifying prior values for the mean parameters. This allows us to impose a constraint on the mean coefficients that the analysis outputs.
Method
1. Select your analysis tool. In this case, our Hierarchical Bayes output.
2. Go to Data > Show Advanced Options > R Code > Edit Code in the object inspector.
3. Scroll down to the bottom where the main function is. Here, the main function is called FitChoiceModel
.
4. If you hover your cursor over the function name, a preview of the R documentation will appear with all the available arguments.
5. Add the following argument line within this function (i.e. before the last line):
hb.prior.mean = c(1, 2, 1, 0, 1, 0, 1, 2, 0),
Assuming you have 9 mean coefficients in your output, this will apply the specified priors to your analysis. The default is 0. Note, that hb.prior.sd
is the equivalent argument for specifying priors for standard deviations.
6. Press Yes when prompted.
7. Press Calculate to run or update your analysis.
Next
How to Use R-based Analysis Tools in Displayr