Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

how to generate 0-1 variable by fixed possibility

  • qiangqi
  • qiangqi's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
1 year 1 month ago #240124 by qiangqi
Hi Joffm,

I establish a simple choice question and respondent could give me an answer, for example, 20%. And then, I want to get a result 0 or 1 in the next equation question and the result is 1 with a possibility of 20% and 0 with 80%. I don't know how to achieve this.

Best,
Qiang

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 1 month ago #240198 by Joffm
Did you try any of my proposals I gave four days ago?

And please, do not expect anything from me, if you if you are not able to explain what exactly you want to achieve?
Like
I have this single question
 


and I want the following result
If the respondent selects 20% there is a new variable (proz20) set to 1, otherwise to 0
If the respondent selects 50% there is a new variable (proz50) set to 1, otherwise to 0

And exactly this I showed in my proposals
Otherwise you have to use some equations, like
eq20: {if(Q1=="20",1,0)}
eq50: {if(Q1=="50",1,0)}
...


Or do you want to calculate the result and talk about probability?

and the result is 1 with a possibility of 20% and 0 with 80%.

You can do this:
Create a random number (0-100)
Now you can say {if(Q1=="20",if(randnum le 20,1,0),if(Q1=="50",if(randnum le 50,1,0),if(Q1=="80",if(randnum le 80,1,0),0)))}
Now
if the respondent selects "20" he will get a "1" with a probability of 20% and a "0" with a probability of 80%
if the respondent selects "50" he will get a "1" with a probability of 50% and a "0" with a probability of 50%
...

Do you want to achieve this?

Sorry, till now nobody seems to know.

Joffm
​​​​​​​

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

  • qiangqi
  • qiangqi's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
1 year 1 month ago #240204 by qiangqi
Hi Joffm,

The last section you give is what I want. Getting a random 0 or 1 with a different possibility. Thanks for your help.

Best,
Qiang

Please Log in to join the conversation.

Lime-years ahead

Online-surveys for every purse and purpose