Bradley-Terry Model doesn't recover parameters

I am fitting a Bradley-Terry model on binary choice data between two pairs of dollar amounts/probabilities. I am currently doing parameter recovery for my risk aversion parameter–r in the model below. Specifically, there are no posterior samples for r \approx 0 but there are samples for |r| > 0.1, there are divergent transitions, and the chains don’t mix. I have unsuccessfully tried various fixes–non-centered parameterization, increasing adapt_delta, and running a lot of iterations. I’m not sure how best to proceed. Thanks!

functions{
  real pwr_val(real money, real r){
    real v; 
    real money_shift = money + 1;
      if (r < 00){
      v = -money_shift^r;
    } else if (r > 0){
      v = money_shift^r;
    } else {
      v = log(money_shift);
    }
    return v;
  }
}
data {
  int<lower=0> K;                       // Number of different distributions
  int<lower=0> N;                       // Number of comparisons made
  int<lower=1, upper=K> dist0[N];       // distribution 0 for comparison n
  int<lower=1, upper=K> dist1[N];       // distribution 1 for comparison n
  matrix[K, 8] dist_val;                // Dollar value for the outcomes
  vector[8] p_outcome_round;            // Probabilities for each outcome
  int<lower=0, upper=1> y[N];           // winner for game n
}

parameters {
  real<lower = -10, upper = 10> r;
}
transformed parameters{
  vector[N] mu_diff;                  // Difference in mean value for comparison N
  matrix[K, 8] dist_pwr_utils; 
  vector[K] dist_pwr_util; 
  // Get the mean value for each distribution
  for (k in 1:K) {
    for (j in 1:8) {
      dist_pwr_utils[k, j] = p_outcome_round[j] * pwr_val(dist_val[k, j], r);
    }
    dist_pwr_util[k] = sum(dist_pwr_utils[k]) ;
  }
  // get the predicted difference for each item
  for (n in 1:N) {
    mu_diff[n] = dist_pwr_util[dist1[n]] - dist_pwr_util[dist0[n]]; 

  }
}
model {
  r ~ normal(0, 1);
  y ~ bernoulli_logit(mu_diff);
}

Have you looked here ? Are you using @Bob_Carpenter’s implementation?

Also consider https://cran.r-project.org/package=pcFactorStan

1 Like

This was user error. I needed to standardize the transformed parameter dist_pwr_util to match the generated data. For future reference here’s a great post on BT Models: https://statmodeling.stat.columbia.edu/2014/07/13/stan-analyzes-world-cup-data/