Skip to content
Prev 205488 / 398506 Next

Generating data from Null Distribution

Jim

the 2x2 case is reasonably straightforward because the support
is quite a small set. 

With the aylmer package you could do this:

 > a <- matrix(c(1,5,7,8),2,2)
 > sample(seq_along(allprobs(a)),100,replace=TRUE,prob=allprobs(a))
  [1] 3 2 4 1 3 4 4 4 4 3 3 4 4 2 3 4 5 4 3 3 4 4 2 1 4 3 3 3 4 2 3 4 3 
4 4 2 3
 [38] 3 4 3 4 4 3 4 3 2 3 4 2 3 3 4 2 3 2 3 1 3 5 1 3 2 3 3 4 5 2 5 1 3 
3 4 3 5
 [75] 4 2 3 4 5 2 3 4 4 3 3 3 4 3 4 6 3 3 4 2 4 4 2 3 2 3
 >

For bigger tables the matter becomes quite complicated but you
can use randomboards() of the aylmer package, which generates
random samples using the Metropolis-Hastings algorithm.

HTH

Robin
Jim Silverton wrote: