mixSource: Water Source as a Mixture

Description Usage Arguments Details Value Examples

View source: R/watercomp.R

Description

Given isotopic compositions of two or more potential sources, generate a posterior sample of source mixtures conditioned on one or more sample values.

Usage

1
2
mixSource(obs, sources, slope, prior = rep(1,nrow(sources)), shp = 1, 
            ngens = 1e5, ncores = 1)

Arguments

obs

iso object containing isotope values for one or more samples.

sources

iso object containing isotope values for two or more sources which may have contributed to the observed samples.

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).

ngens

integer. Number of posterior samples to obtain (per chain).

ncores

integer. Number of cores to use for parallel processing.

Details

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.

Value

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.

mixture_d2H

Hydrogen isotopic composition of unevaporated source mixture.

mixture_d18O

Oxygen isotopic composition of unevaporated source mixture.

sX_fraction

Fractional contribution of each source.

S

Evaporation line slope.

E

Evaporation index, equal to the difference between the sample and unevaporated source mixture oxygen isotope values.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
#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)

isoWater documentation built on July 21, 2021, 1:06 a.m.