combineChains: Combine selected chains

View source: R/GcClusterFunctions.R

combineChainsR Documentation

Combine selected chains

Description

Combine and arrange selected, individual chains to create a set of chains.

Usage

combineChains(samplePars, selectedChains, procDir = ".")

Arguments

samplePars

List containing, among other things, the names of the files in which the stanfit objects are stored. These objects contain the samples of the posterior pdf. This list is return by function sampleFmm, for which the documentation includes a complete description of container samplePars.

selectedChains

Dataframe listing the indices of the chains that are combined. (See Details).

procDir

Directory containing the files with the stanfit objects.

Details

Argument selectedChains is a dataframe with two columns. The first column, for which the heading is "Chain," comprises the indices of the chains that will be combined. The second column, for which the heading is "isSwitched", comprises logical values (that is, TRUE or FALSE), which indicate whether the variables in the associated chain are switched.

To understand selectedChains consider two examples. (1) Assume that row 1 of selectedChains comprises the values 2 and FALSE. These values indicate that chain 2 will be included in the combination and that the variables in the finite mixture model are not switched. That is, variable mu1 in the chain is assigned to mu1, variable mu2 in the chain is assigned to mu2, and so on. (2) Assume that row 2 of selectedChains comprises the values 4 and TRUE. These values indicate that chain 4 will be included in the combination and that the variables in the finite mixture model are switched. That is, variable mu1 in the chain is assigned to mu2, variable mu2 in the chain is assigned to mu1, and so on.

Value

The returned value is a stanfit object, which is described in the rstan documentation. This object comprises the multiple chains, which have samples of the following model parameters:

Parameter Description
theta Proportion of population associated with pdf 1.
mu1 Mean vector for pdf 1.
mu2 Mean vector for pdf 2.
tau1 Standard deviation vector for pdf 1.
tau2 Standard deviation vector for pdf 2.
L_Omega1 Cholesky decomposition of the correlation matrix for pdf 1.
L_Omega2 Cholesky decomposition of the correlation matrix for pdf 2.
log_lik The logarithm of the likelihood function.

References

Stan Development Team, 2015, Stan Modeling Language - Users Guide and Reference Manual, Version 2.6.0, available on line at http://mc-stan.org/ (last accessed October 2015).

Examples

## Not run: 
combinedChains <- combineChains(samplePars, selectedChains)

## End(Not run)


USGS-R/GcClust documentation built on April 17, 2023, 8:08 p.m.