
Dynamic IRT: ideal points that drift by a random walk (Martin and Quinn 2002)
Source:R/spatial_voting.R
morie_spatial_voting_dynamic_irt.RdThe one-dimensional dynamic item response model of Martin and Quinn (2002),
fitted by their Gibbs sampler: a vote is cast when the latent utility
\(z_{jk} = -\alpha_k + \beta_k \theta_{j,t(k)} + \varepsilon_{jk}\)
is positive, \(\varepsilon \sim N(0, 1)\); the ideal points follow a
random walk, \(\theta_{j,0} \sim N(e_0, E_0)\),
\(\theta_{j,t} \sim N(\theta_{j,t-1}, \tau^2_j)\); and the roll-call
parameters have normal priors \(\alpha_k \sim N(a_0, 1/A_0)\),
\(\beta_k \sim N(b_0, 1/B_0)\). Each sweep draws the latent utilities
(truncated normals), every roll call's \((\alpha, \beta)\) (conjugate
normal), every legislator's whole path by forward filtering and backward
sampling, and, when c0 and d0 are positive, the evolution
variances from \(IG((c_0 + T)/2, (d_0 + SS)/2)\). The sign is fixed by
reflecting a draw whenever the anchor legislator's mean ideal point
is negative. This is the model of MCMCpack::MCMCdynamicIRT1d, with
the same default priors; both recover the same paths on simulated data.
Usage
morie_spatial_voting_dynamic_irt(
votes,
time_periods,
n_samples = 500L,
burn_in = 100L,
seed = 42L,
thin = 1L,
tau2 = 1,
c0 = -1,
d0 = -1,
e0 = 0,
E0 = 1,
a0 = 0,
A0 = 0.1,
b0 = 0,
B0 = 0.1,
anchor = NULL
)Arguments
- votes
Legislators-by-roll-calls matrix of 0/1 votes (-1/1 is read as 0/1);
NAfor absent.- time_periods
Period of each roll call (one entry per column).
- n_samples
Posterior draws kept.
- burn_in
Sweeps discarded first.
- seed
RNG seed.
- thin
Keep every
thin-th sweep.- tau2
Evolution variance (the starting value when it is estimated).
- c0, d0
Inverse-gamma prior on \(\tau^2\); \(\tau^2\) is held at
tau2unless both are positive.- e0, E0
Prior mean and variance of the initial ideal point.
- a0, A0, b0, B0
Prior means and precisions of \(\alpha\) and \(\beta\).
- anchor
Legislator (row index) whose ideal point is kept positive; the largest first principal-component score by default.
Value
A list with theta (legislators by periods, posterior means),
theta_sd, alpha, beta, tau2,
per_period (one entry per period with its ideal_points),
periods, n_periods, n_legislators, n_samples,
anchor and engine.
References
Martin, A. D. and Quinn, K. M. (2002). Dynamic ideal point estimation via Markov chain Monte Carlo for the U.S. Supreme Court, 1953-1999. Political Analysis 10(2), 134-153.
Examples
# \donttest{
set.seed(7)
N <- 12; Tn <- 3; kper <- 15
period <- rep(1:Tn, each = kper)
truth <- t(sapply(rnorm(N), function(s) s + cumsum(c(0, rnorm(Tn - 1, 0, 0.3)))))
a <- rnorm(Tn * kper, 0, 0.5); b <- rnorm(Tn * kper, 1.5, 0.5)
p <- pnorm(-rep(a, each = N) + rep(b, each = N) * truth[, period])
V <- matrix(rbinom(length(p), 1, p), N)
fit <- morie_spatial_voting_dynamic_irt(V, period, n_samples = 400, burn_in = 100)
abs(cor(as.numeric(fit$theta), as.numeric(truth))) # the paths are recovered
#> [1] 0.9440225
# }