Display a variable according to a probability

HELLO. I survey households and in each household I interview several individuals. The individuals’ questions are in a repeated group. There are 2 note in the repeated group and I would like one note per household to appear at random. A note must appear at random according to the following probabilities. Note 1 with proba 0.6 and Note 2 with proba 0.3
There is one note per household and the note does not change for the individuals in the household. Thank you for helping me

1 Like

Hello Bro,

Can you help me please.
i just sent a message in a forum.
Thanks you

@nohandoye, maybe this post discussed previously should be helpful for you:

Thanks you @Kal_Lam
But have you another example for randomizing questions (not block)?
Thanks

Try something like this:


SimpleForm.xlsx (14.6 KB)

This can go wherever you like, inside a repeat group or not as desired. The important thing is to generate a fixed random number once() - so it doesn’t keep changing - and for the relevant check for each note to test mutually exclusive ranges.

There is one note per household

I observe that, given your prescribed probabilities above, this means 10% of the time a note wont be shown. And that you only show one note of the other [if this is not in fact the case, and both notes can sometimes appear together, then just simplify the relevant check accordingly so they are not mutually exclusive].

Thank you very much @Xiphware . But what can I add to the formula to have a proba that does not change between individuals belonging to the household and a proba that changes only by household?

If you have a repeat iteration for each household, then the ${rnd} calculation goes inside that repeat.

the repeat iteration is only for each household’s member (not for household).

@Xiphware Thanks you very much