(Pseudo-) random numbers, algos, seeds [🇷 for BE/BA]
we had to edit 78% of your replies (deleting TOFU). This is the first warning.
❝ Even though when we specify the Block size, we are getting repeated seqno within the block in R.
By chance! You know what random means? Here another one:
library(randomizeBE)
print(RL4(nsubj = 12, blocksize = 6), sumry = TRUE)
Randomization table created: 2019-08-26 12:26:28
(seed: 1742219 blocksize: 6 )
subject seqno sequence
1 1 TR
2 1 TR
3 2 RT
4 1 TR
5 2 RT
6 2 RT
7 1 TR
8 2 RT
9 1 TR
10 1 TR
11 2 RT
12 2 RT
Summary of randomisation
12 subjects randomized into 2 sequence groups.
Number of subjects in sequence groups:
RT TR
6 6
Runs test of randomness: p.value=0.5448
Block 1 (1– 6): 1, 1, 2, 1, 2, 2
Block 2 (7–12): 1, 2, 1, 1, 2, 2
❝ But when we do in SAS …
I thought that
❝ ❝ ❝ ❝ ❝ ❝ But my SAS Licence got expired
❝
❝ … we get different seqno (ex: 1,2) within the block.
❝
❝ In SAS:
❝
❝ Output:
❝
❝ blocks sequence
❝ 4 1
❝ 4 2
❝ 5 2
❝ 5 1
❝ 6 2
❝ 6 1
❝ 1 1
❝ 1 2
❝ 2 2
❝ 2 1
❝ 3 2
❝ 3 1
❝
❝ the seqno within the block is not getting repeated in SAS Output
Sorry, now you’ve lost me.
Block 1 (1–3): 1, 2, 2, 1, 2, 1
Block 2 (4–6): 1, 2, 2, 1, 2, 1
What do you want to achieve? Reproduce one randomization by another? Only possible if
- same software (i.e., same AlGore rhythm) and
- same seed of the (pseudo-) random number generator
Example of simulating the empiric type I error (TIE) in
PowerTOST
(where you can also set a seed). If the argument setseed
is missing, it is set to TRUE
(in order to reproduce results). When you set it to FALSE
, different seeds are used:library(PowerTOST)
runs <- 12
CV <- 0.20
n <- sampleN.TOST(CV = CV, details = FALSE, print = FALSE)[["Sample size"]]
res <- data.frame(run = 1:runs, seed = c("missing", TRUE, rep(FALSE, runs - 2)),
TIE = 0, sig = "", stringsAsFactors = FALSE)
nsims <- 1e6
sig <- binom.test(0.05*nsims, nsims, alternative = "less")$conf.int[2]
res$TIE[1] <- power.TOST.sim(CV = CV, theta0 = 1.25, nsims = nsims, n = n)
for (j in 2:runs) {
res$TIE[j] <- power.TOST.sim(CV = CV, theta0 = 1.25, nsims = nsims, n = n,
setseed = as.logical(res$seed[j]))
}
res$sig[res$TIE > sig] <- "*"
print(res, row.names = FALSE)
run seed TIE sig
1 missing 0.050188
2 TRUE 0.050188
3 FALSE 0.049840
4 FALSE 0.049886
5 FALSE 0.050003
6 FALSE 0.050103
7 FALSE 0.049841
8 FALSE 0.049945
9 FALSE 0.050264
10 FALSE 0.050543 *
11 FALSE 0.049727
12 FALSE 0.049942
BTW, we know that the TIE of TOST is the nominal α or less. In simulations the empiric TIE might be higher. In run 10 the TIE was even significantly >0.05 (limit 0.05036) – more often (9.1%) than expected.
However, rolling the dice 1,000 times, I got 496 times ≤0.05 and 504 times >0.05 (5.00% significantly >0.05). Welcome to the world of chance and the wonders of Mersenne Twister.
Dif-tor heh smusma 🖖🏼 Довге життя Україна!
Helmut Schütz
The quality of responses received is directly proportional to the quality of the question asked. 🚮
Science Quotes
Complete thread:
- Randomization Schedule in R sury 2019-08-23 13:39 [🇷 for BE/BA]
- package randomizeBE Helmut 2019-08-24 16:31
- package randomizeBE sury 2019-08-26 09:34
- package randomizeBE Helmut 2019-08-26 10:35
- package randomizeBE sury 2019-08-26 11:54
- (Pseudo-) random numbers, algos, seedsHelmut 2019-08-26 12:28
- how about randomly selected block sizes? yjlee168 2019-08-28 07:25
- how about randomly selected block sizes? ElMaestro 2019-08-28 09:26
- package randomizeBE sury 2019-08-26 11:54
- package randomizeBE Helmut 2019-08-26 10:35
- package randomizeBE sury 2019-08-26 09:34
- package randomizeBE Helmut 2019-08-24 16:31