B2ZM_MCMC: Bayesian Two-Zone Models: using Gibbs with Metropolis step

Description Usage Arguments Details Value Note Author(s) References See Also Examples

Description

B2ZM_MCMC obtains random samples from the posterior distribution of parameters and exposure concentrations for the Bayesian two-zone model proposed by Zhang et al. (2009) using Gibbs with Metropolis step. The user can choose whether the near and far field measurement error processes are dependent or not. In the independent model, 5 parameters are considered: 1) Beta: Interzonal air flow rate (m3); 2) Q: supply and exhaust flow rate (m3/min); 3) G: contaminant emission rate (mg/min); 4) Tau_N: variance of the measurement error at the near field; 5)Tau_F; variance of the measurement error at the far field. In the dependent model (default), one more parameter is considered: 6) Tau_NF: covariance between the measurements at the near and far field. Any prior distribution for Beta, Q and G can be chosen. In the independent model, the prior distributions for Tau_N and Tau_F are inverse gamma distributions; in the dependent model, the prior joint distribution of Tau_N, Tau_NF and Tau_F is the Inverse Wishart Distribution (see the Details section for more information on the parameterization of these distributions). The output from B2ZM_MCMC is a list that belongs to the classe gibbs. This output is valid as an input for the functions summary and plot.

Usage

1
2
3
4
5
6
7
B2ZM_MCMC (data, priorBeta, priorQ, priorG, v, S, 
                      tauN.sh, tauN.sc, tauF.sh, tauF.sc,  
                      VN, VF, indep.model = FALSE, cred = 95,  
                      NUpd = 10000, burnin = 1000, lag = 1, 
                      initial = NULL, Sigma.Cand = NULL, 
                      m = 6000, figures = list(save = FALSE, 
                      type =c("ps", "eps","pdf", "png", "jpg"))) 

Arguments

data

A 3-column matrix where the columns are time, concentrations at the near field, and concentrations at the far field, respectively. The time must be scaled in minutes (min), and the concentrations must be scaled in miligrams per cubic meter (mg/m3)

priorBeta

A string defining the prior distribution for the parameter Beta. To declare the prior distribution of Beta, use standard R nomenclature for probability distributions. For example, if the prior of Beta is a Uniform(0,20), declare it with "unif(0,20)"; if it is a Normal(0,1), declare it with "norm(0,1)". DO NOT put an "d" or "r" in front the name of the distributions. The options are: "unif(a,b)", "gamma(a,b)", "exp(a)", "norm(a,b)", "t(a)", "weibull(a,b)", "f(a,b)", "chisq(a,b)", "cauchy(a,b)" and "lnorm(a,b)".

priorQ

A string defining the prior distribution for Q (use the nomenclature as for priorBeta).

priorG

A string defining the prior distribution for G (use the nomenclature as for priorBeta).

v

Degrees of freedom for the Inverse Wishart distribution (prior joint distribution for Tau_N, Tau_NF and Tau_F in the dependent model).

S

A 2x2 positive definite matrix for the Inverse Wishart (prior joint distribution for Tau_N, Tau_NF and Tau_F in the dependent model).

tauN.sh

The shape parameter in the inverse gamma distribution (prior distribution for Tau_N in the independent model).

tauN.sc

The scalar parameter in the inverse gamma distribution (prior distribution for Tau_N in the independent model).

tauF.sh

The shape parameter in the inverse gamma distribution (prior distribution for Tau_F in the independent model).

tauF.sc

The scalar parameter in the inverse gamma distribution (prior distribution for Tau_F in the independent model).

VN

Volume of the near field in cubic meters (m3).

VF

Volume of the far field in cubic meters (m3).

indep.model

A logical value indicating whether the independent model should be considered. The default is FALSE.

cred

A scalar between 0 and 100 indicating the credibility level for the posterior intervals of the parameters.

NUpd

Number of updates. The default is 10,000.

burnin

Period of burn-in. The default is 1,000.

lag

Thin interval. The default is 1.

initial

A vector containing the initial values for the parameters: Beta, Q and G (exactly in this order).

Sigma.Cand

A 3x3 covariance matrix for the normal multivariate proposal distribution of Beta, Q and G. The default is NULL, and in this case, the covariance matrix used is the negative inverse of the hessian matrix of the log posterior distribution at the estimated posterior mode.

m

Number of sampling values from the prior distribution used to estimate a good starting value that is used in the estimation of Sigma.Cand. It is used only if Sigma.Cand is not declared. See the Details section for more information.

figures

The command plot(obj) produces several plots, where obj is the output from B2ZM_MCMC. Using figures, those plots are built internally and saved as eps, pdf, ps, png or jpg format. figures is a list containing the following parameters:

save:

a logical value indicating that the figures are to be saved. The default is FALSE.

type:

a string that indicates the image file type. The default is "ps".

Details

Parameterization priors: The inverse gamma distribution with shape a and scale b has mean b/(a-1) (a>1) and variance (b^2)/((a-1)^2(a-2)) (a>2). The inverse Wishart with v degrees of freedom and scalar matrix S has mean S/(v-p-1), where p is the number of rows of S.

Covariance Matrix for the proposal distribution: If the covariance matrix for the multivariate normal poposal distribution is NULL for the Metropolis sampler the covariance matrix used is the negative inverse of the hessian matrix of the log posterior distribution at the estimated posterior mode. To estimate the posterior mode, the function nlm is used. The values of the estimated posterior mode depends on the starting parameter values. m is the number of sampling values from the prior distributions of Beta, Q and G. The vector (among the m sampled) with largest likelihood value is used as starting parameter values.

