Learn R Programming

NPP (version 0.6.0)

LMNPP_MCMC: MCMC Sampling for Normal Linear Model using Normalized Power Prior

Description

Conduct posterior sampling for normal linear model with normalized power prior. For the power parameter \(\delta\), a Metropolis-Hastings algorithm with either independence proposal, or a random walk proposal on its logit scale is used. For the regression parameter \(\beta\) and \(\sigma^2\), Gibbs sampling is used.

Usage

LMNPP_MCMC(y.Cur, y.Hist, x.Cur = NULL, x.Hist = NULL,
           prior = list(a = 1.5, b = 0, mu0 = 0,
                   Rinv = matrix(1, nrow = 1), delta.alpha = 1, delta.beta = 1),
           MCMCmethod = 'IND', rw.logit.delta = 0.1,
           ind.delta.alpha= 1, ind.delta.beta= 1, nsample = 5000,
           control.mcmc = list(delta.ini = NULL, burnin = 0, thin = 1))

Value

A list of class "NPP" with five elements:

beta

posterior of the model parameter \(\beta\) in vector or matrix form.

sigmasq

posterior of the model parameter \(\sigma^2\).

delta

posterior of the power parameter \(\delta\).

acceptance

the acceptance rate in MCMC sampling for \(\delta\) using Metropolis-Hastings algorithm.

DIC

the deviance information criteria for model diagnostics.

Arguments

y.Cur

a vector of individual level of the response y in current data.

y.Hist

a vector of individual level of the response y in historical data.

x.Cur

a vector or matrix or data frame of covariate observed in the current data. If more than 1 covariate available, the number of rows is equal to the number of observations.

x.Hist

a vector or matrix or data frame of covariate observed in the historical data. If more than 1 covariate available, the number of rows is equal to the number of observations.

prior

a list of the hyperparameters in the prior for model parameters \((\beta, \sigma^2)\) and \(\delta\). The form of the prior for model parameter \((\beta, \sigma^2)\) is in the section "Details".

a a positive hyperparameter for prior on model parameters. It is the power \(a\) in formula \((1/\sigma^2)^a\); See details.

b equals 0 if a flat prior is used for \(\beta\). Equals 1 if a normal prior is used for \(\beta\); See details.

mu0 a vector of the mean for prior \(\beta|\sigma^2\). Only applicable if b = 1.

Rinv inverse of the matrix \(R\). The covariance matrix of the prior for \(\beta|\sigma^2\) is \(\sigma^2 R^{-1}\).

delta.alpha is the hyperparameter \(\alpha\) in the prior distribution \(Beta(\alpha, \beta)\) for \(\delta\).

delta.beta is the hyperparameter \(\beta\) in the prior distribution \(Beta(\alpha, \beta)\) for \(\delta\).

MCMCmethod

sampling method for \(\delta\) in MCMC. It can be either 'IND' for independence proposal; or 'RW' for random walk proposal on logit scale.

rw.logit.delta

the stepsize(variance of the normal distribution) for the random walk proposal of logit \(\delta\). Only applicable if MCMCmethod = 'RW'.

ind.delta.alpha

specifies the first parameter \(\alpha\) when independent proposal \(Beta(\alpha, \beta)\) for \(\delta\) is used. Only applicable if MCMCmethod = 'IND'

ind.delta.beta

specifies the first parameter \(\beta\) when independent proposal \(Beta(\alpha, \beta)\) for \(\delta\) is used. Only applicable if MCMCmethod = 'IND'

nsample

specifies the number of posterior samples in the output.

control.mcmc

a list of three elements used in posterior sampling.

delta.ini is the initial value of \(\delta\) in MCMC sampling.

burnin is the number of burn-ins. The output will only show MCMC samples after bunrin.

thin is the thinning parameter in MCMC sampling.

Author

Zifei Han hanzifei1@gmail.com

Details

If \(b = 1\), prior for \((\beta, \sigma)\) is \((1/\sigma^2)^a * N(mu0, \sigma^2 R^{-1})\), which includes the g-prior. If \(b = 0\), prior for \((\beta, \sigma)\) is \((1/\sigma^2)^a\). The outputs include posteriors of the model parameter(s) and power parameter, acceptance rate when sampling \(\delta\), and the deviance information criteria.

References

Ibrahim, J.G., Chen, M.-H., Gwon, Y. and Chen, F. (2015). The Power Prior: Theory and Applications. Statistics in Medicine 34:3724-3749.

Duan, Y., Ye, K. and Smith, E.P. (2006). Evaluating Water Quality: Using Power Priors to Incorporate Historical Information. Environmetrics 17:95-106.

Berger, J.O. and Bernardo, J.M. (1992). On the development of reference priors. Bayesian Statistics 4: Proceedings of the Fourth Valencia International Meeting, Bernardo, J.M, Berger, J.O., Dawid, A.P. and Smith, A.F.M. eds., 35-60, Clarendon Press:Oxford.

Jeffreys, H. (1946). An Invariant Form for the Prior Probability in Estimation Problems. Proceedings of the Royal Statistical Society of London, Series A 186:453-461.

See Also

BerNPP_MCMC; MultinomialNPP_MCMC; PoissonNPP_MCMC; NormalNPP_MCMC

Examples

Run this code
set.seed(123)
x1 = runif(100, min = 0, max = 10)
x0 = runif(100, min = 0, max = 1)
y1 = 10+ 2*x1 + rnorm(100, mean = 0, sd = 1)
y0 = 10+ 1.5*x0 + rnorm(100, mean = 0, sd = 1)

RegPost = LMNPP_MCMC(y.Cur = y1, y.Hist = y0, x.Cur = x1, x.Hist = x0,
                     prior = list(a = 1.5, b = 0, mu0 = c(0, 0),
                                  Rinv = diag(100, nrow = 2),
                     delta.alpha = 1, delta.beta = 1), MCMCmethod = 'IND',
                     ind.delta.alpha= 1, ind.delta.beta= 1, nsample = 5000,
                     control.mcmc = list(delta.ini = NULL,
                                         burnin = 2000, thin = 2))

Run the code above in your browser using DataLab