- Posts: 45
- Thank you received: 0
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
- Topic Author
- Offline
- Senior Member
Less
More
1 year 2 months ago #240124
by qiangqi
Replied by qiangqi on topic how to generate 0-1 variable by fixed possibility
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
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
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12996
- Thank you received: 3999
1 year 2 months ago #240198
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic how to generate 0-1 variable by fixed possibility
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?
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
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?
You can do this:and the result is 1 with a possibility of 20% and 0 with 80%.
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
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 45
- Thank you received: 0
1 year 2 months ago #240204
by qiangqi
Replied by qiangqi on topic how to generate 0-1 variable by fixed possibility
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
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.