Skip to content

Commit

Permalink
Update mixSource add eprior
Browse files Browse the repository at this point in the history
  • Loading branch information
bumbanian committed Aug 4, 2023
1 parent 14b0b7f commit cec414d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CRAN-SUBMISSION
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Version: 1.1.2
Date: 2023-08-04 16:49:40 UTC
SHA: 14b0b7fe83101169593c0a08727218e727b39e5d
Binary file modified R/sysdata.rda
Binary file not shown.
8 changes: 4 additions & 4 deletions R/watercomp.R
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ mwlSource = function(obs, MWL = NULL, slope, stype = 1, ngens=1e4, ncores = 1){

#takes values of observed and hypothesized endmember source waters (each type 'iso'),hypothesized EL slope,
#prior (as relative contribution of each source to mixture), and number of parameter draws
mixSource = function(obs, sources, slope, prior=rep(1,nrow(sources)),
shp=1, ngens=1e5, ncores = 1){
mixSource = function(obs, sources, slope, mixprior=rep(1,nrow(sources)),
shp=1, eprior = c(0, 15), ngens=1e5, ncores = 1){

if(!inherits(obs, "iso")){
warning("Expecting iso object for obs, this argument may be
Expand Down Expand Up @@ -143,13 +143,13 @@ mixSource = function(obs, sources, slope, prior=rep(1,nrow(sources)),
}

#dirchlet priors
alphas = prior/min(prior) * shp
alphas = mixprior/min(mixprior) * shp

#data
d = list(nsource = nsource, ndat = ndat,
obs = obs, obs.vcov = obs.vcov,
sources = sources, sources.vcov = sources.vcov,
alphas = alphas, slope = slope)
alphas = alphas, eprior = eprior, slope = slope)

#parameters
p = c("mixture_d2H", "mixture_d18O", "fracs", "S", "E")
Expand Down
2 changes: 1 addition & 1 deletion data-raw/prepData.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ mixModel = "model{
o_pred = mixture_d18O + E
#evap prior
E ~ dunif(0, 15)
E ~ dunif(eprior[1], eprior[2])
#EL slope prior
S ~ dnorm(slope[1], 1 / slope[2] ^ 2)
Expand Down
9 changes: 6 additions & 3 deletions man/mixSource.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ Given isotopic compositions of two or more potential sources, generate a posteri
}

\usage{
mixSource(obs, sources, slope, prior = rep(1,nrow(sources)), shp = 1,
ngens = 1e5, ncores = 1)
mixSource(obs, sources, slope, mixprior = rep(1,nrow(sources)), shp = 1,
eprior = c(0, 15), ngens = 1e5, ncores = 1)
}

\arguments{
Expand All @@ -25,12 +25,15 @@ mixSource(obs, sources, slope, prior = rep(1,nrow(sources)), shp = 1,
\item{slope}{
numeric. Vector of length two specifying prior parameters for the evaporation line slope (mean, standard deviation).
}
\item{prior}{
\item{mixprior}{
numeric. Vector of length equal to the number of sources, giving prior estimates of relative contributions of different sources.
}
\item{shp}{
numeric. Shape parameter constant used in specifying prior estimates of source contributions (see Details).
}
\item{eprior}{
numeric. Vector of length 2 giving prior estimates of maximum and minimum oxygen isotope evaporation effect.
}
\item{ngens}{
integer. Number of posterior samples to obtain (per chain).
}
Expand Down

0 comments on commit cec414d

Please sign in to comment.