Skip to contents

Bayesian IRT likelihood (deterministic part of CJR machinery)

Usage

morie_spatial_voting_bayesian_irt_likelihood(votes, x, alpha, beta)

Arguments

votes

Binary matrix. @param x Ideal points.

x

Matrix or data.frame of vote data (rows = legislators, columns = roll-call votes).

alpha

Difficulty. @param beta Discrimination.

beta

Numeric vector of item-difficulty parameters; one entry per column of x.

Value

List with loglik, vote_probs, n_correct, n_total, accuracy.

References

Clinton, Jackman & Rivers (2004).

Examples

v <- matrix(stats::rbinom(20, 1, 0.5), 4, 5)
morie_spatial_voting_bayesian_irt_likelihood(
  v, matrix(rnorm(4), 4, 1), rep(0, 5), matrix(rnorm(5), 5, 1))
#> $loglik
#> [1] -15.96142
#> 
#> $vote_probs
#>           [,1]      [,2]      [,3]      [,4]      [,5]
#> [1,] 0.3213825 0.8500217 0.4693241 0.2622438 0.8801091
#> [2,] 0.4141079 0.6861280 0.4856382 0.3829512 0.7088177
#> [3,] 0.3884281 0.7367472 0.4812445 0.3486802 0.7637095
#> [4,] 0.2846557 0.8982567 0.4623835 0.2174507 0.9253802
#> 
#> $n_correct
#> [1] 11
#> 
#> $n_total
#> [1] 20
#> 
#> $accuracy
#> [1] 0.55
#>