Welcome to the LimeSurvey Community Forum

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

Randomization 50:50

  • Maddie.Storm
  • Maddie.Storm's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 weeks 5 days ago #260203 by Maddie.Storm
Randomization 50:50 was created by Maddie.Storm
Hi!
I am looking to randomize the Modified GMSEX here and the Fully Modified GMSEX here. When participants get to this stage of the survey, I need it to be 50/50 chance of getting either one. 
How do I do this? Is there a code? If so, where does this go?

Thanks!

Please Log in to join the conversation.

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 weeks 4 days ago #260213 by holch
Replied by holch on topic Randomization 50:50
Creating a 50/50 chance is easy, there have been many posts about this in the forum. You basically create a random number between 1 and 2 within a equation type question and then use the relevance equation / condition of the question to show / hide it depending on the number that has been drawn.

However, to make sure you don't run into trouble, you shouldn't just create a random number via {rand(1,2)}, but you need to check if this random number already exists, before you create it new.

Why is this important? Because otherwise you are running the risk that the random number changes for the same participant. Because with {rand(1,2)} the "dice are rolled everytime this equation question is called.
Code:
{if(is_empty(randnumber),rand(1,2),randnumber.NAOK)}

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The following user(s) said Thank You: Maddie.Storm

Please Log in to join the conversation.

  • Maddie.Storm
  • Maddie.Storm's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 weeks 3 days ago #260300 by Maddie.Storm
Replied by Maddie.Storm on topic Randomization 50:50
Hi! Thank you so much for responding. I just tried to do it, but I think I still have a problem. My questions are in array form and they have to stay that way. It is for the scale validity in our study, and it seems like the equation style would not work for the length and look of the array.
So, is there any way to randomize arrays 50:50? Is there a code for these? Where do I put each code?

Also, how do I do this: "You need to check if this random number already exists before you create it new."? How do I assign one question as 1 and the other as 2? Does this go into the condition box?

Thanks so much! I am very new to LimeSurvey. 

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 weeks 3 days ago #260301 by Joffm
Replied by Joffm on topic Randomization 50:50
Hi,
it seems you are confused about it.

You see the construct we use
Code:
{if(is_empty(randnumber), rand(1,2),randnumber)}
Meaning: if "randnumber" is still empty, create a random number from 1-2, otherwise keep it as it is.

Reason for this construct:
If you only use {rand(1,2)} you create a random number. But if the respondent goes back to this question or even group there will be generated a new random number that may be different.
Therefore the check "is_empty". 
​​​​​​

Well, now yoa have in your variable "randnumber" a value (1 or 2).

And now the conditions of your questions.
One question is only displayed if this "randnumber" is equal 1, the other if it is equal 2.

And exactly this you enter into the condition of the question.
randnumber==1 resp. randnumber==2

Best you read the manual, "ExpressionScript" again and you may download and import the sample surveys provided in the manual.

Joffm 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: Maddie.Storm

Please Log in to join the conversation.

  • Maddie.Storm
  • Maddie.Storm's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 weeks 3 days ago #260302 by Maddie.Storm
Replied by Maddie.Storm on topic Randomization 50:50
Hi!
I attached pictures here... I know it seems like a mess! 
Would you be able to provide me the exact code to put in these? I am not the best at this.. I am just looking for 50:50 between variables 1 and 2. 
What would be the exact condition for my first question (variable 1) in the group and second question (variable 2)? It does not seem to pick up on randnumber == 1?
Then I tried filling them in and it doesn't seem to work either.

Each Condition for ModifiedGMSEX (1) and FullyModifiedGMSEX (2): ?

Exact Group Relevance Code (Modified GMSEX): ?

Randomization group name: ?


Thank you so much for your help! 

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 weeks 2 days ago - 2 weeks 2 days ago #260305 by Joffm
Replied by Joffm on topic Randomization 50:50
Better you attach the lss export of your try.

As @holch wrote you create the random number in a question of type "equation" which is called "randnumber". 
Please read the manual about question types.
 Then you enter the shown logical terms (randnumber==1 resp  randnumber==2) in the "condition" field of the question.

And why don't you see a 50:50 distribution?
What do you expect if you throw a coin 100 times? This is analogue to the creation of a random number from 1-2 100 times.

Again my advice. Read the manual, study the included sample surveys to learn the basics about questions, about ExpressionScript, about the implemented functions, etc.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 2 weeks 2 days ago by Joffm.
The following user(s) said Thank You: Maddie.Storm

Please Log in to join the conversation.

  • Maddie.Storm
  • Maddie.Storm's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 weeks 2 days ago #260308 by Maddie.Storm
Replied by Maddie.Storm on topic Randomization 50:50
Sure thing!
Here is the question group attached.

Thank you SO much.

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 weeks 2 days ago #260309 by Joffm
Replied by Joffm on topic Randomization 50:50
Please provide neither lsq nor lsg exports.
We always ask for lss exports of the relevant questions.

Reason:
lsq and lsg exports are language sensitive.
You can't import them into a survey with a different base language 
So first we have to guess the base language, create a survey to be able to import.
Furthermore your survey wide settings are missing.

lss exports we only have to import.

Please, ease the work of us volunteers.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: Maddie.Storm

Please Log in to join the conversation.

More
2 weeks 1 day ago - 2 weeks 1 day ago #260346 by PabloSantos
Replied by PabloSantos on topic Randomization 50:50
Hi!
I am so sorry about that. I attached the lss file here if you want to take a look! It should work.
 
Last edit: 2 weeks 1 day ago by PabloSantos. Reason: Wrong Acc

Please Log in to join the conversation.

  • Maddie.Storm
  • Maddie.Storm's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 weeks 1 day ago #260349 by Maddie.Storm
Replied by Maddie.Storm on topic Randomization 50:50
Sorry, accidentally replied with the wrong account if there was confusion.

Here it is again. 
Thanks.

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 weeks 2 hours ago #260453 by Joffm
Replied by Joffm on topic Randomization 50:50
Hi,
​​​​​​in your survey I see nothing of the things @holch and I told you.

Where is the question of type "equation", where you generate the random number as said and shown before?
Best you put it into the "Sociodemographic" group.

And where are the two conditions
"randnumber==1" and "randnumber==2" in the questions "EndMod" resp. "FullyMod"?

That's all you have todo.

By the way you should use a quota to screen out people who do not consent.
Instead of putting this condition into each group condition.

Joffm 

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

Please Log in to join the conversation.

Lime-years ahead

Online-surveys for every purse and purpose