Hi, I’ am pleased to inform that a set of 36 SPSS Syntax Files - SIMPLE AND COMPLEX RANDOM ASSIGNMENT FOR EXPERIMENTAL DESIGNS - for randomization of between-subjects (simple random assignment, block random assignment, and stratified random assignment) and within-subjects designs (complete counterbalancing, Latin squares, and carryovers designs) is available at: http://www.fpce.uc.pt/niips/spss_prc/scra/scra.htm Best regards, Valentim R. Alferes http://www.fpce.uc.pt/niips/spss_prc/index.htm |
Thank you for a very informative site! I have, what i think, is a simple
question about the StrataRand1.sps syntax. Is this a correct interpretation using an example where the stratfiying factors are age, and sex: Stratum 1 = sex (M, F) Stratum 2= age (<18, 19+) * Enter Stratum number and number of units per Stratum. begin data 1 22 - I want 22 cases that are Male <18 2 53 - I want 53 cases that are Male 19+ 3 45 - I want 45 cases that are Female <18 4 61 - I want 61 cases that are Female 19+ end data. * Enter number of treatments. compute ntreat = 4. i want those number of cases in each stratum to be assigned to 1 of 4 groups Thanks Carol -- Sent from: http://spssx-discussion.1045642.n5.nabble.com/ ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
Hi all,
I have been trying to modify the following syntax called StrataRand1.sps from the previously mentioned site:
data list list/Stratum(f8.0) nstrata(f8.0).
* Enter Stratum number and number of units per Stratum.
begin data
1 22
2 53
3 45
4 61
end data.
* Enter number of treaments.
compute ntreat = 4.
loop cases=1 to nstrata.
xsave outfile=outf1/keep=Stratum ntreat.
end loop.
get file=outf1.
compute x=$casenum.
rank variables=x(a) by Stratum/rank/print=no.
set rng=mt mtindex=random.
compute random=rv.uniform(0,ntreat).
compute Treatment=trunc(random)+1.
formats all(f8.0).
variable labels Rx"Unit".
oms/select tables/if commands=["summarize"]
subtypes=["case processing summary"]/destination viewer=no.
oms/select tables/if commands=["crosstabs"]
subtypes=["case processing summary"]/destination viewer=no.
sort cases by Stratum(a) rx(a).
summarize/tables=Stratum rx treatment/format=validlist nocasenum nototal
/title='Stratified Random Assignment \n Sorted by Stratum/Unit'/cells=none.
sort cases by treatment(a) Stratum(a) rx(a).
summarize/tables=Stratum rx treatment/format=validlist nocasenum nototal
/title='Stratified Random Assignment \n Sorted by Treatment'/cells=none.
crosstabs/tables=Stratum by Treatment/cells=count row.
...which yields the following data file.
Stratum nstrata ntreat cases x Rx random treatment
3 45 4 46 3 1 2 2
4 61 4 62 4 1 2 2
1 22 4 23 1 1 4 4
2 53 4 54 2 1 3 4
My goal is to produce a program that will randomize 4 people in each of the following stratum into 1 of 2 groups like below.
ID Stratum Sex Age Treatment
1 1 M 20
2 1 M 21
3 1 M 23
4 1 M 24
5 2 F 22
6 2 F 23
7 2 F 24
8 2 F 25
9 3 M 35
10 3 M 26
11 3 M 40
12 3 M 50
13 4 F 52
14 4 F 60
15 4 F 41
16 4 F 38
I apparently have not found the correct syntax since i don't think what was produced is going to get me anything like this example.
Does anyone know where i might find the correct syntax to modify?
Thanks
Carol
Sent from the SPSSX Discussion mailing list archive at Nabble.com. ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
In reply to this post by parisec-2
Hi all,
I have been trying to modify the following syntax called StrataRand1.sps from the previously mentioned site: data list list/Stratum(f8.0) nstrata(f8.0). * Enter Stratum number and number of units per Stratum. begin data 1 22 2 53 3 45 4 61 end data. * Enter number of treaments. compute ntreat = 4. loop cases=1 to nstrata. xsave outfile=outf1/keep=Stratum ntreat. end loop. get file=outf1. compute x=$casenum. rank variables=x(a) by Stratum/rank/print=no. set rng=mt mtindex=random. compute random=rv.uniform(0,ntreat). compute Treatment=trunc(random)+1. formats all(f8.0). variable labels Rx"Unit". oms/select tables/if commands=["summarize"] subtypes=["case processing summary"]/destination viewer=no. oms/select tables/if commands=["crosstabs"] subtypes=["case processing summary"]/destination viewer=no. sort cases by Stratum(a) rx(a). summarize/tables=Stratum rx treatment/format=validlist nocasenum nototal /title='Stratified Random Assignment \n Sorted by Stratum/Unit'/cells=none. sort cases by treatment(a) Stratum(a) rx(a). summarize/tables=Stratum rx treatment/format=validlist nocasenum nototal /title='Stratified Random Assignment \n Sorted by Treatment'/cells=none. crosstabs/tables=Stratum by Treatment/cells=count row. ...which yields the following data file. Stratum nstrata ntreat cases x Rx random treatment 3 45 4 46 3 1 2 2 4 61 4 62 4 1 2 2 1 22 4 23 1 1 4 4 2 53 4 54 2 1 3 4 My goal is to produce a program that will randomize 4 people in each of the following stratum into 1 of 2 groups like below. ID Stratum Sex Age Treatment 1 1 M 20 2 1 M 21 3 1 M 23 4 1 M 24 5 2 F 22 6 2 F 23 7 2 F 24 8 2 F 25 9 3 M 35 10 3 M 26 11 3 M 40 12 3 M 50 13 4 F 52 14 4 F 60 15 4 F 41 16 4 F 38 I apparently have not found the correct syntax since i don't think what was produced is going to get me anything like this example. Does anyone know where i might find the correct syntax to modify? Thanks Carol -- Sent from: http://spssx-discussion.1045642.n5.nabble.com/ ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
Administrator
|
Hi Carol. If I follow, you have exactly 16 subjects, 4 in each of 4 strata,
and you want to randomly allocate them to two groups, with 2 in each group within each stratum. Is that right? If so, here are a couple of methods you could use. HTH. * Read in Carol's 16 cases. DATA LIST LIST / ID Stratum (2F2.0) Sex(A1) Age(F3.0). BEGIN DATA 1 1 M 20 2 1 M 21 3 1 M 23 4 1 M 24 5 2 F 22 6 2 F 23 7 2 F 24 8 2 F 25 9 3 M 35 10 3 M 26 11 3 M 40 12 3 M 50 13 4 F 52 14 4 F 60 15 4 F 41 16 4 F 38 END DATA. SET RNG=MT MTINDEX=300119. COMPUTE x = RV.UNIFORM(0,1). SORT CASES by Stratum x. * Method 1: Use MOD() function. COMPUTE Treat1 = MOD($casenum,2). FORMATS Treatment(F1). * Method 2: Use RANK with NTILES(2). RANK VARIABLES=x (A) BY Stratum /RANK /NTILES(2) /PRINT=YES /TIES=MEAN. RENAME VARIABLES (Nx=Treat2). FORMATS Treat1(F1). * Check numbers in each cell. CROSSTABS TABLES = Stratum BY Treat1 Treat2 / TABLES = Treat1 BY Treat2. * SORT CASES by id. /* Uncomment to restore original order of cases. parisec-2 wrote > Hi all, > > --- snip --- > > My goal is to produce a program that will randomize 4 people in each of > the > following stratum into 1 of 2 groups like below. > > > ID Stratum Sex Age Treatment > 1 1 M 20 > 2 1 M 21 > 3 1 M 23 > 4 1 M 24 > 5 2 F 22 > 6 2 F 23 > 7 2 F 24 > 8 2 F 25 > 9 3 M 35 > 10 3 M 26 > 11 3 M 40 > 12 3 M 50 > 13 4 F 52 > 14 4 F 60 > 15 4 F 41 > 16 4 F 38 > > > I apparently have not found the correct syntax since i don't think what > was > produced is going to get me anything like this example. > > Does anyone know where i might find the correct syntax to modify? > > Thanks > Carol > > > > > -- > Sent from: http://spssx-discussion.1045642.n5.nabble.com/ > > ===================== > To manage your subscription to SPSSX-L, send a message to > LISTSERV@.UGA > (not to SPSSX-L), with no body text except the > command. To leave the list, send the command > SIGNOFF SPSSX-L > For a list of commands to manage subscriptions, send the command > INFO REFCARD ----- -- Bruce Weaver [hidden email] http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." NOTE: My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. -- Sent from: http://spssx-discussion.1045642.n5.nabble.com/ ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
--
Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." PLEASE NOTE THE FOLLOWING: 1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. 2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/). |
Administrator
|
In reply to this post by parisec-2
Talk about over engineering?
GET FILE='C:\Program Files\IBM\SPSS\Statistics\22\Samples\English\Employee data.sav'. DATASET NAME Employee WINDOW=FRONT. COMPUTE RndVar=RV.UNIFORM(5,6). RANK VARIABLES=RndVar (A) BY minority jobcat /RANK INTO R_Rnd. DO REPEAT X=0 0 0 1 1 1 / Y = 1 2 3 1 2 3/ Get= 5 10 28 41 36 28. COMPUTE Select=SUM(Select,(minority EQ x AND jobcat EQ y) * (R_Rnd LE Get )). END REPEAT. FILTER BY Select. parisec-2 wrote > Thank you for a very informative site! I have, what i think, is a simple > question about the StrataRand1.sps syntax. > > Is this a correct interpretation using an example where the stratfiying > factors are age, and sex: > > > Stratum 1 = sex (M, F) > Stratum 2= age (<18, 19+) > > * Enter Stratum number and number of units per Stratum. > begin data > 1 22 - I want 22 cases that are Male <18 > 2 53 - I want 53 cases that are Male 19+ > 3 45 - I want 45 cases that are Female <18 > 4 61 - I want 61 cases that are Female 19+ > end data. > > * Enter number of treatments. > compute ntreat = 4. > > i want those number of cases in each stratum to be assigned to 1 of 4 > groups > > Thanks > Carol > > > > > > -- > Sent from: http://spssx-discussion.1045642.n5.nabble.com/ > > ===================== > To manage your subscription to SPSSX-L, send a message to > LISTSERV@.UGA > (not to SPSSX-L), with no body text except the > command. To leave the list, send the command > SIGNOFF SPSSX-L > For a list of commands to manage subscriptions, send the command > INFO REFCARD ----- Please reply to the list and not to my personal email. Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" -- Sent from: http://spssx-discussion.1045642.n5.nabble.com/ ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
In reply to this post by Bruce Weaver
Bruce,
Thank you much for taking the time to give both of these options. I finally went through both methods and the both work to randomize an even number of cases in each stratum. the first method gives a 1,0,1,0 pattern and the second one gives a 1,1,0,0 pattern. Is there something i could add in there so it's not a predictable pattern? Dave, thank you for posting too. I ran this and it looks like it is designed to select cases within a stratum which is going to be very useful for another project i have. Carol -- Sent from: http://spssx-discussion.1045642.n5.nabble.com/ ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
Administrator
|
Hi Carol. For the code I posted earlier, with one small modification to the
computation of Treat 2: * Method 2: Use RANK with NTILES(2). RANK VARIABLES=x (A) BY Stratum /RANK /NTILES(2) /PRINT=YES /TIES=MEAN. COMPUTE Treat2 = Nx-1. FORMATS Treat1 Treat2(F1). I get the following output when I LIST the data at the end: ID Stratum Sex Age x Treat1 Rx Nx Treat2 1 1 M 20 .72 0 4.000 2 1 2 1 M 21 .07 0 2.000 1 0 3 1 M 23 .41 1 3.000 2 1 4 1 M 24 .04 1 1.000 1 0 5 2 F 22 .67 1 3.000 2 1 6 2 F 23 .68 0 4.000 2 1 7 2 F 24 .33 0 2.000 1 0 8 2 F 25 .08 1 1.000 1 0 9 3 M 35 .12 1 1.000 1 0 10 3 M 26 .66 1 3.000 2 1 11 3 M 40 .84 0 4.000 2 1 12 3 M 50 .41 0 2.000 1 0 13 4 F 52 .15 0 2.000 1 0 14 4 F 60 .12 1 1.000 1 0 15 4 F 41 .60 1 3.000 2 1 16 4 F 38 .61 0 4.000 2 1 Number of cases read: 16 Number of cases listed: 16 The two patterns you mention below appear to be for Stratum 1. The other strata show different sequences of 0s and 1s. So I'm not sure how the pattern is predictable. If you want to see a different pattern, change the MTINDEX value on the SET command. HTH. parisec-2 wrote > Bruce, > > Thank you much for taking the time to give both of these options. I > finally > went through both methods and the both work to randomize an even number of > cases in each stratum. the first method gives a 1,0,1,0 pattern and the > second one gives a 1,1,0,0 pattern. > > Is there something i could add in there so it's not a predictable pattern? > > > Dave, thank you for posting too. I ran this and it looks like it is > designed > to select cases within a stratum which is going to be very useful for > another project i have. > > Carol > > > > -- > Sent from: http://spssx-discussion.1045642.n5.nabble.com/ > > ===================== > To manage your subscription to SPSSX-L, send a message to > LISTSERV@.UGA > (not to SPSSX-L), with no body text except the > command. To leave the list, send the command > SIGNOFF SPSSX-L > For a list of commands to manage subscriptions, send the command > INFO REFCARD ----- -- Bruce Weaver [hidden email] http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." NOTE: My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. -- Sent from: http://spssx-discussion.1045642.n5.nabble.com/ ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
--
Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." PLEASE NOTE THE FOLLOWING: 1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. 2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/). |
Thanks. Where is Treat1 defined?
Do i need to include this at the start? COMPUTE Treat1 = MOD($casenum,2). FORMATS Treat1 (F1). * Method 2: Use RANK with NTILES(2). RANK VARIABLES=x (A) BY Stratum /RANK /NTILES(2) /PRINT=YES /TIES=MEAN. COMPUTE Treat2 = Nx-1. FORMATS Treat1 Treat2(F1). -- Sent from: http://spssx-discussion.1045642.n5.nabble.com/ ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
Administrator
|
Hi Carol. I showed two ways to do it, but you could just pick the one that
you like the best. It might be easier to explain Method 2 to other people: Ranking the data by a random number is probably easier to understand than the MOD function is! To answer your question though, here is some of the code again. * Read in Carol's 16 cases. * --- snip the DATA LIST command ---. * Change MTINDEX value on the next line if you wish. SET RNG=MT MTINDEX=300119. COMPUTE x = RV.UNIFORM(0,1). SORT CASES by Stratum x. * Method 1: Use MOD() function. COMPUTE Treat1 = MOD($casenum,2). /* <<< Value of Treat1 is assigned here. * Method 2: Use RANK with NTILES(2). RANK VARIABLES=x (A) BY Stratum /RANK /NTILES(2) /PRINT=YES /TIES=MEAN. COMPUTE Treat2 = Nx-1. /* <<< Value of Treat2 is assigned here. FORMATS Treat1 Treat2(F1). Variable Nx (generated by RANK VARIABLES) has values of 1 and 2. It appeared you wanted values of 1 and 0. That's why I set Treat2 = Nx-1. If you're fine with 1-2 coding, just rename Nx to Treat (or whatever). HTH. parisec-2 wrote > Thanks. Where is Treat1 defined? > > > Do i need to include this at the start? > > COMPUTE Treat1 = MOD($casenum,2). > FORMATS Treat1 (F1). > > > > > > * Method 2: Use RANK with NTILES(2). > RANK VARIABLES=x (A) BY Stratum > /RANK > /NTILES(2) > /PRINT=YES > /TIES=MEAN. > COMPUTE Treat2 = Nx-1. > FORMATS Treat1 Treat2(F1). > > > > > > > -- > Sent from: http://spssx-discussion.1045642.n5.nabble.com/ > > ===================== > To manage your subscription to SPSSX-L, send a message to > LISTSERV@.UGA > (not to SPSSX-L), with no body text except the > command. To leave the list, send the command > SIGNOFF SPSSX-L > For a list of commands to manage subscriptions, send the command > INFO REFCARD ----- -- Bruce Weaver [hidden email] http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." NOTE: My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. -- Sent from: http://spssx-discussion.1045642.n5.nabble.com/ ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
--
Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." PLEASE NOTE THE FOLLOWING: 1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. 2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/). |
Yes. Method 2 it is since i will have to explain!
This worked flawlessly. Thank you! Carol -- Sent from: http://spssx-discussion.1045642.n5.nabble.com/ ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
Free forum by Nabble | Edit this page |