run_symmetric_mcmc: Run the BSBT with symmetric effect MCMC algorithm

View source: R/mcmc_functions.R

run_symmetric_mcmcR Documentation

Run the BSBT with symmetric effect MCMC algorithm

Description

This function runs the BSBT MCMC algorithm where two types are judges can be separated. It generates samples for the grand mean of the types perceptions for the derivation in each object and the difference between them. It is similar to run_mcmc. This function requires the data to be separate into two parts, one for each type. There should be a win matrix for each type. Similarly, initial estimates for the grand mean and difference parameters need to be included separately.

Usage

run_symmetric_mcmc(
  n.iter,
  delta,
  covariance.matrix,
  type1.win.matrix,
  type2.win.matrix,
  f.initial,
  g.initial,
  omega = 0.1,
  chi = 0.1,
  thinning = 1
)

Arguments

n.iter

The number of iterations to be run

delta

The underrlaxed tuning parameter. Must be in (0, 1)

covariance.matrix

The output from the covariance matrix function, which contains the decomposed and inverted covariance matrix. The variance hyperparameter must be set to 1.

type1.win.matrix

A matrix, where w_ij give the number of times object i beat j when judged by men

type2.win.matrix

A matrix, where w_ij give the number of times object i beat j when judged by women

f.initial

A vector of the initial estimate for f, the grand mean of the perceptions

g.initial

A vector of the initial estimate for g, the difference between the perceptions

omega

The value of the inverse gamma shape parameter

chi

The value of the inverse gamma scale parameter

thinning

Setting thinning to i will store every i^th iteration. This may be required for very long runs.

Value

A list of MCMC output

  • f.matrix - A matrix containing the each iteration of f

  • g.matrix - A matrix containing the each iteration of g

  • alpha.sq - A matrix containing the iterations of alpha^2

  • acceptance.rate - The acceptance rate for f and g

  • time.taken - Time taken to run the MCMC algorithm in seconds

Examples


n.iter <- 10
delta <- 0.1
covariance.matrix <- list()
covariance.matrix$mean <- c(0, 0, 0)
covariance.matrix$decomp <- diag(3)
covariance.matrix$inv    <- diag(3)
men.comparisons <- data.frame("winner" = c(1, 3, 2, 2), "loser" = c(3, 1, 1, 3))
women.comparisons <- data.frame("winner" = c(1, 2, 1, 2), "loser" = c(3, 1, 3, 3))
men.win.matrix <- comparisons_to_matrix(3, men.comparisons) #win matrix for the male judges
women.win.matrix <- comparisons_to_matrix(3, women.comparisons) #win matrix for the female judges
f.initial <- c(0, 0, 0) #initial estimate for grand mean
g.initial <- c(0, 0, 0) #initial estimate for differences

mcmc.output <- run_symmetric_mcmc(n.iter, delta, covariance.matrix, men.win.matrix,
    women.win.matrix, f.initial, g.initial)


BSBT documentation built on Aug. 9, 2022, 5:06 p.m.