mixSource | R Documentation |
Given isotopic compositions of two or more potential sources, generate a posterior sample of source mixtures conditioned on one or more sample values.
mixSource(obs, sources, slope, prior=rep(1,nrow(sources)),
shp = 1, edist = "unif", eprior = NULL, ngens = 1e5, ncores = 1)
obs |
|
sources |
|
slope |
numeric. Vector of length two specifying prior parameters for the evaporation line slope (mean, standard deviation). |
prior |
numeric. Vector of length equal to the number of sources, giving prior estimates of relative contributions of different sources. |
shp |
numeric. Shape parameter constant used in specifying prior estimates of source contributions (see Details). |
edist |
character. One of |
eprior |
numeric. Vector of length 2 giving prior parameter estimates for the oxygen isotope evaporation effect. For |
ngens |
integer. Number of posterior samples to obtain (per chain). |
ncores |
integer. Number of cores to use for parallel processing. |
The Dirichlet distribution is used to represent the fractional contribution of each source. The prior estimate is a Dirchlet where the shape parameter for source i
is given by prior[i] / min(prior) * shp
.
If ncores
= 1, three chains will be run on a single core. If ncores
> 1, ncores
chains will be run in parallel on ncores
cores.
Returns an object of class “mixSource”, a list containing:
summary |
matrix. Summary table of JAGS MCMC results, including parameter posterior distributions and convergence statistics. |
results |
data.frame. Posterior samples of model parameters.
|
#Prep sources
O = runif(3, -15, -2)
H = O * 8 + 10 + rnorm(3, 0, 6)
sources = iso(H, O, 1, 0.2, 0.17)
#Sample data
obs = iso(-60, -6, 0.5, 0.1, 0)
#Evaporation slope
slope = c(5, 0.3)
#Run and report...likely not converged!
ws = mixSource(obs, sources, slope, ngens = 1e3)
ws$summary
#A traceplot
plot(ws$results$mixture_d18O[1:1000], type = "l")
lines(ws$results$mixture_d18O[1001:2000], col = 2)
lines(ws$results$mixture_d18O[2001:3000], col = 3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.