This is the main class for a Markov chain drawn from sampling distribution. It provides all statistics of such sample or a group of samples drawn in multichain process.
The following constructors can be used to create a markov Chain object:
MarkovChain()
Create an empty chain
MarkovChain(fileName)
Read a chain from a file
MarkovChain(chain)
Create a chain with data from an array
MarkovChain(chain, values)
Create a chain with data from an array and stores the values of the approximate density of the distribution calculated at the points from chain
MarkovChain(chain, values, log)
Create a chain with data from an array and stores the values of the approximate density of the distribution calulated at the points from chain. The values can be in logarithmic form.
Table 9.1. MarkovChain constructors settings
Parameter name | Description | Values |
| |
---|---|---|---|---|
fileName | a string specifying the (path to and) name of the file containing the points from a Markov chain | string | - | |
chain | the points of Markov Chain, 1st dimension - the index no. of a point, 2nd dimension - the number of variable | two dimensional array of real values | - | |
values | the values of the density function estimating the distribution, calculated at points of the chain, i.e. value[i] is calculated for the point chain[i]. | array of real values (positive if log = false) | - | |
log | specify whether the distribution is in logarithmic form or not | true / false | false |
Table 9.2. The MarkovChain object methods
Method name and syntax | Description of parameters | Output | Output type |
---|---|---|---|
getSum() | the sum of all elements in the chain: | double[ ] | |
getSumSquare() | the sum of squares of all elements in the chain: | double[ ] | |
getAverage() | the average of the chain elements | double[ ] | |
getSSE( ) | the sum of squared errors of the chain | double[ ] | |
getStandardDeviation( ) | the standard deviation of the chain | double[ ] | |
getVariance() | the variance for the chain | double[ ] | |
getCovarianceMatrix( ) | the covariance matrix for the chain | double[ ][ ] | |
getAutocovariance(maxLag) | maxLag - the maximum lag value (integer) | the autocovariance from chain for lags from 0 to maxLag | double[ ][ ] |
getCentralMoment(rank) | rank - the rank of the central moment (integer) | the central moment with the given rank from the chain | double[ ] |
getQuantile(rank) | rank - the rank of the quantile (double) | the quantile for the chain | double[ ] |
getMode() | the mode from the chain | double[ ] | |
getModePosition() | the mode position in the chain | integer | |
getSample(burnin, thin) | burnin - number of elements to discard from the beginning (integer), thin - every thin-th element is included in the sample (integer) | return a sample with length = (chainLength - burnin) / thin | MarkovChain |
getSubChain(begin, end) | begin - first position from the chain to be included in the subchain (integer), end - last position in chain to be inclyded in the subchain (integer). | Markov chain with elements from begin to end (inclusively) | MarkovChain |
getUnivariateMarkovChain(pos) | pos - index of the dimension (integer) | the Markov chain restricted to the specified dimesion | MarkovChain |
getElement(pos) | pos - position of the element (integer) | the element at the specified position in the chain | double[ ] |
getValue(pos) | pos - the position in the chain (integer) | the value of sampling distribution calculated for the element at the specified position in the chain | double |
getDimension() | the number of dimensions of the chain | integer | |
getLength( ) | the total number of elements in the chain | integer | |
getChain() | two dimensional array of chain elements | double[ ][ ] | |
setChain(chain) | chain - two dimensional array of Markov chain elements (double[ ][ ]) | void | |
setChain(chain, length) | chain - two dimensional array of Markov chain elements (double[ ][ ]), length - how many elements from the beginning to set (integer). | void | |
setChain(chain, values, log) | chain - two dimensional array of Markov chain elements (double[ ][ ]), values - array of values of sampling distributions calculated for the related points from chain (double[ ]), log - specify whether values are in logarithmic form (boolean) | void | |
setValues(values, log) | values - array of values of sampling distributions calculated for the related points from chain (double[ ]), log - specify whether values are in logarithmic form (boolean) | void | |
getVarNames() | an array of set variable names or default names | String[ ] | |
setVarNames(names) | names - an array of variable names for each dimension (String[ ]) | void | |
writeOutput(fileName) | fileName - name of the file to which the chain will be saved (String). | void | |
writeOutput(fileName, append) | fileName - name of the file to which the chain will be saved (String). append - specify whether to append the chain at the end of the file (boolean) | void | |
read(fileName) | fileName - the name of the file from which the chain will be read (String) | void |
Table 9.3. The MarkovChain static methods
Method name and syntax | Description of parameters | Output | Output type |
---|---|---|---|
getSum(chains) | chains - an array of Markov chains (MarkovChain[ ]) | the algebraic sum of all elements in all chains: | double[ ] |
getSumSquare(chains) | chains - an array of Markov chains (MarkovChain[ ]) | the algebraic sum of the squares of all elements in all chains: | double[ ] |
getAverage(chains) | chains - an array of Markov chains (MarkovChain[ ]) | the average from all chains: | double[ ] |
getSSE(chains) | chains - an array of Markov chains (MarkovChain[ ]) | the sum of squared errors calcukated for all elements from all chains: | double[ ] |
getStandardDeviation(chains) | chains - an array of Markov chains (MarkovChain[ ]) | the standard deviation calculated for all chains: | double[ ] |
getVariance(chains) | chains - an array of Markov chains (MarkovChain[ ]) | the variance calculated for all chains: | double[ ] |
getCovarianceMatrix(chains) | chains - an array of Markov chains (MarkovChain[ ]) | the covariance calculated for all chains: | double[ ][ ] |
getCentralMoment(chains, rank) | chains - an array of Markov chains (MarkovChain[ ]) rank - the rank of the central moment (integer) | the central moment with the given rank calculated for all chains | double[ ] |
getQuantile(chains, rank) | chains - an array of Markov chains (MarkovChain[ ]) rank - the rank of the quantile (double) | the given quantile calculated for all chains | double[ ] |
getSSB(chains) | chains - an array of Markov chains (MarkovChain[ ]) | the sum of squares between all chains: | double[ ] |
getBetween(chains) | chains - an array of Markov chains (MarkovChain[ ]) | the variance between chains: | double[ ][ ] |
getSSW(chains) | chains - an array of Markov chains (MarkovChain[ ]) | the sum of squares within all chains: | double[ ] |
getWithin(chains) | chains - an array of Markov chains (MarkovChain[ ]) | the variance within all chains " | double[ ][ ] |
getPosteriorVariance(chains) | chains - an array of Markov chains (MarkovChain[ ]) | the posterior variance from all chains: | double[ ][ ] |
getMode(chains) | chains - an array of Markov chains (MarkovChain[ ]) | the mode of the density estimated from all chains | double[ ] |
getMuliR(chains) | chains - an array of Markov chains (MarkovChain[ ]) | the multirate of convergence (more information) | double |
getR(chains) | chains - an array of Markov chains (MarkovChain[ ]) | the rate of convergence (more information) | double[ ] |
getUnivariateMarkovChain(chains, pos) | chains - an array of Markov chains (MarkovChain[ ]) pos - index of the dimension (integer) | the Markov chain obtained by restricting all the chains to the specified dimension | MarkovChain |
getDimension(chains) | chains - an array of Markov chains (MarkovChain[ ]) | the dimension of elements in the chains | integer |
getLength(chains) | chains - an array of Markov chains (MarkovChain[ ]) | the sum of lengths of all the chains | int |
getMaxLength(chains) | chains - an array of Markov chains (MarkovChain[ ]) | the length of the longest chain | integer |
getVarNames(chains) | chains - an array of Markov chains (MarkovChain[ ]) | an array of set variable names or default names | String[ ] |
setVarNames(chains, names) | chains - an array of Markov chains (MarkovChain[ ]) names - an array for names of variables for each dimension (String[ ]) | void |
Expanded description of selected static MarkovChain methods