randomization: validation [Regulatives / Guidelines]

posted by Helmut Homepage – Vienna, Austria, 2012-06-15 19:39 (4750 d 11:36 ago) – Posting: # 8745
Views: 13,860

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
23,424 posts in 4,927 threads, 1,673 registered users;
26 visitors (0 registered, 26 guests [including 17 identified bots]).
Forum time: 07:15 CEST (Europe/Vienna)

Truth and clarity are complementary.    Niels Bohr

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