psrf: Calculates the potential scale reduction factor.

Description Usage Arguments Value Author(s) References See Also Examples

View source: R/psrf.R

Description

This function calculates the potential scale reduction factor of parameters or hyperparameters over several MCMC simulations (or one simulation split up). This can serve as a convergence diagnostic.

Usage

1
psrf(parameters)

Arguments

parameters

A list of MCMC trajectories, where each trajectory is a matrix with NumParams rows and NumIterations columns, where NumParams is the number of parameters and NumIterations is the number of samples.

Value

A vectors of length NumParams, containing the PSRF values for each parameter.

Author(s)

Sophie Lebre

Frank Dondelinger

References

Gelman and Rubin (1992) Inference from iterative simulation using multiple sequences, Statistical Science.

See Also

psrf_check, psrf_check_hyper

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Generate 5 'runs' of random samples from Gaussian N(0,1)
samples = list()

for(run in 1:5) {
  samples[[run]] = matrix(rnorm(1000), 1, 1000)
}

# Check potential scale reduction factor
# (Will be very close to 1 due to the samples being from 
# the same distribution)
psrf.val = psrf(samples)


# Now use slightly different Gaussian distributions for each 'run'.
for(run in 1:5) {
  mean = runif(1, 0, 2)
  samples[[run]] = matrix(rnorm(1000, mean, 1), 1, 1000)
}

# Check potential scale reduction factor
# (Should be > 1.1)
psrf.val = psrf(samples)

EDISON documentation built on May 2, 2019, 2:39 a.m.