
Bayesian unfolding (Bakker and Poole 2013)
Source:R/spatial_voting.R
morie_spatial_voting_bayesian_unfolding.RdThe lognormal model of morie_spatial_voting_bayesian_mds
for a respondent-by-stimulus matrix: respondent \(i\) and stimulus
\(j\) get their own coordinates and
$$\log \delta_{ij} \sim N(\log \lVert x_i - z_j \rVert, 1 / \tau),$$
with \(N(0, 10^2)\) priors on every coordinate and
\(\tau \sim U(0, 10)\). Feeling thermometers \(T\) on 0-100 enter
as \(\delta = (100 - T) / 50\), the transformation of Bakker and
Poole; zero or missing dissimilarities are left out.
Usage
morie_spatial_voting_bayesian_unfolding(
D,
n_dims = 2L,
n_samples = 1000L,
burn_in = 200L,
seed = 42L
)Value
List: stimuli (aligned posterior mean),
stimuli_sd, ideal_points, distance_mean
(posterior mean respondent-stimulus distances), sigma,
tau, n_samples, engine.
Details
Given the stimuli the respondents are independent, and given the
respondents the stimuli are, so each block is slice sampled as one
vector per dimension (the same chain law as one at a time), and
\(\tau\) is drawn exactly. Draws are aligned (translation and
rotation) on the stimuli. On 150 simulated respondents and ten
stimuli the posterior mean respondent-stimulus distances agree with a
JAGS encoding of the same model to within 0.018, and \(\tau\) to the
third decimal. (The C sampler shipped with asmcjr could not be
used for the comparison: its .C interface keeps pointers to
freed R memory and crashes.)
References
Bakker, R. and Poole, K. T. (2013). Bayesian metric multidimensional scaling. Political Analysis 21(1), 125-140.
Examples
set.seed(1)
S <- matrix(runif(8, -0.5, 0.5), 4, 2)
R <- matrix(runif(60, -0.5, 0.5), 30, 2)
D <- sqrt(outer(R[, 1], S[, 1], "-")^2 + outer(R[, 2], S[, 2], "-")^2)
fit <- morie_spatial_voting_bayesian_unfolding(D, n_samples = 100L,
burn_in = 100L)
cor(as.numeric(fit$distance_mean), as.numeric(D))
#> [1] 0.9839341