**# Download the manuscript:**

**
A
Bayesian approach for sample size determination in method comparison studies**,
K. Yin, P. K. Choudhary, D. Varghese and S. R. Goodman (2008).

**An R program for computing
average posterior probabilities involved in sample size determination using Yin
et al. (2008). **

**# Download the program:**

Right click on the link avgprob.R and save it as avgprob.R in the working directory. See the example below for how to run this program.

**# Description:**

It computes average posterior probabilities T11star, T22star and T12star given by equation (7) in Yin et al. (2008) for an agreement measure of interest. At present, only two agreement measures are implemented: concordance correlation and total deviation index; and only two independent sampling prior distributions are available: uniform and normal distributions. Independent improper uniform distributions over real line are taken as fitting priors of mean parameters; and independent inverse gamma distributions with a common hyperparameter value are taken as fitting priors of variance parameters.

**# Usage:**

avgprob(n, r, measure, samp.prior, param1, param2, delta = 0.80, tdi.p0 = 0.80, alpha = 0.05, AB = 0.001, n.rep = 100, n.iter = 1000, n.burn = 200)

**# Arguments:**

n = number of individuals in the model.

r = number of replicate pairs on each individual.

measure = agreement measure of interest. Options are "ccc" or "tdi" (concordance correlation coefficient or total deviation index).

samp.prior = sampling prior distribution. Options are "uniform" or "normal".

param1 = a vector of length six containing first set of parameters of independent sampling distributions of (beta_1, beta_2, log sigma_1^2, log sigma_2^2, log psi^2, log psi_I^2). When 'samp.prior = "uniform" ', it contains the lower limits of distributions. When 'samp.prior = "normal" ', it contains the means of distributions.

param2 = a vector of length six containing second set of parameters of independent sampling distributions of (beta_1, beta_2, log sigma_1^2, log sigma_2^2, log psi^2, log psi_I^2). When 'samp.prior = "uniform" ', it contains the upper limits of distributions. When 'samp.prior = "normal" ', it contains the standard deviations of distributions.

delta = scaling factor for the upper credible bound of the (possibly transformed) agreement measure. Must lie in the interval (0, 1). (Default=0.80)

tdi.p0 = probability cutoff for total deviation index. Must lie in the interval (0, 1). Ignored if measure = "ccc". (Default=0.80)

alpha = (1-posterior probability) for the upper credible bound of the agreement measure. Must lie in the interval (0, 1). (Default=0.05)

AB = common hyperparameter value for independent inverse gamma (AB, AB) distributions, which are taken as fitting priors for variances. (Default=0.001)

n.rep = number of Monte Carlo repetitions for computing average. (Default=100)

n.iter = number of Gibbs sampler iterations for posterior simulation. (Default=1000)

n.burn = length of burn in. (Default=200)

**# Value:**

A vector of three average posterior probabilities (T11star, T22star, T12star). T11star and T22star are for intra-method agreement for methods 1 and 2, and T12star is for inter-method agreement between the two methods.

**# Author(s):**

K. Yin and P.K. Choudhary ([email protected]), University of Texas at Dallas

**# Reference(s):**

Yin, K., Choudhary, P.K., Varghese, D. and Goodman, S. R. (2007). A Bayesian approach for sample size determination in method comparison studies. Submitted.

**# Example:**

To run:

1. Open R.

2. Change the working directory to the directory where avgprob.R file is stored.

3. Run source("avgprob.R") to read this file.

4. Run avgprob function with desired inputs.

Depending upon the inputs and the computer speed, it may take a while to get the output.

Running

source("avgprob.R")

param1 <- c(0.01, -0.07, -4.01, -3.82, -7.96, -7.96)

param2 <- c(0.31, 0.25, -2.84, -2.62, -3.55, -3.55)

set.seed(12345)

avgprob (23, 4, "tdi", "uniform", param1, param2, delta = 0.80, tdi.p0 = 0.80,
alpha = 0.05, AB = 0.001, n.rep = 100, n.iter = 1000, n.burn = 250)

returns

t11star t22star t12star

0.1590000 0.1523125 0.0767750

It took about 2.5 minute on a Windows computer with 1.8GHz CPU and 512 MB of RAM.