The covariance matrix is estimated using the function hessian from the package numDeriv, where the parameter vector is the estimated posterior mode.

Value

B2ZM_MCMC returns a list that belongs to the class gibbs. The output from B2ZM contains the objects:

Beta

a vector containing the sampled values from the joint posterior distribution for the parameter Beta.

Q

a vector containing the sampled values from the joint posterior distribution for the parameter Q.

G

a vector containing the sampled values from the joint posterior distribution for the parameter G.

tauN

a vector containing the sampled values from the joint posterior distribution for the parameter Tau_N.

tauF

a vector containing the sampled values from the joint posterior distribution for the parameter Tau_F.

tauNF

a vector containing the sampled values from the joint posterior distribution for the parameter Tau_NF (if the dependent model is used).

Y

a matrix containing the log of the observed concentrations.

DIC

deviance information criterion.

pD

effective number of parameters.

Dbar

Deviance expectation.

ESS

effective sample size.

indep

a logical value indicating whether the independent model was used.

times

a vector containing the times when the observed concentrations were measured.

cred

credibility of the posterior intervals.

AR

acceptance rate in the metropolis step.

Sigma.Cand

covariance matrix used in the proposal distribution.

initial

a vector containing the initial points.

NUpd

number of updates.

burnin

burn-in period.

lag

thin interval.

Methods defined for B2ZM_MCMC object are summary and plot.

Note

In the Examples section, NUpd and m are small just for a quick demonstration. We suggest that NUpd be greater than 10,000 and m be around 4,000.

Author(s)

Joao Vitor Dias Monteiro, Sudipto Banerjee and Gurumurthy Ramachandran.

References

Monteiro, J. V. D., Banerjee, S. and Ramachandran, G. (2011). B2Z: An R Package for Bayesian Two-Zone Models. Journal of Statistical Software 43 (2) 1–23. http://www.jstatsoft.org/v43/i02/

Zhang, Y., Banerjee, S., Yang,R., Lungu,C. and Ramachandran, G. (2009). Bayesian Modeling of Exposure and Airflow Using Two-Zone Models. The Annals of Occupational Hygiene, 53, 409-424. http://www.biostat.umn.edu/~sudiptob/ResearchPapers/ZBYLR.pdf

See Also

B2Z, B2ZM, B2ZM_BCLT,B2ZM_IMIS,B2ZM_SIR

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
##################
#Dependent Model#
################

#Data 1:  100 simulated concentrations during the times
#between 0 and 4, using the parameters Beta = 5, Q = 13.8,
#G = 351.5, VN = pi*10^-3, VF = 3.8, Tau_N = 1, 
#Tau_NF = 0.5 and Tau_F = 0.64. 

data(ex1)
#Without specifying the initial values and 
#the covariance matrix in the proposal distribution

## Not run: 
r <- B2ZM_MCMC(data = ex1, priorBeta = "unif(0,10)",   
     priorQ="unif(11,17)", priorG = "unif(281,482)", S = diag(10,2), 
     v = 4, VN = pi*10^-3, VF = 3.8, NUpd = 10000, burnin = 1000, 
     lag = 1, m = 5000)

summary(r)
plot(r)

## End(Not run)

#Specifying the initial values and the covariance matrix in the proposal distribution
initial <- c(5.338671,  14.147149, 379.591927)

Sigma.Cand <- matrix(c(0.51306,  0.54981,   14.4306,
                       0.54981,  1.75525,   35.5525,
                       14.4306,  35.5525, 1360.5119),3,3)

r <- B2ZM_MCMC(data = ex1, priorBeta = "unif(0,10)", 
     priorQ = "unif(11,17)", priorG = "unif(281,482)", S = diag(10,2), 
     v = 4, VN = pi*10^-3, VF = 3.8, NUpd = 1000, burnin = 100, 
     lag = 1, m = 5000, initial = initial, Sigma.Cand = Sigma.Cand)

summary(r)
plot(r)

## Not run: 
#Saving figures with .jpg extension
r <- B2ZM_MCMC(data = ex1, priorBeta = "unif(0,10)", 
     priorQ = "unif(11,17)", priorG = "unif(281,482)", S = diag(10,2), 
     v = 4, VN = pi*10^-3, VF = 3.8, NUpd = 10000, burnin = 1000, 
     lag = 1, m = 5000, figures = list(save = TRUE, type ="jpg") )

## End(Not run)


#####################
#Independent Model #
###################

#Data 2:  100 simulated concentrations during the times
#between 0 and 4, using the parameters Beta = 5, Q = 13.8,
#G = 351.5, VN = pi*10^-3, VF = 3.8, Tau_N = 1, 
#Tau_NF = 0 and Tau_F = 0.64. 

## Not run: 
data(ex2)

#Without specifying the initial values and the 
#covariance matrix in the proposal distribution

r <- B2ZM_MCMC(data = ex2, indep.model = TRUE, 
     priorBeta = "unif(0,10)", priorQ="unif(11,17)", 
     priorG = "unif(281,482)", tauN.sh = 5 , tauN.sc = 4 , 
     tauF.sh = 5, tauF.sc = 7 , VN = pi*10^-3, VF = 3.8,
     NUpd = 10000, burnin = 1000, lag = 1, m = 1000)

summary(r)
plot(r)

## End(Not run)

B2Z documentation built on May 2, 2019, 6:33 a.m.