In a Computation item, a mathematical computation is executed on the phone of the client, based on the client’s previous answers. However, this computation item is not visible to the client. Only the practitioner can see the results of this computation item on the m-Path dashboard.
Computation items can be used to:
- Compute a sum score or average score of a questionnaire.
- Compute advanced conditional logic.
- Compute new constructs that result from the client’s previous answers.
Example questionnaire ‘computation examples’:
All computations in this article can be tested by using the ‘computation examples’ questionnaire from Freud which can be found in the m-Path questionnaire library. This questionnaire starts with two questions:
- How happy are you now? (label ‘happy’)
- How sad are you now? (label ‘sad’)
How to create a computation item?
- Choose the Computation question type.
- Choose the label of the computation, for example ‘happyPlus50’.
- Type the Mathematical expression, for example ‘[happy]+50’. The value of ‘happyPlus50’ will then be set to 50 plus the answer of the question with label ‘happy’.
- [optional] Fill in the minimum and maximum value for visualization. If this computation question needs to be visualized in a plot, m-Path needs to know its minimum and maximum values. As the minimum and maximum value of the ‘How happy are you now?’ question are 0 and 100, the minimum and maximum value of happyPlus50 are 50 and 150.

Possible mathematical expressions
Normal mathematical expressions
A normal mathematical expression is an expression such as 5+3*2 +4/2. This will give 13 as a result. An absolute value is also possible. For example abs(-5) will result in 5.
Use answers from previous questions
Answers from previous questions can also be used in mathematical expressions. To access these answers, the label of the previous questions is written between [ ] brackets.
E.g. [happy]-[sad] can be used to substract ‘sad’ from ‘happy’ to get some general affect.
Labels from previous computation questions can also be used.
E.g. [happy]+[happyPlus50]

Compute the MEAN, NANMEAN, SUM, MAX and MIN from previous questions
- @MEAN{[happy],[sad]} for the mean of ‘happy’ and ‘sad’.
- @NANMEAN{[happy],[sad],[emptyQuestion]} for the mean, also possible if some questions are not answered.
- @MAX{[happy],[sad]} for the maximum of ‘happy’ and ‘sad’.
- @MIN{[happy],[sad]} for the minimum of ‘happy’ and ‘sad’.
- @SUM{[happy],[sad]} for the sum of ‘happy’ and ‘sad’.
Reverse a score
Use @REVERSE{[happy]} to reverse the score. In this case this is the same as 100-[happy]. If happy7PointLikert is the label of a 7 point likert scale (1 to 7), @REVERSE{[happy7PointLikert]} will result in 7-[happy7PointLikert]+1.
Logical expressions
The following signs can be used to create a logical expression or an equation: >,<,==,<= and >=. If the expression is true, the result will be 1, if not, the result will be 0.
E.g. [happy]>[sad] will result in 1 only if the answer of [happy] was bigger than the answer of [sad].
Random number
Use @Rand{1} to get a random number from a uniform distribution between 0 and 1. Use @Rand{X} to get a random number from a uniform distribution between 0 and X.
Combination of the above
Use the {} brackets to work with nested expressions.
E.g. {@MAX{[happy],[sad]} + {[happy]>[sad]} }*2
Conditional on computation question
Conditions can be defined for computation questions. The interactions or questions in the yes condition will only be shown if the result of the computation question was equal to 1.
E.g. If the expression of the computation question was [happy]>[sad], the condition will be true if happy was actually bigger than sad, which will result in the answer 1 for the computation question (see logical expression above). This is shown in the ‘computation examples’ questionnaire.

Computation questions can also be used to create more advanced conditional structures:
- To create an AND operator, one can use the multiplication of expressions. For example, to make sure happy is bigger than sad AND happy is bigger than 50 AND sad is smaller than 50 the following expression can be used: {[happy]>[sad]}*{[happy]>50}*{[sad]<50}. This will only be 1 if all statements are true.
- To create an OR operator, one can use the plus in an expression. For example, to test if happy is bigger than sad OR happy is bigger than 50 OR sad is smaller than 50 the following expression can be used: {[happy]>[sad]}+{[happy]>50}+{[sad]<50} >= 1. If any of the statements is true, the sum will be 1 or bigger.
- Randomly ask a question: the statement @Rand{1}>0.8 will be true 20% (100-80) of the time. Therefore the conditional question will be triggered 20% of the time.
Use answers from previous questionnaires
Using the load and save functionalities, answers from previous questionnaires can be loaded to execute more advanced expressions and compute an average over time or even time series models.
Examples
Example 1: Intervention after low average affect
In this example we first want to compute an average score of our questionnaire to know the AverageAffect of the participant. Then we want to do an intervention if the participant is feeling bad.
- First we compute ‘AverageAffect’, the mean score. In this case ‘sad’ will be reverse coded: @MEAN{[happy],@REVERSE{[sad]}}.
- Then, conditional on a low ‘AverageAffect’ we do an intervention. We use computation expression [AverageAffect]<20.
See questionnaire ‘computation examples’ for this example.
Example 2: Creation of a new construct
A practitioner may first ask how many beers the client drank today (‘beer’), then how many cocktails (‘cocktail’) and finally how many glasses of wine (‘wine’). To get an overview of the total amount of alcohol consumptions the practitioner can create a computation question that sums all previous alcohol consumptions: [beer]+[wine]+[cocktail].