Simulate data (slice of) an array: Simulate n observations from the array x conditional on the variables in margin (a vector of indices) takes values given by margin.value
simulateArray(x, nsim =1, margin, value.margin, seed =NULL)## S3 method for class 'table'simulate(object, nsim =1, seed =NULL, margin, value.margin,...)## S3 method for class 'xtabs'simulate(object, nsim =1, seed =NULL, margin, value.margin,...)## S3 method for class 'array'simulate(object, nsim =1, seed =NULL, margin, value.margin,...)
Arguments
x, object: An array.
nsim: Number of cases to simulate.
margin, value.margin: Specification of slice of array to simulate from.
seed: Seed to be used for random number generation.
...: Additional arguments, currently not used.
Returns
A matrix.
Note
The current implementation is fragile in the sense that it is not checked that the input argument x is an array.
Examples
## 2x2 arrayx <- parray(c("a","b"), levels=c(2,2), values=1:4)x <- tabNew(c("a","b"), levels=c(2,2), values=1:4)## Simulate from entire arrays <- simulateArray(x,1000)xtabs(~., as.data.frame(s))## Simulate from slice defined by that dimension 1 is fixed at level 2s <-simulateArray(x,1000, margin=1, value.margin=2)xtabs(~., as.data.frame(s))## 2 x 2 x 2 arrayx <- parray(c("a","b","c"), levels=c(2,2,2), values=1:8)## Simulate from entire arrays <-simulateArray(x,36000)xtabs(~., as.data.frame(s))## Simulate from slice defined by that dimension 3 is fixed at level 1s <-simulateArray(x,10000,3,1)xtabs(~., as.data.frame(s))