run_gender_mcmc: Run the BSBT with Gender Effect MCMC algorithm

Description Usage Arguments Value Examples

View source: R/mcmc_functions.R

Description

This function runs the BSBT MCMC algorithm where the male and female judges can be separated. It generates samples for the grand mean of the male and female perceptions for the derivation in each area 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 gender. There should be a win matrix for the male judges, and a win matrix for the female judges. Similarly, initial estimates for the grand mean and difference parameters need to be included seperately.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
run_gender_mcmc(
  n.iter,
  delta,
  covariance.matrix,
  male.win.matrix,
  female.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.

male.win.matrix

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

female.win.matrix

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

f.initial

A vector of the initial estimate for f, the grand mean of men and women's perceptions

g.initial

A vector of the initial estimate for g, the difference between men and women's 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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
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_gender_mcmc(n.iter, delta, covariance.matrix, men.win.matrix,
    women.win.matrix, f.initial, g.initial)

BSBT documentation built on March 15, 2021, 1:07 a.m.