Introduction
This article describes how to edit the underlying Standard R code in an R-based output. You will know an output is based in R by the R icon next to the output in the Report tree. Standard R code is written by our developers and encompasses many R outputs. We enable users to further customize our Standard R if they need to directly on the output through the Properties > R CODE box. Keep in mind with doing this, we can't guarantee the output will continue to work as expected since adding custom code may interfere with the Standard R. Proceed with caution!
Requirements
An R-based analysis tool or visualization (denoted by the R icon in the Report tree) 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 the Report tree. In this case, our Hierarchical Bayes output.
2. Go to Properties > R 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 to edit the Standard R code.
7. Press Calculate to run or update your analysis.
Notes
While the example above is very specific, you can edit any part of the R code used to create the output. In addition to editing settings passed through to the analysis/visualization function, you can also create custom code to modify the input data before the analysis or the final output shown and create more custom error handling.