Learn R Programming

Bclim (version 2.2)

BclimMixPar: Parallel version of Bclim mixture analysis

Description

Function to approximate marginal data posteriors as mixtures of Gaussians

Usage

BclimMixPar(MDP, G = 10, num.cores = 4, mixwarnings = FALSE)

Arguments

MDP
A set of marginal data posteriors, as produced by BclimLayer
G
The number of Gaussian groups required for each layer to be partitioned into. The default of 10 is usually fine.
num.cores
The number of cores to use in the parallel running of this function
mixwarnings
Whether to suppress mixture warnings (default) or not.

Value

  • Outputs a list containing the following objects:
  • MDPA nsamples x n x m array (these values are described below)
  • nThe number of layers
  • mThe number of climate dimensions (always 3)
  • n.sampThe number of samples given in BclimLayer
  • ScMeanThe raw climate means (used for standardisation purposes)
  • ScVarThe raw climate variances (used for standardisation purposes)
  • GThe number of mixture groups (as above)
  • mu.matAn estimate of the Gaussian mixture mean components
  • tau.matAn estimate of the Gaussian mixture precision components
  • p.matAn estimate of the Gaussian mixture proportions

Details

This function approximates marginal data posteriors (MDPs) as mixtures of Gaussians. The mixture algorithm is taken from the Mclust package which is a required installation for this to run. This is the parallel version, i.e. it uses more than one processor, as opposed to the BclimMixSer serial version which will by slower but will run on more machines. For the BclimMixPar function to run, you need to have the R packages doMC and foreach installed. Note that this function does not always report output as it runs, depending on the GUI of the system you are on.

References

See Arxiv paper at http://arxiv.org/abs/1206.5009.

See Also

The output here can be used as an input to BclimMCMC. See the main BclimRun function for more details of the other stages you might need to run.

Examples

Run this code
# Set the working directory using setwd (not shown)

# Download and load in the response surfaces:
url1 <- 'http://mathsci.ucd.ie/~parnell_a/required.data3D.RData'
download.file(url1,'required_data3D.RData')

# and now the pollen
url2 <- 'http://mathsci.ucd.ie/~parnell_a/SlugganPollen.txt'
download.file(url2,'SlugganPollen.txt')

# and finally the chronologies
url3 <- 'http://mathsci.ucd.ie/~parnell_a/Sluggan_2chrons.txt'
download.file(url3,'Slugganchrons.txt')

# Create variables which state the locations of the pollen and chronologies
pollen.loc <- paste(getwd(),'/SlugganPollen.txt',sep='')
chron.loc <- paste(getwd(),'/Slugganchrons.txt',sep='')

# Load in the response surfaces
load('required.data3D.RData')

## note that all of these functions have further options you can change with
step1 <- BclimLayer(pollen.loc,required.data3D=required.data3D)
step2 <- BclimMixPar(step1) # See also the serial version BclimMixSer if you cannot install doMC and foreach
step3 <- BclimMCMC(step2,chron.loc) # You should probably do some convergence checking after this step
step4 <- BclimInterp(step2,step3) 
results <- BclimCompile(step1,step2,step3,step4,core.name="Sluggan Moss")

# Create a plot of MTCO (dim=2)
plotBclim(results,dim=2)

# Create a volatility plot
plotBclimVol(results,dim=2)

Run the code above in your browser using DataLab