0 votes
in SoSci Survey (English) by s090021 (120 points)

Dear all!

I am trying to implement block randomization. I intend to block randomization into treatment groups (3 treatments and 1 control) on age, gender, and education, so that the mean values of these variables were the same in all groups.

I will be very grateful if you could share the code with me.

1 Answer

0 votes
by SoSci Survey (330k points)

Please check this manual chapter for the basic PHP code:
Urns for Subgroup I

This explains how to handle 2 groups. If you have more groups (or blocks), then you will need the appropriate number of urns and some filter to draw from the appropriate urn.

But please take note that if having small groups, randomization may not be equal in the end. The strategy only works if you have significantly more respondens per demographic group than you have tratment groups.

Also you may want to create a "code" from the age, gender, and education variables (e.g. concatenating the three response codes) to select the appropriate urn, instead of creating a heavily nested IF structure. More details on request :)

by s090021 (120 points)
edited by s090021
Thank you!

it really worked! But the question is how to do blocking on multiple variables? Do you know any relevant code that can be used for this purpose?

This is my code, but it seems that I assign the groups and not randomize people into them:

if (value('A002') == 1) {
  urnDraw('men', 'IV01', 'end');
} else {
  urnDraw('women', 'IV01', 'end');
}

if (value('A001') == 1) {
  urnDraw('18-35', 'IV02', 'end');
} elseif (value('A001') == 2) {
  urnDraw('36-55', 'IV02', 'end');
} elseif (value('A001') == 3) {
  urnDraw('56', 'IV02', 'end');
}

 
$z = value('IV01_01');
$m = value('IV02_01');
  if ($z == 1 && $m == 1) {
  question('E002');
} elseif ($z == 1 && $m == 2) {
  question('E003');
} elseif ($z == 1 && $m == 3) {
  question('E004');
} elseif ($z == 2 && $m == 1) {
  question('E005');
} elseif ($z == 2 && $m == 2) {
  question('E006');
} elseif ($z == 2 && $m == 3) {
  question('E002');
}
by SoSci Survey (330k points)
So, let's start with the number of blocks. You have 2 x 3 = 6 blocks for gender and age. What about education?
by s090021 (120 points)
edited by s090021
Right, education has also 3 levels.

I think I finally figured it out. Will leave the solution here, hope it will help someone.



So I have Gender (2 options), Age (3 options), and political support (2 options)

(1)

I will need to create 12 urns (2*3*2):
Example:
men (1 2 3 4 5) #stands for the number of experimental groups
women (1 2 3 4 5)
support (1 2 3 4 5)
no_support (1 2 3 4 5)


(2)

I will need to create 3 IV (for the number of variables)


(3)

Then I make sure that I have a page with randomization. In my case I randomly assign people to 5 groups:

if (value('NA06') == 1) {
  question('E002');
} elseif (value('NA06') == 2) {
  question('E003');
} elseif (value('NA06') == 3) {
  question('E004');
} elseif (value('NA06') == 4) {
  question('E005');
} elseif (value('NA06') == 5) {
  question('E006');
}

where "NA06" is "randomization" and E002-6 are experimental questions


(4)

Blocking on Age, Gender, Polit. support:

if (value('A002') == 1) {
  urnDraw('men', 'IV01', 'end');
} else {
  urnDraw('women', 'IV01', 'end');
}

if (value('A001') == 1) {
  urnDraw('18-35', 'IV02', 'end');
} elseif (value('A001') == 2) {
  urnDraw('36-55', 'IV02', 'end');
} elseif (value('A001') == 3) {
  urnDraw('56', 'IV02', 'end');
}

if (value('A003') == 1) {
  urnDraw('support', 'IV03', 'end');
} elseif (value('A003') == 2) {
  urnDraw('no_support', 'IV03', 'end');
}
 
$z = value('IV01_01');
$m = value('IV02_01');
$l = value('IV03_01');
      if ($z == 1 && $m == 1 && $l == 1) {
  question('NA06');                          ### Important: 'NA06' is page number not ID
} elseif ($z == 1 && $m == 2 && $l == 1) {
  question('NA06');
} elseif ($z == 1 && $m == 3 && $l == 1) {
  question('NA06');
} elseif ($z == 2 && $m == 1 && $l == 2) {
  question('NA06');
} elseif ($z == 2 && $m == 2 && $l == 2) {
  question('NA06');
} elseif ($z == 2 && $m == 3 && $l == 2) {
  question('NA06');
} elseif ($z == 1 && $m == 1 && $l == 2) {
  question('NA06');
} elseif ($z == 1 && $m == 2 && $l == 2) {
  question('NA06');
} elseif ($z == 1 && $m == 3 && $l == 2) {
  question('NA06');
} elseif ($z == 2 && $m == 1 && $l == 1) {
  question('NA06');
} elseif ($z == 2 && $m == 2 && $l == 1) {
  question('NA06');
} elseif ($z == 2 && $m == 3 && $l == 1) {
  question('NA06');
}
by SoSci Survey (330k points)
I am not sure if your randomization is correct.

You are drawing from three separate urns, and you do not connect (!) the demographic factors. That means you will NOT have the same randomization in each cell, but only per demographic variable.

> where "NA06" is "randomization"

When you are always drawing from the same random generator, this does not help anything to have the same structure in each cell.

In my opinion you need 12 random generators OR urns. And you will have to draw from one, depending on all 3 variables. That means: Use the code that you are using at the end, exchange the $z, $m, and $l by the demographic variables, and draw from different urns (or random generators, but that is more complex in your case) in each IF-part.

Willkommen im Online-Support von SoSci Survey.

Hier bekommen Sie schnelle und fundierte Antworten von anderen Projektleitern und direkt von SoSci Survey.

→ Eine Frage stellen


Welcome to the SoSci Survey online support.

Simply ask a question to quickly get answers from other professionals, and directly from SoSci Survey.

→ Ask a Question

...