Simulate data from the hierarchical Dawid-Skene model

simulate_hier_dawid_skene_model(pi, mu, sigma, sim_data, seed = NULL)

Arguments

pi

The pi parameter of the hierarchical Dawid-Skene model.

mu

The mu parameter of the hierarchical Dawid-Skene model.

sigma

The sigma parameter of the hierarchical Dawid-Skene model.

sim_data

Data to guide the simulation. The data must be in the long data format used in rater() except without the 'rating' column. The data specifies:

  • the number of items in the data, and

  • which raters rate each item and how many times they do so.

seed

An optional random seed to use.

Value

The passed sim_data augmented with columns:

  • "z" containing the latent class of each item,

  • "rating" containing the simulated rating.

Details

The number of raters implied by the entries in the rater column must match the number of raters implied by the passed theta parameter.

Examples


# \donttest{

J <- 5
K <- 4

pi <- rep(1 / K, K)

mu <- matrix(0, nrow = K, ncol = K)
diag(mu) <- 5

sigma <- matrix(sqrt(2) / sqrt(pi), nrow = K, ncol = K)

sim_data <- data.frame(item = rep(1:2, each = 5), rater = rep(1:5, 2))

sim_result <- simulate_hier_dawid_skene_model(pi, mu, sigma, sim_data)

sim_result$sim
#>    item rater z ratings
#> 1     1     1 4       4
#> 2     1     2 4       4
#> 3     1     3 4       4
#> 4     1     4 4       4
#> 5     1     5 4       4
#> 6     2     1 4       4
#> 7     2     2 4       2
#> 8     2     3 4       4
#> 9     2     4 4       3
#> 10    2     5 4       1
sim_result$theta
#> , , 1
#> 
#>            [,1]        [,2]         [,3]        [,4]
#> [1,] 0.97296636 0.143441428 0.0005548300 0.003496132
#> [2,] 0.99574957 0.142097543 0.0001453713 0.029210307
#> [3,] 0.95693629 0.004366192 0.0178696398 0.005008288
#> [4,] 0.04328287 0.011771894 0.0247064217 0.074430736
#> [5,] 0.99850754 0.135293157 0.0090763604 0.155414724
#> 
#> , , 2
#> 
#>              [,1]      [,2]         [,3]        [,4]
#> [1,] 0.0090112145 0.5696757 0.0005548300 0.003496132
#> [2,] 0.0014168100 0.5737074 0.0001453713 0.029210307
#> [3,] 0.0143545716 0.9869014 0.0178696398 0.005008288
#> [4,] 0.3189057097 0.9646843 0.0247064217 0.074430736
#> [5,] 0.0004974864 0.5941205 0.0090763604 0.155414724
#> 
#> , , 3
#> 
#>              [,1]        [,2]      [,3]        [,4]
#> [1,] 0.0090112145 0.143441428 0.9983355 0.003496132
#> [2,] 0.0014168100 0.142097543 0.9995639 0.029210307
#> [3,] 0.0143545716 0.004366192 0.9463911 0.005008288
#> [4,] 0.3189057097 0.011771894 0.9258807 0.074430736
#> [5,] 0.0004974864 0.135293157 0.9727709 0.155414724
#> 
#> , , 4
#> 
#>              [,1]        [,2]         [,3]      [,4]
#> [1,] 0.0090112145 0.143441428 0.0005548300 0.9895116
#> [2,] 0.0014168100 0.142097543 0.0001453713 0.9123691
#> [3,] 0.0143545716 0.004366192 0.0178696398 0.9849751
#> [4,] 0.3189057097 0.011771894 0.0247064217 0.7767078
#> [5,] 0.0004974864 0.135293157 0.0090763604 0.5337558
#> 

# }