randomization: validation [Regulatives / Guidelines]

posted by Helmut Homepage – Vienna, Austria, 2012-06-15 19:39 (4326 d 00:17 ago) – Posting: # 8745
Views: 12,322

Dear Ravi!

I don’t think that you have to submit the code, but like all software it should be validated. I did it once for my own randomization in HP-UX Pascal based on the Wald–Wolfowitz runs test.
For SAS see here; set-up in other software is easy as well. For [image] have a look at package tseries runs.test().

A simple randomization for a 2×2 cross-over with balanced sequences and random frequency of runs:

library(tseries)
#set.seed(15062012)              # uncomment this line for testing
size <- 24
sig  <- 0                        # break condition
while (sig < 0.05) {             # … until nonsignificant runs
  x <- 1                         # break condition
  while (sum(x) != 0) {          # … until balanced
    x <- sign(rnorm(size))       # random: -1 or +1
  }
  runs <- length(rle(x)$lengths) # No. of runs
  x[x==1]  <- "RT"               # nicer ‘looks’
  x[x==-1] <- "TR"
  x   <- as.factor(x)
  rt  <- runs.test(x)            # perform test
  sig <- rt$p.value              # p-value
  }
x                                # display randomization
rt                               # show test results


Should give (with the testing seed):
[1] RT RT RT TR TR TR TR RT RT TR TR TR RT RT TR TR RT TR TR RT RT RT TR RT
Levels: RT TR

        Runs Test

data:  x
Standard Normal = -0.8348, p-value = 0.4038
alternative hypothesis: two.sided

Dif-tor heh smusma 🖖🏼 Довге життя Україна! [image]
Helmut Schütz
[image]

The quality of responses received is directly proportional to the quality of the question asked. 🚮
Science Quotes

Complete thread:

UA Flag
Activity
 Admin contact
22,988 posts in 4,825 threads, 1,661 registered users;
100 visitors (1 registered, 99 guests [including 8 identified bots]).
Forum time: 19:56 CEST (Europe/Vienna)

The only way to comprehend what mathematicians mean by Infinity
is to contemplate the extent of human stupidity.    Voltaire

The Bioequivalence and Bioavailability Forum is hosted by
BEBAC Ing. Helmut Schütz
HTML5