Welcome to the LimeSurvey Community Forum

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

Seudo Random (1,2,1,2,1,2...)

  • aalfonsoc
  • aalfonsoc's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 3 months ago #226162 by aalfonsoc
Seudo Random (1,2,1,2,1,2...) was created by aalfonsoc
Please help us help you and fill where relevant:
Your LimeSurvey version: Versión 4.1.17+200414
Own server or LimeSurvey hosting: Private
Survey theme/template: Irrelevant
==================
Good afternoon,

First of all, I would like to thank you and acknowledge your work.

I need to randomize a question but my number of subjects is very low, so I would like not to do it using rand()
I need to the first subjects to go to control group, the second one to treatment, the third one to control.... Is that possible.
Seudo Random (1,2,1,2,1,2...)

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 3 months ago #226164 by Joffm
Replied by Joffm on topic Seudo Random (1,2,1,2,1,2...)
Hi,
this is only possible in theory.

1.
The obvious solution would be to use the answer id of the responses.
You know that each respondent gets an autoincrement id in the answer table.
This you access by {SAVEDID}.
{1+SAVEDID-2*floor(SAVEDID/2)}
So the approach is:
Group 1: odd IDs
Group 2: even IDs

Easy to implement, but in practice...?
What happens if respondents 3, 7, and 11 do not complete the survey?
You get this distribution: 1,2,2,1,2,2,1,2,2

2.
Now you might think: Let's take in account only the completed surveys.
To do this you have to use the plugin "getStatInSurvey".
Since Version 5.x. of LimeSurvey there is a core plugin "statFunction". You might consider an update. Your version is 2 years old.

Here we count the completed surveys and again
{1+Q0-2*floor(Q0/2)} 
Group 1: odd number of completes  
Group 2: even number of completes  
Sounds good, but...
You only count completed surveys.
So, if three respondents start the survey, the number of completes will be "0", until the first completes.
So all three will be in group 1.

3.
Next idea, if the survey is token-based.
Predefine the group of each participant in an additional attribute. To do so, you may roll a dice or toss a coin.
But of course the same problems if some do not participate.

4. 
In my opinion the best solution is:
Use a random number and watch the progress and the distribution. And wait until there are enough responses in each group.
If there is an overquote in one of them you may randomly remove some responses (Ask your grandmother which ones)

And there are some other options:
a. You create a random number (1-2)
Initially: 
Group 1: randomnumber==1
Group 2: randomnumber==2
If you think there are enough responses in group1 but too few in group 2, change the relevance equation to
Group 1: randomnumber==0
Group 2: randomnumber ge 1

b. You create a random number (1-100)
Initially: 
Group 1: randomnumber le 50
Group 2: randomnumber gt 50
If you think there are too many responses in group1 but too few in group 2, change the relevance equation to
Group 1: randomnumber le 30
Group 2: randomnumber gt 30

Keep in mind that you can't use the random number to determine the group.

At last:​​​​​​
You did not specify, what is "but my number of subjects is very low".
How much is "very low"?

Joffm
 

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

Please Log in to join the conversation.

  • aalfonsoc
  • aalfonsoc's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 3 months ago #226201 by aalfonsoc
Replied by aalfonsoc on topic Seudo Random (1,2,1,2,1,2...)
First and foremost, thank you.
It seems to me a super complete answer and that goes to the altermantive.

The low number, for example a study with two treatments and 24 subjects, (the number of computers in the classroom) is sometimes very well balanced but other times... not so much. Which is not statistically significant, but ... I was looking for a better way.

I suppose I could look up how many people have answered that question before you and see if that number is even or odd... but the process is tedious.

I was looking to see if I missed a rand() type command but that it was a 0 1 switch that every time someone passes it changes it.

Again thank you very much, I will continue to rely on luck and big numbers.

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose