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       3
#> 5     1     5 4       2
#> 6     2     1 3       3
#> 7     2     2 3       3
#> 8     2     3 3       3
#> 9     2     4 3       3
#> 10    2     5 3       3
sim_result$theta
#> , , 1
#> 
#>           [,1]        [,2]        [,3]        [,4]
#> [1,] 0.8846549 0.004229251 0.008074149 0.003371913
#> [2,] 0.9735868 0.002462831 0.125093885 0.010066566
#> [3,] 0.9360601 0.004568268 0.000196505 0.163554156
#> [4,] 0.9989373 0.011813939 0.045420843 0.238438657
#> [5,] 0.9945303 0.118367443 0.002452571 0.144794985
#> 
#> , , 2
#> 
#>             [,1]      [,2]        [,3]        [,4]
#> [1,] 0.038448362 0.9873122 0.008074149 0.003371913
#> [2,] 0.008804405 0.9926115 0.125093885 0.010066566
#> [3,] 0.021313316 0.9862952 0.000196505 0.163554156
#> [4,] 0.000354222 0.9645582 0.045420843 0.238438657
#> [5,] 0.001823241 0.6448977 0.002452571 0.144794985
#> 
#> , , 3
#> 
#>             [,1]        [,2]      [,3]        [,4]
#> [1,] 0.038448362 0.004229251 0.9757776 0.003371913
#> [2,] 0.008804405 0.002462831 0.6247183 0.010066566
#> [3,] 0.021313316 0.004568268 0.9994105 0.163554156
#> [4,] 0.000354222 0.011813939 0.8637375 0.238438657
#> [5,] 0.001823241 0.118367443 0.9926423 0.144794985
#> 
#> , , 4
#> 
#>             [,1]        [,2]        [,3]      [,4]
#> [1,] 0.038448362 0.004229251 0.008074149 0.9898843
#> [2,] 0.008804405 0.002462831 0.125093885 0.9698003
#> [3,] 0.021313316 0.004568268 0.000196505 0.5093375
#> [4,] 0.000354222 0.011813939 0.045420843 0.2846840
#> [5,] 0.001823241 0.118367443 0.002452571 0.5656150
#> 

# }