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 3       1
#> 2     1     2 3       3
#> 3     1     3 3       3
#> 4     1     4 3       3
#> 5     1     5 3       4
#> 6     2     1 4       4
#> 7     2     2 4       4
#> 8     2     3 4       4
#> 9     2     4 4       4
#> 10    2     5 4       4
sim_result$theta
#> , , 1
#> 
#>           [,1]         [,2]         [,3]         [,4]
#> [1,] 0.9277802 0.0047418760 0.3103373894 2.889353e-05
#> [2,] 0.9825994 0.0961698551 0.0003368129 3.345813e-04
#> [3,] 0.8875942 0.0006904351 0.0001641961 1.707973e-01
#> [4,] 0.6564395 0.0043353800 0.0004222629 2.529998e-02
#> [5,] 0.9101537 0.0162473903 0.3300404513 1.294223e-03
#> 
#> , , 2
#> 
#>             [,1]      [,2]         [,3]         [,4]
#> [1,] 0.024073252 0.9857744 0.3103373894 2.889353e-05
#> [2,] 0.005800196 0.7114904 0.0003368129 3.345813e-04
#> [3,] 0.037468598 0.9979287 0.0001641961 1.707973e-01
#> [4,] 0.114520158 0.9869939 0.0004222629 2.529998e-02
#> [5,] 0.029948781 0.9512578 0.3300404513 1.294223e-03
#> 
#> , , 3
#> 
#>             [,1]         [,2]        [,3]         [,4]
#> [1,] 0.024073252 0.0047418760 0.068987832 2.889353e-05
#> [2,] 0.005800196 0.0961698551 0.998989561 3.345813e-04
#> [3,] 0.037468598 0.0006904351 0.999507412 1.707973e-01
#> [4,] 0.114520158 0.0043353800 0.998733211 2.529998e-02
#> [5,] 0.029948781 0.0162473903 0.009878646 1.294223e-03
#> 
#> , , 4
#> 
#>             [,1]         [,2]         [,3]      [,4]
#> [1,] 0.024073252 0.0047418760 0.3103373894 0.9999133
#> [2,] 0.005800196 0.0961698551 0.0003368129 0.9989963
#> [3,] 0.037468598 0.0006904351 0.0001641961 0.4876080
#> [4,] 0.114520158 0.0043353800 0.0004222629 0.9241001
#> [5,] 0.029948781 0.0162473903 0.3300404513 0.9961173
#> 

# }