+xHi,
I am relatively new to inquisit and have started to create some experiments as well as surveys. In one of the surveys, I am measuring BMI. Due to the fact that there are differences across gender when it comes to categorizing people based on their BMI, I wanted to use the raw BMI score in order to assign people to different weight groups conditional on sex. I have used a nested statement within an expression in order to do so. As long as I don't include this newly created expression within my summary data everything is fine, but once I enter it, inquisit shuts down at the end of the survey after all survey items have been filled in and the finish button has been pressed. Strangely, I am able to run the survey, and I don't get any kind of error messages. This makes it hard for me as a novice to figure out what exactly is wrong with my code. Since I don´t get any summary files for these runs, I am absolutely sure that the problem arises due to adding this expression to the summary data.
This is the code for the expression:
/ BMICAT = {(if radiobuttons.Geschlecht.response == 1)
{
if (expressions.BMI < 20)
{
expressions.BMICAT == 1;
}
else if (expressions.BMI >= 20 && expressions.BMI < 25)
{
expressions.BMICAT == 2;
}
else if (expressions.BMI >= 25 && expressions.BMI <30)
{
expressions.BMICAT == 3;
}
else if (expressions.BMI >= 30 && expressions.BMI < 35)
{
expressions.BMICAT == 4;
}
else if (expressions.BMI >= 35 && expressions.BMI < 40)
{
expressions.BMICAT == 5;
}
else if (expressions.BMI >= 40)
{
expressions.BMICAT == 6;
}
}
}
This is just the code for males (thus having answered radiobuttons.Geschlecht with response 1).
Hope that somebody can help me out and tell me what exactly went wrong, so that I can adapt the code.
Cheers,
Kugel
expressions.BMICAT == 1;
#1: == would be the wrong operator. == is a logical operator, = would be the assignment operator.
#2: You are trying to re-write expressions.bmicat itself.
Barring other mistakes in any of the other expressions you did not include, the correct formulation would be:
<values>
/ rand_BMI = round(rand(1,50))
</values>
<expressions>
/ BMI = values.rand_bmi
/ BMICAT = if(radiobuttons.Geschlecht.response == 1)
{
if (expressions.BMI < 20) 1;
else if (expressions.BMI >= 20 && expressions.BMI < 25) 2;
else if (expressions.BMI >= 25 && expressions.BMI <30) 3;
else if (expressions.BMI >= 30 && expressions.BMI < 35) 4;
else if (expressions.BMI >= 35 && expressions.BMI < 40) 5;
else if (expressions.BMI >= 40) 6;
}
</expressions>
<surveypage mypage>
/ caption = "Randomly generated BMI for testing purposes: <%values.rand_bmi%>"
/ questions = [1=geschlecht]
</surveypage>
<radiobuttons geschlecht>
/ options = ("male", "female")
/ optionvalues = ("1", "2")
</radiobuttons>
<survey mysurvey>
/ pages = [1=mypage]
</survey>
<summarydata>
/ columns = [script.subjectid radiobuttons.geschlecht.response values.rand_bmi expressions.bmicat]
/ separatefiles = true
</summarydata>