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] -13.67235
#> 
#> $vote_probs
#>           [,1]      [,2]      [,3]      [,4]      [,5]
#> [1,] 0.5003823 0.4908906 0.5350893 0.4778274 0.4822821
#> [2,] 0.5036739 0.4131456 0.8013291 0.2965312 0.3347056
#> [3,] 0.4983696 0.5387906 0.3536119 0.5937282 0.5751359
#> [4,] 0.4987749 0.5291696 0.3888806 0.5707191 0.5566082
#> 
#> $n_correct
#> [1] 12
#> 
#> $n_total
#> [1] 20
#> 
#> $accuracy
#> [1] 0.6
#>