Learn R Programming

LaplacesDemon (version 16.1.1)

CSF: Cumulative Sample Function

Description

The Cumulative Sample Function (CSF) is a visual MCMC diagnostic in which the user may select a measure (such as a variable, summary statistic, or other diagnostic), and observe a plot of how the measure changes over cumulative posterior samples from MCMC, such as the output of LaplacesDemon. This may be considered to be a generalized extension of the cumuplot in the coda package, which is a more restrictive form of the cusum diagnostic introduced by Yu and Myckland (1998).

Yu and Myckland (1998) suggest that CSF plots should be examined after traditional trace plots seem convergent, and assert that faster mixing chains (which are more desirable) result in CSF plots that are more `hairy' (as opposed to smooth), though this is subjective and has been debated. The LaplacesDemon package neither supports nor contradicts the suggestion of mixing and `hairiness', but suggests that CSF plots may be used to provide additional information about a chain. For example, a user may decide on a practical burnin given when a conditional mean obtains a certain standard error.

Usage

CSF(x, name, method="Quantiles", quantiles=c(0.025,0.500,0.975), output=FALSE)

Arguments

x

This is a vector of posterior samples from MCMC.

name

This is an optional name for vector x, and is input as a quoted string, such as name="theta".

method

This is a measure that will be observed over the course of cumulative samples of x. It defaults to method="Quantiles", and optional methods include: "ESS", "Geweke.Diagnostic", "HPD", "is.stationary", "Kurtosis", "MCSE", "MCSE.bm", "MCSE.sv", "Mean", "Mode", "N.Modes", "Precision", "Quantiles", and "Skewness".

quantiles

This optional argument applies only when method="Quantiles", in which case this vector indicates the probabilities that will be observed. It defaults to the median and 95% probability interval bounds (see p.interval for more information).

output

Logical. If output=TRUE, then the results of the measure over the course of the cumulative samples will be output as an object, either a vector or matrix, depending on the method argument. The output argument defaults to FALSE.

Details

When method="ESS", the effective sample size (ESS) is observed as a function of the cumulative samples of x. For more information, see the ESS function.

When method="Geweke.Diagnostic", the Z-score output of the Geweke diagnostic is observed as a function of the cumulative samples of x. For more information, see the Geweke.Diagnostic function.

When method="HPD", the Highest Posterior Density (HPD) interval is observed as a function of the cumulative samples of x. For more information, see the p.interval function.

When method="is.stationary", stationarity is logically tested and the result is observed as a function of the cumulative samples of x. For more information, see the is.stationary function.

When method="Kurtosis", kurtosis is observed as a function of the cumulative samples of x.

When method="MCSE", the Monte Carlo Standard Error (MCSE) estimated with the IMPS method is observed as a function of the cumulative samples of x. For more information, see the MCSE function.

When method="MCSE.bm", the Monte Carlo Standard Error (MCSE) estimated with the batch.means method is observed as a function of the cumulative samples of x. For more information, see the MCSE function.

When method="MCSE.sv", the Monte Carlo Standard Error (MCSE) estimated with the sample.variance method is observed as a function of the cumulative samples of x. For more information, see the MCSE function.

When method="Mean", the mean is observed as a function of the cumulative samples of x.

When method="Mode", the estimated mode is observed as a function of the cumulative samples of x. For more information, see the Mode function.

When method="N.Modes", the estimated number of modes is observed as a function of the cumulative samples of x. For more information, see the Modes function.

When method="Precision", the precision (inverse variance) is observed as a function of the cumulative samples of x.

When method="Quantiles", the quantiles selected with the quantiles argument are observed as a function of the cumulative samples of x.

When method="Skewness", skewness is observed as a function of the cumulative samples of x.

References

Yu, B. and Myckland, P. (1997). "Looking at Markov Samplers through Cusum Path Plots: A Simple Diagnostic Idea". Statistics and Computing, 8(3), p. 275--286.

See Also

burnin, ESS, Geweke.Diagnostic, is.stationary, LaplacesDemon, MCSE, Mode, Modes, and p.interval.

Examples

Run this code
# NOT RUN {
#Commented-out because of run-time for package builds
#library(LaplacesDemon)
#x <- rnorm(1000)
#CSF(x, method="ESS")
#CSF(x, method="Geweke.Diagnostic")
#CSF(x, method="HPD")
#CSF(x, method="is.stationary")
#CSF(x, method="Kurtosis")
#CSF(x, method="MCSE")
#CSF(x, method="MCSE.bm")
#CSF(x, method="MCSE.sv")
#CSF(x, method="Mean")
#CSF(x, method="Mode")
#CSF(x, method="N.Modes")
#CSF(x, method="Precision")
#CSF(x, method="Quantiles")
#CSF(x, method="Skewness")
# }

Run the code above in your browser using DataLab