The syntax for constructing a Convergence Diagnostics and Output Analysis object is as follows:
CODA(chains[, prior])
Tabela 9.19. CODA constructor settings
Parameter name | Parameter type | Description |
---|---|---|
chains | MarkovChain[] | an array of chains to examine |
prior | MultivariateDistribution | the a-priori distribution |
Tabela 9.20. CODA methods
Method name and syntax | Description of parameters | Output | Output type |
---|---|---|---|
getOutputAnalysis() | an OutputAnalysis object | ||
getDiagnostics() | a Diagnostics object | ||
display() | displays a window with statistical infomation about the chains | void |
The constructor of OutputAnalysis objects has the following syntax:
OutputAnalysis(chains, prior)
where chains is an array of MarkovChain (MarkovChain[]) and prior is a MultivariateDistribution object.
Tabela 9.21. OutputAnalysis methods
Method name and syntax | Description of parameters | Output | Output type |
---|---|---|---|
statistics() | a Statistics object containing various statistics | ||
batchMeanVariance(chainNr) | chainNr - the number of chain for calculations (int) | mean variance of mean calculated in batch mode (i.e. calculated on data split into a number of groups, the result is the variance between means calculated for each group) | double[] |
batchStandardError(chainNr) | chainNr - the number of chain for calculations (int) | the standard error calculated in batch mode | double[] |
getKernelDensityEstimator() | the kernel density estimator used for displaying density plots | a KernelDensityEstimator object | |
setKernelDensityEstimator(kde) | kde - a KernelDensityEstimator object which should be used for displaying density plots | void | |
plots() | displays a window with trace and density plots | void |
Statistics are created by an OutputAnalysis object.
Tabela 9.22. Statistics methods
Method name and syntax | Description of parameters | Output | Output type |
---|---|---|---|
toString() | a string contaning all statistical information | String | |
display() | displays a window with all statistical information | void |
A ChainStatistics object contains statistics for a single Markov chain.
Tabela 9.23. ChainStatistics public fields
Field | Description | Type |
---|---|---|
mode | the mode values for the chain | double[] |
median | the median values for the chain | double[] |
average | the average values for the chain | double[] |
standardDeviation | standard deviation values for the chain | double[] |
naiveStandardError | the standard error values for the chain calculated as | double[] |
batchStandardError | the standard error values calculated in batch mode | double[] |
batchSize | the size of samples used in batch mode | int |
quantiles | a two dimensiona array of quantiles: 1st dimension - the no. of rank of quantile (its value is on the corresponding position of quantilesRank), 2nd dimenson - the no. of attribute | double[][] |
quantilesRank | the ranks of quantiles | double[] |
varName | variables names | String[] |
A trace plot for a given variable shows the value of that variable for every moment in the chain. Traces of a variable descending from two or more different chains are shown on the same plot.
Density plots show the estimated density of each variable. Samples for estimation are taken from all chains combined togoether. If prior is defined, the plot of prior density is also drawn on the chart. Confidence levels for both densities are also displayed. The various etimating methods is decribed in the subsection below. Kernel type and confidence interval can be chosen from the
menu.The constructor has the following syntax:
KernelDensityEstimator([type])
Tabela 9.25. KernelDensityEstimator constructor settings
Parameter name | Parameter type | Description |
---|---|---|
type | KernelType | the type of kernel |
Tabela 9.26. KernelDensityEstimator methods
Method name and syntax | Description of parameters | Output | Output type |
---|---|---|---|
getKernel() | the type of kernel used for estimation | KernelType | |
setKernel(kernel) | kernel - the type of kernel which should be used for estimation(KernelType ) | void | |
getBandWidth() | the bannwidth, default is NaN | double | |
setBandWidth(bw) | bw - the bandwidth (double) | void | |
getLastUsedBandWidth() | retrieves the bandwidth used for the most recent estimation, if bandwidth had been set to NaN it would have been automatically calculated using the thumb rule | double | |
getPointsCount() | the number of points used for estimation | int | |
setPointsCount(points) | points - the number of points in which the density should be estimated | void | |
estimate(x) | x - real observations | a two dimensional array of estimantes (2nd. position) and calculation points (1st. position) | double[][] |
The constructor of Diagnostics objects has the following syntax:
Diagnostics(chains)
where chains is an array of MarkovChain (MarkovChain[]).
Tabela 9.28. Diagnostics methods
Method name and syntax | Description of parameters | Output | Output type |
---|---|---|---|
getGeweke() | a Geweke object containing Geweke z-statictics | a Geweke object | |
getAutocorrelation() | an Autocorrelation object containing the autocorrelation statistics | an Autocorrelation object | |
getGelmanRubin() | a GelmanRubin object containing the values of R and multiR coefficients | a GelmanRubin object |
The Autocorrelation class can calculate autocorrelation up to 50 lags.
The constructor has the following syntax:
Autocorrelation(chains)
where chains is an array of MarkovChain (MarkovChain[]).
Tabela 9.29. Autocorrelation methods
Method name and syntax | Description of parameters | Output | Output type |
---|---|---|---|
corr(chainNr) | chainNr - the number of the chain for which autocorrelattion should be calculated (int) | a three dimensional array of correlation coefficients consisting of correlation matrices with appropriate lag of second variable: 1st. dimension - the number of lag, 2nd and 3rd dimensions - the variable numbers | double[][][] |
corr() | a four dimensional array of autocorrelation data for all chains: 1st. dimension - the chain number, 2nd. dimension - the lag number, 3rd. and 4th, dimensions - the variable numbers | double[][][][] | |
plots() | displays the autocorrelation plots | void | |
display() | displays a window with the autocorrelation statistics | void | |
toString() | returns a string with the autocorrelation statistics | String |
This convergence diagnostic is based on a test for equality of the means of the first and last part of the Markov chain (by default the first 10% and the last 50%). If the samples are drawn from the stationary distribution of the chain, the two means are equal and Geweke's statistic has an asymptotically standard normal distribution. The test statistic is a standard Z-score: the difference between the two sample means divided by its estimated standard error calculated under the assumption that the two parts of the chain are asymptotically independent, which requires that the sum of this two fractions is strictly less than 1.
Plots show what happens to Geweke's Z-score when successively larger numbers of iterations are discarded from the beginning of the chain. The first half of the Markov chain is divided into segments (by default ), and next the Geweke's Z-score is repeatedly calculated. The first Z-score is calculated with all iterations in the chain, the second after discarding the first segment, the third after discarding the first two segments, and so on. The last Z-score is calculated using only the samples in the second half of the chain and the plot never discards more than half of the chain to preserve the asymptotic conditions required for Geweke's diagnostic.
The constructor has the following syntax:
Geweke(chains)
where chains is an array of MarkovChain (MarkovChain[]).
Tabela 9.30. Geweke methods
Method name and syntax | Description of parameters | Output | Output type |
---|---|---|---|
zScore() | a two dimensional array with zScores values: 1st. dimension - the chain number, 2nd. dimension - the variable number. | double[][] | |
plots() | displays a window with Geweke plots | void | |
display() | displays a window with Geweke z-scores | void | |
toString() | returns a string with Geweke z-scores | String |
Gelman and Rubin in 1992 proposed a general approach to monitoring convergence of MCMC output in which two or more parallel chains are run with starting values that are overdispersed relative to the posterior distribution. [Brooks, Gelman 1998] Convergence is diagnosed when the chains have 'forgotten' their initial values, and the output from all chains is indistinguishable. This diagnostic is applied to a single variable from the chain. It is based a comparison of within-chain and between-chain variances, and is similar to a classical analysis of variance. Additionaly, multivariate version of the R coefficient is also calculated.
Plots show the evolution of Gelman and Rubin's shrink factor and variances calculated on the second half of the chain as the number of iterations increases.
The constructor has the following syntax:
GelmanRubin(chains)
where chains is an array of MarkovChain (MarkovChain[]).
Tabela 9.31. GelmanRubin methods
Method name and syntax | Description of parameters | Output | Output type |
---|---|---|---|
getMPSRF() | calculates the multivariate potential scale reduction factor | double | |
getMPSRF50() | calculates the multivariate potential scale reduction factor for the second halves of the chains | double | |
getPSRF() | calculates the (univariate) potential scale reduction factor for variable | double[] | |
getPSRF50() | calculates the (univariate) potential scale reduction factor for each variable for the second halves of the chains | double[] | |
getWithinVariance() | calculates the within variance matrix | double[][] | |
getDetWithinVariance() | calculates the determinant of the within variance matrix | double | |
getWithinVariance50() | calculates the within variance matrix for the second halves of the chains | double[][] | |
double getDetWithinVariance50() | calculates the determinant of the within variance matrix for second halves of the chains | double | |
getPosteriorVariance() | calculates the posterior variance matrix | double[][] | |
getDetPosteriorVariance() | calculates the determinant of the posterior variance matrix | double | |
getPosteriorVariance50() | calculates the posterior variance matrix for the second halves of the chains | double[][] | |
getDetPosteriorVariance50() | calculates the determinant of the posterior variance matrix for the second halves of the chains | double | |
plots() | displays the Gelman&Rubin plots window | void | |
display() | displays a window with Gelman&Rubin diagnostic data | void | |
toString() | returns a string with Gelman&Rubin diagnostic data | String |