Learn R Programming

gRbase (version 1.8-5.1)

array-simulate: Simulate data from array.

Description

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

Usage

simulateArray(x, nsim = 1, margin, value.margin)

tabSim(x, nsim = 1, margin, value.margin)

ar_sim(x, nsim = 1, margin, value.margin)

Arguments

x

An array.

nsim

Number of cases to simulate

margin, value.margin

Specification of slice of array to simulate from

Value

A matrix

Examples

Run this code
# NOT RUN {
 
## 2x2 array
x <- parray(c("a", "b"), levels=c(2, 2), values=1:4)

## Simulate from entire array
s <- simulateArray(x, 1000)
xtabs(~., as.data.frame(s))

## Simulate from slice defined by that dimension 1 is fixed at level 2
s <-simulateArray(x, 6000, 1, 2)
xtabs(~., as.data.frame(s))

## 2 x 2 x 2 array
x <- parray(c("a", "b", "c"), levels=c(2, 2, 2), values=1:8)
## Simulate from entire array
s <-simulateArray(x, 36000)
xtabs(~., as.data.frame(s))

## Simulate from slice defined by that dimension 3 is fixed at level 1
s <-simulateArray(x, 10000, 3, 1)
xtabs(~., as.data.frame(s))


# }

Run the code above in your browser using DataLab