Calculating ratios
Protobi is smart enough to make calculating ratios simple
Let's say your survey asked for quantities in absolute counts. But now you want the option to report them as percentages. This tutorial demonstrates how you can do just that, and correctly preserve percentages, frequencies and averages.
Example
Here, we have two questions:
- S8: How many patients do you treat for Condition X?
- Q2: How many of those patients do you treat with the following therapies?
To create a new group that displays percentages of respondents' patients being treated with each different therapy we need to calculate a ratio (Q2_x / S8).
Clone the group (optional)
You might want to clone Q2 to create a new group for the ratio values (see Move, mirror, clone tutorial.) You don't have to clone the element unless you want to see both the original counts and the ratio. In this example, we've opted to clone Q2 and name the new group Q2vS8. It's necessary to use a recursive clone because we want to clone the parent group, but also create independent copies of its children.
Set denominator
For the new group, press the square edit icon and choose "More properties..." from the context menu. Then, next to "denominator" enter "S8".
Scale the percentages to 100
In the same properties dialog, set the "scale" to 100. As an analyst you may be familiar seeing percentages in the interval of 0 to 1. But your client may prefer to see ratio on an interval of 0 to 100.
Result
Voilá! After setting denominator, and using a scale of 100, we now have a new group that is defined as Q2_x / S8.
Additional options
Select custom value bins
Press the square edit icon and choose "Round by..." to create custom rounding for the group. For a question measured in percentage, we recommend rounding by 20.
Zero-fill [NA] values
If some respondents were counted as [NA], and you want those values to count as 0 you can showMissing and recode [NA]s to "0".
1. Choose "More properties..." from the context menu. Then, next to "showMissing" choose "Yes".
2. Choose "Recode..." from the context menu. Drag [NA] over to the "(New code)" button and name it "0".
Limit the question to a subset of respondents
If you want to consider only a certain subset of respondents for the question, create a permanent filter on the group.
In the example below, we want to limit the responses in Q2vS8 to respondents who indicated they are a "Practice Nurse" in S1.
First, press "Practice Nurse" in S1 to create a filter.
Then, choose "Filters..." from Q2vS8 context menu and apply the current filters.
The element is now permanently limited to Practice nurses, and this is automatically labeled in the footnote.
Edit footnotes
Footnotes can be edited directly by pressing on the existing footnote text.
You can also edit footnotes in "More properties..." from the context menu. Next to "footnote" enter your text.
Scale bars using maxValue
If you prefer not to scale percentages to 100, then you might want to scale the bars. By default bars are scaled to 100, but if the percentages are being displayed in the interval of 0 to 1, the default setting won't be ideal.
Set "maxValue" under "More properties..." to reference a value by which to scale bars for the element or group. This is useful when compacting to mean, so that bars can be drawn for means relative to some value.
Q3 compacted to mean, without maxValue:
After maxValue is set to 1:
Calculate ratio averages
By default, when you use the "denominator" property, the mean is intelligently weighted to show the ratio average, (i.e., the sum of numerators over sum of denominators, excluding rows with missing values for either).
Calculate simple ratios
If you want to calculate a simple ratio, Protobi's default calculation method can be turned off. To calculate average of ratios-- as in, calculate Q2_x/Q8 for each respondent, and then average the resulting ratios, you can turn ratioMean off be using the attribute in JSON:
"ratioMean":false
Q2vS8 turning "ratioMean" off: