Jump to content

Help:RiskDisplay

From RiskiPedia

Help:RiskDisplay

The <riskdisplay> tag displays the result of a risk model defined by a RiskModel, typically stored on a "/Data" subpage with related DataTable2 tables. For simple cases or debugging, it can use a direct calculation or custom text. See RiskModel documentation for details on calculations and text formatting.

RiskDisplays are put on pages with DropDown or RiskParameter UI elements to allow users to choose different variables that affect the risk calculation(s).

Syntax

The <riskdisplay> tag requires one of these attributes:

  • `model`: The name of a risk model defined by a <riskmodel> tag (preferred method).
  • `calculation`: A mathematical expression, for simple cases or debugging.

Use either `model` or `calculation`, not both. Optional text inside the tag overrides the model’s description.

Basic syntax:

<riskdisplay model="heart_attack_risk" />

Or with a direct calculation:

<riskdisplay calculation="base_probability * exposure_factor">Your risk is about {result}%</riskdisplay>

Usage

  1. For most cases, use the <riskdisplay> tag with the `model` attribute to reference a <riskmodel>, typically defined on a "/Data" subpage with related DataTable2 tables. This uses the model’s calculation and description.
  2. For simple cases or debugging, use the `calculation` attribute or include text inside the tag to override the model’s description. See RiskModel documentation for calculation and text formatting details.

Examples

Using a Risk Model

Display the result of a risk model named "heart_attack_risk":

<riskdisplay model="heart_attack_risk" />

This uses the calculation and description from the "heart_attack_risk" <riskmodel>, typically defined on a "/Data" subpage.

Using a Direct Calculation

Define a calculation for a simple case or debugging:

<riskdisplay calculation="base_probability * exposure_factor">Your risk is {{One_In_N|{result}}}</riskdisplay>

This computes a result and displays it as "1 in X" (e.g., "1 in 10" for 0.1).

Overriding Model Text

Override the model’s description with custom text:

<riskdisplay model="RiskScore">The weighted risk score is '''{result}''' points</riskdisplay>

This uses the "RiskScore" model’s calculation but displays the result with custom text.

Debugging with Detailed Text

Display raw and formatted results along with a variable for debugging:

<riskdisplay model="AccidentRisk">Raw probability: {result}
Human-friendly probability: {{One_In_N|{result}}}
Odds-ratio: {distraction_odds_ratio}</riskdisplay>

This uses the "AccidentRisk" model’s calculation, showing the raw `{result}`, a human-friendly version via {{One_In_N}}, and the `distraction_odds_ratio` variable.

Notes

  • The `model` attribute is the preferred method, referencing a <riskmodel> typically defined on a "/Data" subpage.
  • Use `calculation` or text inside the tag only for simple cases or debugging.
  • Models can be defined on the current page or a "/Data" subpage.
  • Text formatting, including templates like {{One_In_N|{result}}}, is described in RiskModel documentation.

Troubleshooting

  • **Error: "riskdisplay: missing model= or calculation="** – Include either the `model` or `calculation` attribute.
  • **Error: "riskdisplay: specify either model or calculation, not both"** – Use only one of `model` or `calculation`.
  • **Error: "riskdisplay: can't find riskmodel named X"** – Ensure the `model` name matches a <riskmodel> on the current page or a "/Data" subpage.
  • **Result not displayed** – Check that the referenced model has a valid description, or if overriding, ensure the text includes the `{result}` placeholder. See RiskModel documentation for details.

For related features, see RiskModel documentation or DataTable2 documentation.