Title: | Normalized Power Prior Bayesian Analysis |
---|---|
Description: | Posterior sampling in several commonly used distributions using normalized power prior as described in Duan, Ye and Smith (2006) <doi:10.1002/env.752> and Ibrahim et.al. (2015) <doi:10.1002/sim.6728>. Sampling of the power parameter is achieved via either independence Metropolis-Hastings or random walk Metropolis-Hastings based on transformation. |
Authors: | Zifei Han, Qiang Zhang, Tianyu Bai Yuyan Duan and Keying Ye |
Maintainer: | Zifei Han <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.6.0 |
Built: | 2024-11-07 02:39:48 UTC |
Source: | https://github.com/cran/NPP |
Incorporate multiple historical data sets for posterior sampling of a Bernoulli population using the normalized power prior. The Metropolis-Hastings algorithm, with either an independence proposal or a random walk proposal on the logit scale, is applied for the power parameter . Gibbs sampling is utilized for the model parameter
.
BerMNPP_MCMC1(n0, y0, n, y, prior_p, prior_delta_alpha, prior_delta_beta, prop_delta_alpha, prop_delta_beta, delta_ini, prop_delta, rw_delta, nsample, burnin, thin)
BerMNPP_MCMC1(n0, y0, n, y, prior_p, prior_delta_alpha, prior_delta_beta, prop_delta_alpha, prop_delta_beta, delta_ini, prop_delta, rw_delta, nsample, burnin, thin)
n0 |
A non-negative integer vector representing the number of trials in historical data. |
y0 |
A non-negative integer vector denoting the number of successes in historical data. |
n |
A non-negative integer indicating the number of trials in the current data. |
y |
A non-negative integer for the number of successes in the current data. |
prior_p |
a vector of the hyperparameters in the prior distribution |
prior_delta_alpha |
a vector of the hyperparameter |
prior_delta_beta |
a vector of the hyperparameter |
prop_delta_alpha |
a vector of the hyperparameter |
prop_delta_beta |
a vector of the hyperparameter |
delta_ini |
the initial value of |
prop_delta |
the class of proposal distribution for |
rw_delta |
the stepsize(variance of the normal distribution) for the random walk proposal of logit |
nsample |
specifies the number of posterior samples in the output. |
burnin |
the number of burn-ins. The output will only show MCMC samples after bunrin. |
thin |
the thinning parameter in MCMC sampling. |
The outputs include posteriors of the model parameter(s) and power parameter, acceptance rate in sampling .
The normalized power prior distribution is
Here and
are the initial prior distributions of
and
, respectively.
is the likelihood function of historical data
, and
is the corresponding power parameter.
A list of class "NPP" comprising:
acceptrate |
Acceptance rate in MCMC sampling for |
p |
Posterior distribution of the model parameter |
delta |
Posterior distribution of the power parameter |
Qiang Zhang [email protected]
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.
BerMNPP_MCMC2
;
BerOMNPP_MCMC1
;
BerOMNPP_MCMC2
BerMNPP_MCMC1(n0 = c(275, 287), y0 = c(92, 125), n = 39, y = 17, prior_p = c(1/2,1/2), prior_delta_alpha = c(1/2,1/2), prior_delta_beta = c(1/2,1/2), prop_delta_alpha = c(1,1)/2, prop_delta_beta = c(1,1)/2, delta_ini = NULL, prop_delta = "IND", nsample = 2000, burnin = 500, thin = 2)
BerMNPP_MCMC1(n0 = c(275, 287), y0 = c(92, 125), n = 39, y = 17, prior_p = c(1/2,1/2), prior_delta_alpha = c(1/2,1/2), prior_delta_beta = c(1/2,1/2), prop_delta_alpha = c(1,1)/2, prop_delta_beta = c(1,1)/2, delta_ini = NULL, prop_delta = "IND", nsample = 2000, burnin = 500, thin = 2)
Multiple historical data are combined individually.
The NPP of multiple historical data is the product of the NPP of each historical data.
Conduct posterior sampling for Bernoulli population with normalized power prior.
For the power parameter , a Metropolis-Hastings algorithm with either independence proposal, or a random walk proposal on its logit scale is used.
For the model parameter
, Gibbs sampling is used.
BerMNPP_MCMC2(n0, y0, n, y, prior_p, prior_delta_alpha, prior_delta_beta, prop_delta_alpha, prop_delta_beta, delta_ini, prop_delta, rw_delta, nsample, burnin, thin)
BerMNPP_MCMC2(n0, y0, n, y, prior_p, prior_delta_alpha, prior_delta_beta, prop_delta_alpha, prop_delta_beta, delta_ini, prop_delta, rw_delta, nsample, burnin, thin)
n0 |
a non-negative integer vector: number of trials in historical data. |
y0 |
a non-negative integer vector: number of successes in historical data. |
n |
a non-negative integer: number of trials in the current data. |
y |
a non-negative integer: number of successes in the current data. |
prior_p |
a vector of the hyperparameters in the prior distribution |
prior_delta_alpha |
a vector of the hyperparameter |
prior_delta_beta |
a vector of the hyperparameter |
prop_delta_alpha |
a vector of the hyperparameter |
prop_delta_beta |
a vector of the hyperparameter |
delta_ini |
the initial value of |
prop_delta |
the class of proposal distribution for |
rw_delta |
the stepsize (variance of the normal distribution) for the random walk proposal of logit |
nsample |
specifies the number of posterior samples in the output. |
burnin |
the number of burn-ins. The output will only show MCMC samples after burnin. |
thin |
the thinning parameter in MCMC sampling. |
The outputs include posteriors of the model parameter(s) and power parameter, acceptance rate in sampling .
The normalized power prior distribution is
Here and
are the initial prior distributions of
and
, respectively.
is the likelihood function of historical data
, and
is the corresponding power parameter.
A list of class "NPP" with three elements:
acceptrate |
the acceptance rate in MCMC sampling for |
p |
posterior of the model parameter |
delta |
posterior of the power parameter |
Qiang Zhang [email protected]
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.
BerMNPP_MCMC1
;
BerOMNPP_MCMC1
;
BerOMNPP_MCMC2
BerMNPP_MCMC2(n0 = c(275, 287), y0 = c(92, 125), n = 39, y = 17, prior_p=c(1/2,1/2), prior_delta_alpha=c(1/2,1/2), prior_delta_beta=c(1/2,1/2), prop_delta_alpha=c(1,1)/2, prop_delta_beta=c(1,1)/2, delta_ini=NULL, prop_delta="IND", nsample = 2000, burnin = 500, thin = 2)
BerMNPP_MCMC2(n0 = c(275, 287), y0 = c(92, 125), n = 39, y = 17, prior_p=c(1/2,1/2), prior_delta_alpha=c(1/2,1/2), prior_delta_beta=c(1/2,1/2), prop_delta_alpha=c(1,1)/2, prop_delta_beta=c(1,1)/2, delta_ini=NULL, prop_delta="IND", nsample = 2000, burnin = 500, thin = 2)
Conduct posterior sampling for Bernoulli population with normalized power prior.
For the power parameter , a Metropolis-Hastings algorithm with either
independence proposal, or a random walk proposal on its logit scale is used.
For the model parameter
, Gibbs sampling is used.
BerNPP_MCMC(Data.Cur = c(100, 50), Data.Hist = c(100, 50), CompStat = list(n0 = NULL, y0 = NULL, n1 = NULL, y1 = NULL), prior = list(p.alpha = 1, p.beta = 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))
BerNPP_MCMC(Data.Cur = c(100, 50), Data.Hist = c(100, 50), CompStat = list(n0 = NULL, y0 = NULL, n1 = NULL, y1 = NULL), prior = list(p.alpha = 1, p.beta = 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))
Data.Cur |
a non-negative integer vector of two elements: c(number of trials, number of successes) in the current data. |
Data.Hist |
a non-negative integer vector of two elements: c(number of trials, number of successes) in the historical data. |
CompStat |
a list of four elements that represents the
"compatibility(sufficient) statistics" for
|
prior |
a list of the hyperparameters in the prior for both
|
MCMCmethod |
sampling method for |
rw.logit.delta |
the stepsize(variance of the normal distribution) for the random walk proposal of logit |
ind.delta.alpha |
specifies the first parameter |
ind.delta.beta |
specifies the first parameter |
nsample |
specifies the number of posterior samples in the output. |
control.mcmc |
a list of three elements used in posterior sampling.
|
The outputs include posteriors of the model parameter(s) and power parameter, acceptance rate in sampling , and
the deviance information criteria.
A list of class "NPP" with four elements:
p |
posterior of the model parameter |
delta |
posterior of the power parameter |
acceptance |
the acceptance rate in MCMC sampling for |
DIC |
the deviance information criteria for model diagnostics. |
Zifei Han [email protected]
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.
MultinomialNPP_MCMC
;
NormalNPP_MCMC
;
PoissonNPP_MCMC
BerNPP_MCMC(Data.Cur = c(493, 473), Data.Hist = c(680, 669), prior = list(p.alpha = 0.5, p.beta = 0.5, delta.alpha = 1, delta.beta = 1), MCMCmethod = 'RW', rw.logit.delta = 1, nsample = 5000, control.mcmc = list(delta.ini = NULL, burnin = 2000, thin = 5))
BerNPP_MCMC(Data.Cur = c(493, 473), Data.Hist = c(680, 669), prior = list(p.alpha = 0.5, p.beta = 0.5, delta.alpha = 1, delta.beta = 1), MCMCmethod = 'RW', rw.logit.delta = 1, nsample = 5000, control.mcmc = list(delta.ini = NULL, burnin = 2000, thin = 5))
Multiple ordered historical data are incorporated together.
Conduct posterior sampling for Bernoulli population with normalized power prior.
For the power parameter , a Metropolis-Hastings algorithm with independence proposal is used.
For the model parameter
, Gibbs sampling is used.
BerOMNPP_MCMC1(n0, y0, n, y, prior_gamma, prior_p, gamma_ind_prop, gamma_ini, nsample, burnin, thin, adjust = FALSE)
BerOMNPP_MCMC1(n0, y0, n, y, prior_gamma, prior_p, gamma_ind_prop, gamma_ini, nsample, burnin, thin, adjust = FALSE)
n0 |
a non-negative integer vector: number of trials in historical data. |
y0 |
a non-negative integer vector: number of successes in historical data. |
n |
a non-negative integer: number of trials in the current data. |
y |
a non-negative integer: number of successes in the current data. |
prior_gamma |
a vector of the hyperparameters in the prior distribution |
prior_p |
a vector of the hyperparameters in the prior distribution |
gamma_ind_prop |
a vector of the hyperparameters in the proposal distribution |
gamma_ini |
the initial value of |
nsample |
specifies the number of posterior samples in the output. |
burnin |
the number of burn-ins. The output will only show MCMC samples after burnin. |
thin |
the thinning parameter in MCMC sampling. |
adjust |
Logical, indicating whether or not to adjust the parameters of the proposal distribution. |
The outputs include posteriors of the model parameter(s) and power parameter, acceptance rate in sampling .
The normalized power prior distribution is given by:
Here, and
are the initial prior distributions of
and
, respectively.
is the likelihood function of historical data
, and
is the corresponding power parameter.
A list of class "NPP" with three elements:
acceptrate |
the acceptance rate in MCMC sampling for |
p |
posterior of the model parameter |
delta |
posterior of the power parameter |
Qiang Zhang [email protected]
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.
BerMNPP_MCMC1
,
BerMNPP_MCMC2
,
BerOMNPP_MCMC2
BerOMNPP_MCMC1(n0 = c(275, 287), y0 = c(92, 125), n = 39, y = 17, prior_gamma=c(1,1,1)/3, prior_p=c(1/2,1/2), gamma_ind_prop=rep(1,3)/2, gamma_ini=NULL, nsample = 2000, burnin = 500, thin = 2, adjust = FALSE)
BerOMNPP_MCMC1(n0 = c(275, 287), y0 = c(92, 125), n = 39, y = 17, prior_gamma=c(1,1,1)/3, prior_p=c(1/2,1/2), gamma_ind_prop=rep(1,3)/2, gamma_ini=NULL, nsample = 2000, burnin = 500, thin = 2, adjust = FALSE)
Multiple ordered historical data are combined individually.
Conduct posterior sampling for Bernoulli population with normalized power prior.
For the power parameter , a Metropolis-Hastings algorithm with independence proposal is used.
For the model parameter
, Gibbs sampling is used.
BerOMNPP_MCMC2(n0, y0, n, y, prior_gamma, prior_p, gamma_ind_prop, gamma_ini, nsample, burnin, thin, adjust = FALSE)
BerOMNPP_MCMC2(n0, y0, n, y, prior_gamma, prior_p, gamma_ind_prop, gamma_ini, nsample, burnin, thin, adjust = FALSE)
n0 |
a vector of non-negative integers: numbers of trials in historical data. |
y0 |
a vector of non-negative integers: numbers of successes in historical data. |
n |
a non-negative integer: number of trials in the current data. |
y |
a non-negative integer: number of successes in the current data. |
prior_gamma |
a vector of the hyperparameters in the prior distribution |
prior_p |
a vector of the hyperparameters in the prior distribution |
gamma_ind_prop |
a vector of the hyperparameters in the proposal distribution |
gamma_ini |
the initial value of |
nsample |
specifies the number of posterior samples in the output. |
burnin |
the number of burn-ins. The output will only show MCMC samples after burn-in. |
thin |
the thinning parameter in MCMC sampling. |
adjust |
Whether or not to adjust the parameters of the proposal distribution. |
The outputs include posteriors of the model parameter(s) and power parameter, acceptance rate in sampling .
The normalized power prior distribution is
Here and
are the initial prior distributions of
and
, respectively.
is the likelihood function of historical data
, and
is the corresponding power parameter.
A list of class "NPP" with three elements:
acceptrate |
the acceptance rate in MCMC sampling for |
p |
posterior of the model parameter |
delta |
posterior of the power parameter |
Qiang Zhang [email protected]
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.
BerMNPP_MCMC1
;
BerMNPP_MCMC2
;
BerOMNPP_MCMC1
BerOMNPP_MCMC2(n0 = c(275, 287), y0 = c(92, 125), n = 39, y = 17, prior_gamma=c(1,1,1)/3, prior_p=c(1/2,1/2), gamma_ind_prop=rep(1,3)/2, gamma_ini=NULL, nsample = 2000, burnin = 500, thin = 2, adjust = FALSE)
BerOMNPP_MCMC2(n0 = c(275, 287), y0 = c(92, 125), n = 39, y = 17, prior_gamma=c(1,1,1)/3, prior_p=c(1/2,1/2), gamma_ind_prop=rep(1,3)/2, gamma_ini=NULL, nsample = 2000, burnin = 500, thin = 2, adjust = FALSE)
Based on Laplace Approximation
The function assumes that the prior of the model parameters is very flat that had very minor impact on the shape of the power prior (posterior based on the D0).
LaplacelogC(delta, loglikmle, detHessian, ntheta)
LaplacelogC(delta, loglikmle, detHessian, ntheta)
delta |
the power parameter between 0 and 1. The function returns |
loglikmle |
a scalar; the loglikelihood of the historical data evaluated at the maximum likelihood estimates based on the historical data |
detHessian |
determinant of the Hessian matrix evaluated at the loglikelihood function with respect to the maximum likelihood estimates based on the historical data |
ntheta |
an positive integer indicating number of parameters in the model |
based on the Laplace approximation. Can be used for the posterior sampling in the normalized power prior.
Zifei Han [email protected]
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.
Multiple historical data are incorporated together.
Conduct posterior sampling for Linear Regression Model with normalized power prior.
For the power parameter , a Metropolis-Hastings algorithm with either
independence proposal, or a random walk proposal on its logit scale is used.
For the model parameters
, Gibbs sampling is used.
LMMNPP_MCMC1(D0, X, Y, a0, b, mu0, R, delta_ini, prop_delta, prior_delta_alpha, prior_delta_beta, prop_delta_alpha, prop_delta_beta, rw_delta, nsample, burnin, thin)
LMMNPP_MCMC1(D0, X, Y, a0, b, mu0, R, delta_ini, prop_delta, prior_delta_alpha, prior_delta_beta, prop_delta_alpha, prop_delta_beta, rw_delta, nsample, burnin, thin)
D0 |
a list of |
X |
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. |
Y |
a vector of individual level of the response y in the current data. |
a0 |
a positive shape parameter for inverse-gamma prior on model parameter |
b |
a positive scale parameter for inverse-gamma prior on model parameter |
mu0 |
a vector of the mean for prior |
R |
a inverse matrix of the covariance matrix for prior |
delta_ini |
the initial value of |
prop_delta |
the class of proposal distribution for |
prior_delta_alpha |
a vector of the hyperparameter |
prior_delta_beta |
a vector of the hyperparameter |
prop_delta_alpha |
a vector of the hyperparameter |
prop_delta_beta |
a vector of the hyperparameter |
rw_delta |
the stepsize(variance of the normal distribution) for the random walk proposal of logit |
nsample |
specifies the number of posterior samples in the output. |
burnin |
the number of burn-ins. The output will only show MCMC samples after bunrin. |
thin |
the thinning parameter in MCMC sampling. |
The outputs include posteriors of the model parameters and power parameter,
acceptance rate in sampling .
Let
=
, the normalized power prior distribution is
Here and
are the initial prior distributions of
and
, respectively.
is the likelihood function of historical data
, and
is the corresponding power parameter.
A list of class "NPP" with four elements:
acceptrate |
the acceptance rate in MCMC sampling for |
beta |
posterior of the model parameter |
sigma |
posterior of the model parameter |
delta |
posterior of the power parameter |
Qiang Zhang [email protected]
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.
LMMNPP_MCMC2
;
LMOMNPP_MCMC1
;
LMOMNPP_MCMC2
## Not run: set.seed(1234) sigsq0 = 1 n01 = 100 theta01 = c(0, 1, 1) X01 = cbind(1, rnorm(n01, mean=0, sd=1), runif(n01, min=-1, max=1)) Y01 = X01%*%as.vector(theta01) + rnorm(n01, mean=0, sd=sqrt(sigsq0)) D01 = cbind(X01, Y01) n02 = 70 theta02 = c(0, 2, 3) X02 = cbind(1, rnorm(n02, mean=0, sd=1), runif(n02, min=-1, max=1)) Y02 = X02%*%as.vector(theta02) + rnorm(n02, mean=0, sd=sqrt(sigsq0)) D02 = cbind(X02, Y02) n03 = 50 theta03 = c(0, 3, 5) X03 = cbind(1, rnorm(n03, mean=0, sd=1), runif(n03, min=-1, max=1)) Y03 = X03%*%as.vector(theta03) + rnorm(n03, mean=0, sd=sqrt(sigsq0)) D03 = cbind(X03, Y03) D0 = list(D01, D02, D03) n0 = c(n01, n02, n03) n = 100 theta = c(0, 3, 5) X = cbind(1, rnorm(n, mean=0, sd=1), runif(n, min=-1, max=1)) Y = X%*%as.vector(theta) + rnorm(n, mean=0, sd=sqrt(sigsq0)) LMMNPP_MCMC1(D0=D0, X=X, Y=Y, a0=2, b=2, mu0=c(0,0,0), R=diag(c(1/64,1/64,1/64)), delta_ini=NULL, prior_delta_alpha=c(1,1,1), prior_delta_beta=c(1,1,1), prop_delta_alpha=c(1,1,1), prop_delta_beta=c(1,1,1), prop_delta="RW", rw_delta=0.9, nsample=5000, burnin=1000, thin=3) ## End(Not run)
## Not run: set.seed(1234) sigsq0 = 1 n01 = 100 theta01 = c(0, 1, 1) X01 = cbind(1, rnorm(n01, mean=0, sd=1), runif(n01, min=-1, max=1)) Y01 = X01%*%as.vector(theta01) + rnorm(n01, mean=0, sd=sqrt(sigsq0)) D01 = cbind(X01, Y01) n02 = 70 theta02 = c(0, 2, 3) X02 = cbind(1, rnorm(n02, mean=0, sd=1), runif(n02, min=-1, max=1)) Y02 = X02%*%as.vector(theta02) + rnorm(n02, mean=0, sd=sqrt(sigsq0)) D02 = cbind(X02, Y02) n03 = 50 theta03 = c(0, 3, 5) X03 = cbind(1, rnorm(n03, mean=0, sd=1), runif(n03, min=-1, max=1)) Y03 = X03%*%as.vector(theta03) + rnorm(n03, mean=0, sd=sqrt(sigsq0)) D03 = cbind(X03, Y03) D0 = list(D01, D02, D03) n0 = c(n01, n02, n03) n = 100 theta = c(0, 3, 5) X = cbind(1, rnorm(n, mean=0, sd=1), runif(n, min=-1, max=1)) Y = X%*%as.vector(theta) + rnorm(n, mean=0, sd=sqrt(sigsq0)) LMMNPP_MCMC1(D0=D0, X=X, Y=Y, a0=2, b=2, mu0=c(0,0,0), R=diag(c(1/64,1/64,1/64)), delta_ini=NULL, prior_delta_alpha=c(1,1,1), prior_delta_beta=c(1,1,1), prop_delta_alpha=c(1,1,1), prop_delta_beta=c(1,1,1), prop_delta="RW", rw_delta=0.9, nsample=5000, burnin=1000, thin=3) ## End(Not run)
Multiple historical data are combined individually.
The NPP of multiple historical data is the product of the NPP of each historical data.
Conduct posterior sampling for Linear Regression Model with normalized power prior.
For the power parameter , a Metropolis-Hastings algorithm with either
independence proposal, or a random walk proposal on its logit scale is used.
For the model parameters
, Gibbs sampling is used.
LMMNPP_MCMC2(D0, X, Y, a0, b, mu0, R, delta_ini, prop_delta, prior_delta_alpha, prior_delta_beta, prop_delta_alpha, prop_delta_beta, rw_delta, nsample, burnin, thin)
LMMNPP_MCMC2(D0, X, Y, a0, b, mu0, R, delta_ini, prop_delta, prior_delta_alpha, prior_delta_beta, prop_delta_alpha, prop_delta_beta, rw_delta, nsample, burnin, thin)
D0 |
a list of |
X |
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. |
Y |
a vector of individual level of the response y in the current data. |
a0 |
a positive shape parameter for inverse-gamma prior on model parameter |
b |
a positive scale parameter for inverse-gamma prior on model parameter |
mu0 |
a vector of the mean for prior |
R |
a inverse matrix of the covariance matrix for prior |
delta_ini |
the initial value of |
prop_delta |
the class of proposal distribution for |
prior_delta_alpha |
a vector of the hyperparameter |
prior_delta_beta |
a vector of the hyperparameter |
prop_delta_alpha |
a vector of the hyperparameter |
prop_delta_beta |
a vector of the hyperparameter |
rw_delta |
the stepsize(variance of the normal distribution) for the random walk proposal
of logit |
nsample |
specifies the number of posterior samples in the output. |
burnin |
the number of burn-ins. The output will only show MCMC samples after bunrin. |
thin |
the thinning parameter in MCMC sampling. |
The outputs include posteriors of the model parameters and power parameter,
acceptance rate in sampling .
Let
=
, the normalized power prior distribution is
Here and
are the initial prior distributions of
and
, respectively.
is the likelihood function of historical data
, and
is the corresponding power parameter.
A list of class "NPP" with four elements:
acceptrate |
the acceptance rate in MCMC sampling for |
beta |
posterior of the model parameter |
sigma |
posterior of the model parameter |
delta |
posterior of the power parameter |
Qiang Zhang [email protected]
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.
LMMNPP_MCMC1
;
LMOMNPP_MCMC1
;
LMOMNPP_MCMC2
## Not run: set.seed(1234) sigsq0 = 1 n01 = 100 theta01 = c(0, 1, 1) X01 = cbind(1, rnorm(n01, mean=0, sd=1), runif(n01, min=-1, max=1)) Y01 = X01%*%as.vector(theta01) + rnorm(n01, mean=0, sd=sqrt(sigsq0)) D01 = cbind(X01, Y01) n02 = 70 theta02 = c(0, 2, 3) X02 = cbind(1, rnorm(n02, mean=0, sd=1), runif(n02, min=-1, max=1)) Y02 = X02%*%as.vector(theta02) + rnorm(n02, mean=0, sd=sqrt(sigsq0)) D02 = cbind(X02, Y02) n03 = 50 theta03 = c(0, 3, 5) X03 = cbind(1, rnorm(n03, mean=0, sd=1), runif(n03, min=-1, max=1)) Y03 = X03%*%as.vector(theta03) + rnorm(n03, mean=0, sd=sqrt(sigsq0)) D03 = cbind(X03, Y03) D0 = list(D01, D02, D03) n0 = c(n01, n02, n03) n = 100 theta = c(0, 3, 5) X = cbind(1, rnorm(n, mean=0, sd=1), runif(n, min=-1, max=1)) Y = X%*%as.vector(theta) + rnorm(n, mean=0, sd=sqrt(sigsq0)) LMMNPP_MCMC2(D0=D0, X=X, Y=Y, a0=2, b=2, mu0=c(0,0,0), R=diag(c(1/64,1/64,1/64)), delta_ini=NULL, prior_delta_alpha=c(1,1,1), prior_delta_beta=c(1,1,1), prop_delta_alpha=c(1,1,1), prop_delta_beta=c(1,1,1), prop_delta="RW", rw_delta=0.9, nsample=5000, burnin=1000, thin=5) ## End(Not run)
## Not run: set.seed(1234) sigsq0 = 1 n01 = 100 theta01 = c(0, 1, 1) X01 = cbind(1, rnorm(n01, mean=0, sd=1), runif(n01, min=-1, max=1)) Y01 = X01%*%as.vector(theta01) + rnorm(n01, mean=0, sd=sqrt(sigsq0)) D01 = cbind(X01, Y01) n02 = 70 theta02 = c(0, 2, 3) X02 = cbind(1, rnorm(n02, mean=0, sd=1), runif(n02, min=-1, max=1)) Y02 = X02%*%as.vector(theta02) + rnorm(n02, mean=0, sd=sqrt(sigsq0)) D02 = cbind(X02, Y02) n03 = 50 theta03 = c(0, 3, 5) X03 = cbind(1, rnorm(n03, mean=0, sd=1), runif(n03, min=-1, max=1)) Y03 = X03%*%as.vector(theta03) + rnorm(n03, mean=0, sd=sqrt(sigsq0)) D03 = cbind(X03, Y03) D0 = list(D01, D02, D03) n0 = c(n01, n02, n03) n = 100 theta = c(0, 3, 5) X = cbind(1, rnorm(n, mean=0, sd=1), runif(n, min=-1, max=1)) Y = X%*%as.vector(theta) + rnorm(n, mean=0, sd=sqrt(sigsq0)) LMMNPP_MCMC2(D0=D0, X=X, Y=Y, a0=2, b=2, mu0=c(0,0,0), R=diag(c(1/64,1/64,1/64)), delta_ini=NULL, prior_delta_alpha=c(1,1,1), prior_delta_beta=c(1,1,1), prop_delta_alpha=c(1,1,1), prop_delta_beta=c(1,1,1), prop_delta="RW", rw_delta=0.9, nsample=5000, burnin=1000, thin=5) ## End(Not run)
Conduct posterior sampling for normal linear model with normalized power prior.
For the power parameter , a Metropolis-Hastings algorithm with either
independence proposal, or a random walk proposal on its logit scale is used.
For the regression parameter
and
, Gibbs sampling is used.
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))
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))
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
|
MCMCmethod |
sampling method for |
rw.logit.delta |
the stepsize(variance of the normal distribution) for the random walk proposal of logit |
ind.delta.alpha |
specifies the first parameter |
ind.delta.beta |
specifies the first parameter |
nsample |
specifies the number of posterior samples in the output. |
control.mcmc |
a list of three elements used in posterior sampling.
|
If , prior for
is
, which includes the g-prior.
If
, prior for
is
.
The outputs include posteriors of the model parameter(s) and power parameter, acceptance rate when sampling
, and
the deviance information criteria.
A list of class "NPP" with five elements:
beta |
posterior of the model parameter |
sigmasq |
posterior of the model parameter |
delta |
posterior of the power parameter |
acceptance |
the acceptance rate in MCMC sampling for |
DIC |
the deviance information criteria for model diagnostics. |
Zifei Han [email protected]
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.
BerNPP_MCMC
;
MultinomialNPP_MCMC
;
PoissonNPP_MCMC
;
NormalNPP_MCMC
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))
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))
Multiple historical data are incorporated together.
Conduct posterior sampling for Linear Regression Model with ordered normalized power prior.
For the power parameter , a Metropolis-Hastings algorithm with
independence proposal is used.
For the model parameters
, Gibbs sampling is used.
LMOMNPP_MCMC1(D0, X, Y, a0, b, mu0, R, gamma_ini, prior_gamma, gamma_ind_prop, nsample, burnin, thin, adjust)
LMOMNPP_MCMC1(D0, X, Y, a0, b, mu0, R, gamma_ini, prior_gamma, gamma_ind_prop, nsample, burnin, thin, adjust)
D0 |
a list of |
X |
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. |
Y |
a vector of individual level of the response y in the current data. |
a0 |
a positive shape parameter for inverse-gamma prior on model parameter |
b |
a positive scale parameter for inverse-gamma prior on model parameter |
mu0 |
a vector of the mean for prior |
R |
a inverse matrix of the covariance matrix for prior |
gamma_ini |
the initial value of |
prior_gamma |
a vector of the hyperparameters in the prior distribution
|
gamma_ind_prop |
a vector of the hyperparameters in the proposal distribution |
nsample |
specifies the number of posterior samples in the output. |
burnin |
the number of burn-ins. The output will only show MCMC samples after bunrin. |
thin |
the thinning parameter in MCMC sampling. |
adjust |
Whether or not to adjust the parameters of the proposal distribution. |
The outputs include posteriors of the model parameters and power parameter,
acceptance rate in sampling .
Let
=
, the normalized power prior distribution is
Here and
are the initial prior distributions of
and
, respectively.
is the likelihood function of historical data
, and
is the corresponding power parameter.
A list of class "NPP" with four elements:
acceptrate |
the acceptance rate in MCMC sampling for |
beta |
posterior of the model parameter |
sigma |
posterior of the model parameter |
delta |
posterior of the power parameter |
Qiang Zhang [email protected]
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.
LMMNPP_MCMC1
;
LMMNPP_MCMC2
;
LMOMNPP_MCMC2
## Not run: set.seed(1234) sigsq0 = 1 n01 = 100 theta01 = c(0, 1, 1) X01 = cbind(1, rnorm(n01, mean=0, sd=1), runif(n01, min=-1, max=1)) Y01 = X01%*%as.vector(theta01) + rnorm(n01, mean=0, sd=sqrt(sigsq0)) D01 = cbind(X01, Y01) n02 = 70 theta02 = c(0, 2, 3) X02 = cbind(1, rnorm(n02, mean=0, sd=1), runif(n02, min=-1, max=1)) Y02 = X02%*%as.vector(theta02) + rnorm(n02, mean=0, sd=sqrt(sigsq0)) D02 = cbind(X02, Y02) n03 = 50 theta03 = c(0, 3, 5) X03 = cbind(1, rnorm(n03, mean=0, sd=1), runif(n03, min=-1, max=1)) Y03 = X03%*%as.vector(theta03) + rnorm(n03, mean=0, sd=sqrt(sigsq0)) D03 = cbind(X03, Y03) D0 = list(D01, D02, D03) n0 = c(n01, n02, n03) n = 100 theta = c(0, 3, 5) X = cbind(1, rnorm(n, mean=0, sd=1), runif(n, min=-1, max=1)) Y = X%*%as.vector(theta) + rnorm(n, mean=0, sd=sqrt(sigsq0)) LMOMNPP_MCMC1(D0=D0, X=X, Y=Y, a0=2, b=2, mu0=c(0,0,0), R=diag(c(1/64,1/64,1/64)), gamma_ini=NULL, prior_gamma=rep(1/4,4), gamma_ind_prop=rep(1/4,4), nsample=5000, burnin=1000, thin=5, adjust=FALSE) ## End(Not run)
## Not run: set.seed(1234) sigsq0 = 1 n01 = 100 theta01 = c(0, 1, 1) X01 = cbind(1, rnorm(n01, mean=0, sd=1), runif(n01, min=-1, max=1)) Y01 = X01%*%as.vector(theta01) + rnorm(n01, mean=0, sd=sqrt(sigsq0)) D01 = cbind(X01, Y01) n02 = 70 theta02 = c(0, 2, 3) X02 = cbind(1, rnorm(n02, mean=0, sd=1), runif(n02, min=-1, max=1)) Y02 = X02%*%as.vector(theta02) + rnorm(n02, mean=0, sd=sqrt(sigsq0)) D02 = cbind(X02, Y02) n03 = 50 theta03 = c(0, 3, 5) X03 = cbind(1, rnorm(n03, mean=0, sd=1), runif(n03, min=-1, max=1)) Y03 = X03%*%as.vector(theta03) + rnorm(n03, mean=0, sd=sqrt(sigsq0)) D03 = cbind(X03, Y03) D0 = list(D01, D02, D03) n0 = c(n01, n02, n03) n = 100 theta = c(0, 3, 5) X = cbind(1, rnorm(n, mean=0, sd=1), runif(n, min=-1, max=1)) Y = X%*%as.vector(theta) + rnorm(n, mean=0, sd=sqrt(sigsq0)) LMOMNPP_MCMC1(D0=D0, X=X, Y=Y, a0=2, b=2, mu0=c(0,0,0), R=diag(c(1/64,1/64,1/64)), gamma_ini=NULL, prior_gamma=rep(1/4,4), gamma_ind_prop=rep(1/4,4), nsample=5000, burnin=1000, thin=5, adjust=FALSE) ## End(Not run)
Multiple historical data are combined individually.
The NPP of multiple historical data is the product of the NPP of each historical data.
Conduct posterior sampling for Linear Regression Model with ordered normalized power prior.
For the power parameter , a Metropolis-Hastings algorithm with
independence proposal is used.
For the model parameters
, Gibbs sampling is used.
LMOMNPP_MCMC2(D0, X, Y, a0, b, mu0, R, gamma_ini, prior_gamma, gamma_ind_prop, nsample, burnin, thin, adjust)
LMOMNPP_MCMC2(D0, X, Y, a0, b, mu0, R, gamma_ini, prior_gamma, gamma_ind_prop, nsample, burnin, thin, adjust)
D0 |
a list of |
X |
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. |
Y |
a vector of individual level of the response y in the current data. |
a0 |
a positive shape parameter for inverse-gamma prior on model parameter |
b |
a positive scale parameter for inverse-gamma prior on model parameter |
mu0 |
a vector of the mean for prior |
R |
a inverse matrix of the covariance matrix for prior |
gamma_ini |
the initial value of |
prior_gamma |
a vector of the hyperparameters in the prior distribution
|
gamma_ind_prop |
a vector of the hyperparameters in the proposal distribution |
nsample |
specifies the number of posterior samples in the output. |
burnin |
the number of burn-ins. The output will only show MCMC samples after bunrin. |
thin |
the thinning parameter in MCMC sampling. |
adjust |
Whether or not to adjust the parameters of the proposal distribution. |
The outputs include posteriors of the model parameters and power parameter,
acceptance rate in sampling .
Let
=
, the normalized power prior distribution is
Here and
are the initial prior distributions of
and
, respectively.
is the likelihood function
of historical data
, and
is the corresponding power parameter.
A list of class "NPP" with four elements:
acceptrate |
the acceptance rate in MCMC sampling for |
beta |
posterior of the model parameter |
sigma |
posterior of the model parameter |
delta |
posterior of the power parameter |
Qiang Zhang [email protected]
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.
LMMNPP_MCMC1
;
LMMNPP_MCMC2
;
LMOMNPP_MCMC1
## Not run: set.seed(1234) sigsq0 = 1 n01 = 100 theta01 = c(0, 1, 1) X01 = cbind(1, rnorm(n01, mean=0, sd=1), runif(n01, min=-1, max=1)) Y01 = X01%*%as.vector(theta01) + rnorm(n01, mean=0, sd=sqrt(sigsq0)) D01 = cbind(X01, Y01) n02 = 70 theta02 = c(0, 2, 3) X02 = cbind(1, rnorm(n02, mean=0, sd=1), runif(n02, min=-1, max=1)) Y02 = X02%*%as.vector(theta02) + rnorm(n02, mean=0, sd=sqrt(sigsq0)) D02 = cbind(X02, Y02) n03 = 50 theta03 = c(0, 3, 5) X03 = cbind(1, rnorm(n03, mean=0, sd=1), runif(n03, min=-1, max=1)) Y03 = X03%*%as.vector(theta03) + rnorm(n03, mean=0, sd=sqrt(sigsq0)) D03 = cbind(X03, Y03) D0 = list(D01, D02, D03) n0 = c(n01, n02, n03) n = 100 theta = c(0, 3, 5) X = cbind(1, rnorm(n, mean=0, sd=1), runif(n, min=-1, max=1)) Y = X%*%as.vector(theta) + rnorm(n, mean=0, sd=sqrt(sigsq0)) LMOMNPP_MCMC1(D0=D0, X=X, Y=Y, a0=2, b=2, mu0=c(0,0,0), R=diag(c(1/64,1/64,1/64)), gamma_ini=NULL, prior_gamma=rep(1/4,4), gamma_ind_prop=rep(1/4,4), nsample=5000, burnin=1000, thin=5, adjust=FALSE) ## End(Not run)
## Not run: set.seed(1234) sigsq0 = 1 n01 = 100 theta01 = c(0, 1, 1) X01 = cbind(1, rnorm(n01, mean=0, sd=1), runif(n01, min=-1, max=1)) Y01 = X01%*%as.vector(theta01) + rnorm(n01, mean=0, sd=sqrt(sigsq0)) D01 = cbind(X01, Y01) n02 = 70 theta02 = c(0, 2, 3) X02 = cbind(1, rnorm(n02, mean=0, sd=1), runif(n02, min=-1, max=1)) Y02 = X02%*%as.vector(theta02) + rnorm(n02, mean=0, sd=sqrt(sigsq0)) D02 = cbind(X02, Y02) n03 = 50 theta03 = c(0, 3, 5) X03 = cbind(1, rnorm(n03, mean=0, sd=1), runif(n03, min=-1, max=1)) Y03 = X03%*%as.vector(theta03) + rnorm(n03, mean=0, sd=sqrt(sigsq0)) D03 = cbind(X03, Y03) D0 = list(D01, D02, D03) n0 = c(n01, n02, n03) n = 100 theta = c(0, 3, 5) X = cbind(1, rnorm(n, mean=0, sd=1), runif(n, min=-1, max=1)) Y = X%*%as.vector(theta) + rnorm(n, mean=0, sd=sqrt(sigsq0)) LMOMNPP_MCMC1(D0=D0, X=X, Y=Y, a0=2, b=2, mu0=c(0,0,0), R=diag(c(1/64,1/64,1/64)), gamma_ini=NULL, prior_gamma=rep(1/4,4), gamma_ind_prop=rep(1/4,4), nsample=5000, burnin=1000, thin=5, adjust=FALSE) ## End(Not run)
Based on Its Values on Selected Knots
The function returns the interpolated value (a scalar) of based on its results on selected knots,
given input vector of
.
logCdelta(delta, deltaknot, lCknot)
logCdelta(delta, deltaknot, lCknot)
delta |
a scalar of the input value of |
deltaknot |
a vector of the knots for |
lCknot |
a vector of the values |
A sequence of the values, on selected knots.
Zifei Han [email protected]
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.
loglikNormD0
;
loglikBerD0
;
logCknot
on Selected Knots
The function returns a sequence of the values, on selected knots, given
input vector of
.
logCknot(deltaknot, llikf0)
logCknot(deltaknot, llikf0)
deltaknot |
a vector of the knots for |
llikf0 |
a matrix of the log-likelihoods of class "npp". |
A sequence of the values, on selected knots.
Zifei Han [email protected]
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.
loglikNormD0
;
loglikBerD0
;
logCdelta
The function returns a matrix of class "npp", each element is a log-likelihood of the historical data.
It is an intermediate step to calculate the "normalizing constant" in the normalized
power prior, for the purpose of providing a flexible implementation.
Users can specify their own likelihood function of the same class following this structure.
loglikBerD0(D0, thetalist, ntheta = 1)
loglikBerD0(D0, thetalist, ntheta = 1)
D0 |
a vector of each observation(binary) in historical data. |
thetalist |
a list of parameter values. The number of elements is equal to |
ntheta |
a positive integer indicating number of parameters to be estimated in the model. Default is 1 for Bernoulli. |
A numeric matrix of log-likelihood, for the historical data given the matrix(or array)-valued parameters.
Zifei Han [email protected]
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.
loglikNormD0
;
logCknot
;
logCdelta
The function returns a matrix of class "npp", each element is a log-likelihood of the historical data.
It is an intermediate step to calculate the "normalizing constant" in the normalized
power prior, for the purpose of providing a flexible implementation.
Users can specify their own likelihood function of the same class following this structure.
loglikNormD0(D0, thetalist, ntheta = 2)
loglikNormD0(D0, thetalist, ntheta = 2)
D0 |
a vector of each observation in historical data. |
thetalist |
a list of parameter values. The number of elements is equal to |
ntheta |
a positive integer indicating number of parameters to be estimated in the model. |
A numeric matrix of log-likelihood, for the historical data given the matrix(or array)-valued parameters.
Zifei Han [email protected]
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.
loglikBerD0
;
logCknot
;
logCdelta
The function returns the posterior mode of the power parameter in Bernoulli population.
It calculates the log of the posterior density (up to a normalizing constant), and conduct a grid search
to find the approximate mode.
ModeDeltaBerNPP(Data.Cur, Data.Hist, CompStat = list(n0 = NULL, y0 = NULL, n1 = NULL, y1 = NULL), npoints = 1000, prior = list(p.alpha = 1, p.beta = 1, delta.alpha = 1, delta.beta = 1))
ModeDeltaBerNPP(Data.Cur, Data.Hist, CompStat = list(n0 = NULL, y0 = NULL, n1 = NULL, y1 = NULL), npoints = 1000, prior = list(p.alpha = 1, p.beta = 1, delta.alpha = 1, delta.beta = 1))
Data.Cur |
a non-negative integer vector of two elements: c(number of success, number of failure) in the current data. |
Data.Hist |
a non-negative integer vector of two elements: c(number of success, number of failure) in the historical data. |
CompStat |
a list of four elements that represents the
"compatibility(sufficient) statistics" for
|
npoints |
is a non-negative integer scalar indicating number of points on a regular spaced grid between [0, 1], where we calculate the log of the posterior and search for the mode. |
prior |
a list of the hyperparameters in the prior for both
|
See example.
A numeric value between 0 and 1.
Zifei Han [email protected]
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.
ModeDeltaNormalNPP
;
ModeDeltaPoisNPP
;
ModeDeltaMultinomialNPP
ModeDeltaBerNPP(Data.Cur = c(100, 40), Data.Hist = c(100, 40), npoints = 1000, prior = list(p.alpha = 1, p.beta = 1, delta.alpha = 1, delta.beta = 1)) ModeDeltaBerNPP(Data.Cur = c(100, 40), Data.Hist = c(100, 35), npoints = 1000, prior = list(p.alpha = 1, p.beta = 1, delta.alpha = 1, delta.beta = 1)) ModeDeltaBerNPP(Data.Cur = c(100, 40), Data.Hist = c(100, 50), npoints = 1000, prior = list(p.alpha = 1, p.beta = 1, delta.alpha = 1, delta.beta = 1))
ModeDeltaBerNPP(Data.Cur = c(100, 40), Data.Hist = c(100, 40), npoints = 1000, prior = list(p.alpha = 1, p.beta = 1, delta.alpha = 1, delta.beta = 1)) ModeDeltaBerNPP(Data.Cur = c(100, 40), Data.Hist = c(100, 35), npoints = 1000, prior = list(p.alpha = 1, p.beta = 1, delta.alpha = 1, delta.beta = 1)) ModeDeltaBerNPP(Data.Cur = c(100, 40), Data.Hist = c(100, 50), npoints = 1000, prior = list(p.alpha = 1, p.beta = 1, delta.alpha = 1, delta.beta = 1))
The function returns the posterior mode of the power parameter in normal linear model.
It calculates the log of the posterior density (up to a normalizing constant), and conduct a grid search
to find the approximate mode.
ModeDeltaLMNPP(y.Cur, y.Hist, x.Cur = NULL, x.Hist = NULL, npoints = 1000, prior = list(a = 1.5, b = 0, mu0 = 0, Rinv = matrix(1, nrow = 1), delta.alpha = 1, delta.beta = 1))
ModeDeltaLMNPP(y.Cur, y.Hist, x.Cur = NULL, x.Hist = NULL, npoints = 1000, prior = list(a = 1.5, b = 0, mu0 = 0, Rinv = matrix(1, nrow = 1), delta.alpha = 1, delta.beta = 1))
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. |
npoints |
is a non-negative integer scalar indicating number of points on a regular spaced grid between [0, 1], where we calculate the log of the posterior and search for the mode. |
prior |
a list of the hyperparameters in the prior for model parameters
|
If , prior for
is
, which includes the g-prior.
If
, prior for
is
.
The outputs include posteriors of the model parameter(s) and power parameter, acceptance rate when sampling
, and
the deviance information criteria.
Zifei Han [email protected]
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.
ModeDeltaBerNPP
;
ModeDeltaNormalNPP
;
ModeDeltaMultinomialNPP
;
ModeDeltaNormalNPP
The function returns the posterior mode of the power parameter in multinomial population.
It calculates the log of the posterior density (up to a normalizing constant), and conduct a grid search
to find the approximate mode.
ModeDeltaMultinomialNPP(Data.Cur, Data.Hist, CompStat = list(n0 = NULL, n1 = NULL), npoints = 1000, prior = list(theta.dir.alpha = c(0.5, 0.5, 0.5), delta.alpha = 1, delta.beta = 1))
ModeDeltaMultinomialNPP(Data.Cur, Data.Hist, CompStat = list(n0 = NULL, n1 = NULL), npoints = 1000, prior = list(theta.dir.alpha = c(0.5, 0.5, 0.5), delta.alpha = 1, delta.beta = 1))
Data.Cur |
a non-negative integer vector of |
Data.Hist |
a non-negative integer vector of |
CompStat |
a list of two elements that represents the
"compatibility(sufficient) statistics" for
|
npoints |
is a non-negative integer scalar indicating number of points on a regular spaced grid between [0, 1], where we calculate the log of the posterior and search for the mode. |
prior |
a list of the hyperparameters in the prior for both
|
See example.
A numeric value between 0 and 1.
Zifei Han [email protected]
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.
ModeDeltaBerNPP
;
ModeDeltaNormalNPP
;
ModeDeltaPoisNPP
ModeDeltaMultinomialNPP(CompStat = list(n0 = c(25,25,25,25), n1 = c(25,25,25,25)), prior = list(theta.dir.alpha = c(0.5, 0.5, 0.5, 0.5), delta.alpha = 1, delta.beta = 1)) ModeDeltaMultinomialNPP(CompStat = list(n0 = c(22,25,28,25), n1 = c(25,22,25,28)), prior = list(theta.dir.alpha = c(0.5, 0.5, 0.5, 0.5), delta.alpha = 1, delta.beta = 1)) ModeDeltaMultinomialNPP(CompStat = list(n0 = c(15,25,30,30), n1 = c(25,25,25,25)), prior = list(theta.dir.alpha = c(0.5, 0.5, 0.5, 0.5), delta.alpha = 1, delta.beta = 1))
ModeDeltaMultinomialNPP(CompStat = list(n0 = c(25,25,25,25), n1 = c(25,25,25,25)), prior = list(theta.dir.alpha = c(0.5, 0.5, 0.5, 0.5), delta.alpha = 1, delta.beta = 1)) ModeDeltaMultinomialNPP(CompStat = list(n0 = c(22,25,28,25), n1 = c(25,22,25,28)), prior = list(theta.dir.alpha = c(0.5, 0.5, 0.5, 0.5), delta.alpha = 1, delta.beta = 1)) ModeDeltaMultinomialNPP(CompStat = list(n0 = c(15,25,30,30), n1 = c(25,25,25,25)), prior = list(theta.dir.alpha = c(0.5, 0.5, 0.5, 0.5), delta.alpha = 1, delta.beta = 1))
The function returns the posterior mode of the power parameter in multinomial population.
It calculates the log of the posterior density (up to a normalizing constant), and conduct a grid search
to find the approximate mode.
ModeDeltaNormalNPP(Data.Cur, Data.Hist, CompStat = list(n0 = NULL, mean0 = NULL, var0 = NULL, n1 = NULL, mean1 = NULL, var1 = NULL), npoints = 1000, prior = list(a = 1.5, delta.alpha = 1, delta.beta = 1))
ModeDeltaNormalNPP(Data.Cur, Data.Hist, CompStat = list(n0 = NULL, mean0 = NULL, var0 = NULL, n1 = NULL, mean1 = NULL, var1 = NULL), npoints = 1000, prior = list(a = 1.5, delta.alpha = 1, delta.beta = 1))
Data.Cur |
a vector of individual level current data. |
Data.Hist |
a vector of individual level historical data. |
CompStat |
a list of six elements(scalar) that represents the
"compatibility(sufficient) statistics" for model parameters.
Default is
|
npoints |
is a non-negative integer scalar indicating number of points on a regular spaced grid between [0, 1], where we calculate the log of the posterior and search for the mode. |
prior |
a list of the hyperparameters in the prior for both
|
See example.
A numeric value between 0 and 1.
Zifei Han [email protected]
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.
ModeDeltaBerNPP
;
ModeDeltaMultinomialNPP
;
ModeDeltaPoisNPP
ModeDeltaNormalNPP(CompStat = list(n0 = 50, mean0 = 0, var0 = 1, n1 = 50, mean1 = 0, var1 = 1), npoints = 1000, prior = list(a = 1.5, delta.alpha = 1, delta.beta = 1)) ModeDeltaNormalNPP(CompStat = list(n0 = 50, mean0 = 0, var0 = 1, n1 = 40, mean1 = 0.2, var1 = 1), npoints = 1000, prior = list(a = 1.5, delta.alpha = 1, delta.beta = 1)) ModeDeltaNormalNPP(CompStat = list(n0 = 50, mean0 = 0, var0 = 1, n1 = 40, mean1 = 0.6, var1 = 1), npoints = 1000, prior = list(a = 1.5, delta.alpha = 1, delta.beta = 1))
ModeDeltaNormalNPP(CompStat = list(n0 = 50, mean0 = 0, var0 = 1, n1 = 50, mean1 = 0, var1 = 1), npoints = 1000, prior = list(a = 1.5, delta.alpha = 1, delta.beta = 1)) ModeDeltaNormalNPP(CompStat = list(n0 = 50, mean0 = 0, var0 = 1, n1 = 40, mean1 = 0.2, var1 = 1), npoints = 1000, prior = list(a = 1.5, delta.alpha = 1, delta.beta = 1)) ModeDeltaNormalNPP(CompStat = list(n0 = 50, mean0 = 0, var0 = 1, n1 = 40, mean1 = 0.6, var1 = 1), npoints = 1000, prior = list(a = 1.5, delta.alpha = 1, delta.beta = 1))
The function returns the posterior mode of the power parameter in multinomial population.
It calculates the log of the posterior density (up to a normalizing constant), and conduct a grid search
to find the approximate mode.
ModeDeltaPoisNPP(Data.Cur, Data.Hist, CompStat = list(n0 = NULL, mean0 = NULL, n1 = NULL, mean1 = NULL), npoints = 1000, prior = list(lambda.shape = 1/2, lambda.scale = 100, delta.alpha = 1, delta.beta = 1))
ModeDeltaPoisNPP(Data.Cur, Data.Hist, CompStat = list(n0 = NULL, mean0 = NULL, n1 = NULL, mean1 = NULL), npoints = 1000, prior = list(lambda.shape = 1/2, lambda.scale = 100, delta.alpha = 1, delta.beta = 1))
Data.Cur |
a non-negative integer vector of each observed current data. |
Data.Hist |
a non-negative integer vector of each observed historical data. |
CompStat |
a list of four elements that represents the
"compatibility(sufficient) statistics" for
|
npoints |
is a non-negative integer scalar indicating number of points on a regular spaced grid between [0, 1], where we calculate the log of the posterior and search for the mode. |
prior |
a list of the hyperparameters in the prior for both
|
See example.
A numeric value between 0 and 1.
Zifei Han [email protected]
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.
ModeDeltaBerNPP
;
ModeDeltaNormalNPP
;
ModeDeltaMultinomialNPP
ModeDeltaPoisNPP(CompStat = list(n0 = 50, mean0 = 10, n1 = 50, mean1 = 10), npoints = 1000, prior = list(lambda.shape = 1/2, lambda.scale = 100, delta.alpha = 1, delta.beta = 1)) ModeDeltaPoisNPP(CompStat = list(n0 = 50, mean0 = 10, n1 = 50, mean1 = 9.5), npoints = 1000, prior = list(lambda.shape = 1/2, lambda.scale = 100, delta.alpha = 1, delta.beta = 1)) ModeDeltaPoisNPP(CompStat = list(n0 = 50, mean0 = 10, n1 = 50, mean1 = 9), npoints = 1000, prior = list(lambda.shape = 1/2, lambda.scale = 100, delta.alpha = 1, delta.beta = 1))
ModeDeltaPoisNPP(CompStat = list(n0 = 50, mean0 = 10, n1 = 50, mean1 = 10), npoints = 1000, prior = list(lambda.shape = 1/2, lambda.scale = 100, delta.alpha = 1, delta.beta = 1)) ModeDeltaPoisNPP(CompStat = list(n0 = 50, mean0 = 10, n1 = 50, mean1 = 9.5), npoints = 1000, prior = list(lambda.shape = 1/2, lambda.scale = 100, delta.alpha = 1, delta.beta = 1)) ModeDeltaPoisNPP(CompStat = list(n0 = 50, mean0 = 10, n1 = 50, mean1 = 9), npoints = 1000, prior = list(lambda.shape = 1/2, lambda.scale = 100, delta.alpha = 1, delta.beta = 1))
Conduct posterior sampling for multinomial population with normalized power prior.
For the power parameter , a Metropolis-Hastings algorithm with either
independence proposal, or a random walk proposal on its logit scale is used.
For the model parameter vector
, Gibbs sampling is used.
Assume the prior for model parameter
comes from a Dirichlet distribution.
MultinomialNPP_MCMC(Data.Cur = c(10, 10, 10), Data.Hist = c(10, 10, 10), CompStat = list(n0 = NULL, n1 = NULL), prior = list(theta.dir = c(0.5, 0.5, 0.5), 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))
MultinomialNPP_MCMC(Data.Cur = c(10, 10, 10), Data.Hist = c(10, 10, 10), CompStat = list(n0 = NULL, n1 = NULL), prior = list(theta.dir = c(0.5, 0.5, 0.5), 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))
Data.Cur |
a non-negative integer vector of |
Data.Hist |
a non-negative integer vector of |
CompStat |
a list of two elements that represents the
"compatibility(sufficient) statistics" for
|
prior |
a list of the hyperparameters in the prior for both
|
MCMCmethod |
sampling method for |
rw.logit.delta |
the stepsize(variance of the normal distribution) for the random walk proposal of logit |
ind.delta.alpha |
specifies the first parameter |
ind.delta.beta |
specifies the first parameter |
nsample |
specifies the number of posterior samples in the output. |
control.mcmc |
a list of three elements used in posterior sampling.
|
The outputs include posteriors of the model parameter(s) and power parameter, acceptance rate in sampling , and
the deviance information criteria.
A list of class "NPP" with four elements:
p |
posterior of the model parameter |
delta |
posterior of the power parameter |
acceptance |
the acceptance rate in MCMC sampling for |
DIC |
the deviance information criteria for model diagnostics. |
Tianyu Bai [email protected] Zifei Han [email protected]
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.
BerNPP_MCMC
;
NormalNPP_MCMC
;
PoissonNPP_MCMC
MultinomialNPP_MCMC(Data.Cur = c(3,11,3,669), Data.Hist = c(9,20,9,473), prior = list(theta.dir = c(1,1,1,1), delta.alpha = 1, delta.beta = 1), MCMCmethod = 'IND', rw.logit.delta = 0.1, ind.delta.alpha = 1, ind.delta.beta = 1, nsample = 10000, control.mcmc = list(delta.ini = NULL, burnin = 2000, thin = 5))
MultinomialNPP_MCMC(Data.Cur = c(3,11,3,669), Data.Hist = c(9,20,9,473), prior = list(theta.dir = c(1,1,1,1), delta.alpha = 1, delta.beta = 1), MCMCmethod = 'IND', rw.logit.delta = 0.1, ind.delta.alpha = 1, ind.delta.beta = 1, nsample = 10000, control.mcmc = list(delta.ini = NULL, burnin = 2000, thin = 5))
Conduct posterior sampling for normal population with normalized power prior.
The initial prior is a flat prior.
For the power parameter
, a Metropolis-Hastings algorithm with either
independence proposal, or a random walk proposal on its logit scale is used.
For the model parameter
and
, Gibbs sampling is used.
NormalNPP_MCMC(Data.Cur, Data.Hist, CompStat = list(n0 = NULL, mean0 = NULL, var0 = NULL, n1 = NULL, mean1 = NULL, var1 = NULL), prior = list(a = 1.5, 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))
NormalNPP_MCMC(Data.Cur, Data.Hist, CompStat = list(n0 = NULL, mean0 = NULL, var0 = NULL, n1 = NULL, mean1 = NULL, var1 = NULL), prior = list(a = 1.5, 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))
Data.Cur |
a vector of individual level current data. |
Data.Hist |
a vector of individual level historical data. |
CompStat |
a list of six elements(scalar) that represents the
"compatibility(sufficient) statistics" for model parameters.
Default is
|
prior |
a list of the hyperparameters in the prior for both
|
MCMCmethod |
sampling method for |
rw.logit.delta |
the stepsize(variance of the normal distribution) for the random walk proposal of logit |
ind.delta.alpha |
specifies the first parameter |
ind.delta.beta |
specifies the first parameter |
nsample |
specifies the number of posterior samples in the output. |
control.mcmc |
a list of three elements used in posterior sampling.
|
The outputs include posteriors of the model parameter(s) and power parameter, acceptance rate in sampling , and
the deviance information criteria.
A list of class "NPP" with five elements:
mu |
posterior of the model parameter |
sigmasq |
posterior of the model parameter |
delta |
posterior of the power parameter |
acceptance |
the acceptance rate in MCMC sampling for |
DIC |
the deviance information criteria for model diagnostics. |
Zifei Han [email protected]
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.
BerNPP_MCMC
;
MultinomialNPP_MCMC
;
PoissonNPP_MCMC
;
set.seed(1234) NormalData0 <- rnorm(n = 100, mean= 20, sd = 1) set.seed(12345) NormalData1 <- rnorm(n = 50, mean= 30, sd = 1) NormalNPP_MCMC(Data.Cur = NormalData1, Data.Hist = NormalData0, CompStat = list(n0 = 100, mean0 = 10, var0 = 1, n1 = 100, mean1 = 10, var1 = 1), prior = list(a = 1.5, delta.alpha = 1, delta.beta = 1), MCMCmethod = 'RW', rw.logit.delta = 1, ind.delta.alpha= 1, ind.delta.beta= 1, nsample = 10000, control.mcmc = list(delta.ini = NULL, burnin = 0, thin = 1))
set.seed(1234) NormalData0 <- rnorm(n = 100, mean= 20, sd = 1) set.seed(12345) NormalData1 <- rnorm(n = 50, mean= 30, sd = 1) NormalNPP_MCMC(Data.Cur = NormalData1, Data.Hist = NormalData0, CompStat = list(n0 = 100, mean0 = 10, var0 = 1, n1 = 100, mean1 = 10, var1 = 1), prior = list(a = 1.5, delta.alpha = 1, delta.beta = 1), MCMCmethod = 'RW', rw.logit.delta = 1, ind.delta.alpha= 1, ind.delta.beta= 1, nsample = 10000, control.mcmc = list(delta.ini = NULL, burnin = 0, thin = 1))
The dataset is used to assess if there is site impairment. The site impairment is defined as whether the pH values at a site indicate that the site violates a (lower) standard of 6.0 more than 10% of the time.
data("PHData")
data("PHData")
A data frame with 325 observations on the following 3 variables.
Station
the site number, labeled as 1 to 4
Data.Time
indicator of historical data (coded as 0) or current data (coded as 1)
PH
value of PH on the site
data(PHData)
data(PHData)
This function incorporates multiple sets of historical data for posterior sampling in a Poisson population using a normalized power prior. The power parameter uses a Metropolis-Hastings algorithm, which can be either an independence proposal or a random walk proposal on its logit scale. For the model parameter
, Gibbs sampling is employed.
PoiMNPP_MCMC1(n0, n, prior_lambda, prop_delta, prior_delta_alpha, prior_delta_beta, rw_delta, delta_ini, nsample, burnin, thin)
PoiMNPP_MCMC1(n0, n, prior_lambda, prop_delta, prior_delta_alpha, prior_delta_beta, rw_delta, delta_ini, nsample, burnin, thin)
n0 |
A vector of natural numbers: number of successes in historical data. |
n |
A natural number: number of successes in the current data. |
prior_lambda |
A vector of hyperparameters for the prior distribution |
prop_delta |
The class of proposal distribution for |
prior_delta_alpha |
A vector of hyperparameter |
prior_delta_beta |
A vector of hyperparameter |
rw_delta |
The stepsize (variance of the normal distribution) for the random walk proposal of logit |
delta_ini |
The initial value for |
nsample |
Specifies the number of posterior samples in the output. |
burnin |
The number of burn-ins. Only the MCMC samples after this burn-in will be shown in the output. |
thin |
The thinning parameter used in MCMC sampling. |
The function returns posteriors for both the model and power parameters, as well as the acceptance rate for sampling . The normalized power prior distribution is given by:
Here, and
are the initial prior distributions for
and
, respectively.
is the likelihood function based on historical data
, with
being its corresponding power parameter.
A list of class "NPP" comprising:
acceptrate |
The acceptance rate in MCMC sampling for |
lambda |
Posterior samples of the model parameter |
delta |
Posterior samples of the power parameter |
Qiang Zhang [email protected]
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.
PoiMNPP_MCMC2
,
PoiOMNPP_MCMC1
,
PoiOMNPP_MCMC2
PoiMNPP_MCMC1(n0 = c(0, 3, 5), n = 3, prior_lambda = c(1, 1/10), prop_delta = "IND", prior_delta_alpha = c(1, 1, 1), prior_delta_beta = c(1, 1, 1), rw_delta = 0.1, delta_ini = NULL, nsample = 2000, burnin = 500, thin = 2)
PoiMNPP_MCMC1(n0 = c(0, 3, 5), n = 3, prior_lambda = c(1, 1/10), prop_delta = "IND", prior_delta_alpha = c(1, 1, 1), prior_delta_beta = c(1, 1, 1), rw_delta = 0.1, delta_ini = NULL, nsample = 2000, burnin = 500, thin = 2)
Multiple historical data are combined individually.
Conduct posterior sampling for Poisson population with normalized power prior.
For the power parameter , a Metropolis-Hastings algorithm with either independence proposal, or a random walk proposal on its logit scale is used.
For the model parameter
, Gibbs sampling is used.
PoiMNPP_MCMC2(n0,n,prior_lambda,prop_delta,prior_delta_alpha, prior_delta_beta,rw_delta, delta_ini,nsample,burnin,thin)
PoiMNPP_MCMC2(n0,n,prior_lambda,prop_delta,prior_delta_alpha, prior_delta_beta,rw_delta, delta_ini,nsample,burnin,thin)
n0 |
a natural number vector : number of successes in historical data. |
n |
a natural number : number of successes in the current data. |
prior_lambda |
a vector of the hyperparameters in the prior distribution |
prop_delta |
the class of proposal distribution for |
prior_delta_alpha |
a vector of the hyperparameter |
prior_delta_beta |
a vector of the hyperparameter |
rw_delta |
the stepsize(variance of the normal distribution) for the random walk proposal of logit |
delta_ini |
the initial value of |
nsample |
specifies the number of posterior samples in the output. |
burnin |
the number of burn-ins. The output will only show MCMC samples after bunrin. |
thin |
the thinning parameter in MCMC sampling. |
The outputs include posteriors of the model parameter(s) and power parameter, acceptance rate in sampling .
The normalized power prior distribution is
Here and
are the initial prior distributions of
and
, respectively.
is the likelihood function of historical data
, and
is the corresponding power parameter.
A list of class "NPP" with three elements:
acceptrate |
the acceptance rate in MCMC sampling for |
lambda |
posterior of the model parameter |
delta |
posterior of the power parameter |
Qiang Zhang [email protected]
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.
PoiMNPP_MCMC1
;
PoiOMNPP_MCMC1
;
PoiOMNPP_MCMC2
PoiMNPP_MCMC2(n0=c(0,3,5),n=3,prior_lambda=c(1,1/10),prop_delta="IND", prior_delta_alpha=c(1,1,1), prior_delta_beta=c(1,1,1), rw_delta=0.1, delta_ini=NULL, nsample = 2000, burnin = 500, thin = 2)
PoiMNPP_MCMC2(n0=c(0,3,5),n=3,prior_lambda=c(1,1/10),prop_delta="IND", prior_delta_alpha=c(1,1,1), prior_delta_beta=c(1,1,1), rw_delta=0.1, delta_ini=NULL, nsample = 2000, burnin = 500, thin = 2)
Multiple ordered historical data are incorporated together.
Conduct posterior sampling for Poisson population with normalized power prior.
For the power parameter , a Metropolis-Hastings algorithm with independence proposal is used.
For the model parameter
, Gibbs sampling is used.
PoiOMNPP_MCMC1(n0,n,prior_gamma,prior_lambda, gamma_ind_prop, gamma_ini,nsample,burnin,thin)
PoiOMNPP_MCMC1(n0,n,prior_gamma,prior_lambda, gamma_ind_prop, gamma_ini,nsample,burnin,thin)
n0 |
a natural number vector : number of successes in historical data. |
n |
a natural number : number of successes in the current data. |
prior_gamma |
a vector of the hyperparameters in the prior distribution |
prior_lambda |
a vector of the hyperparameters in the prior distribution |
gamma_ind_prop |
a vector of the hyperparameters in the proposal distribution |
gamma_ini |
the initial value of |
nsample |
specifies the number of posterior samples in the output. |
burnin |
the number of burn-ins. The output will only show MCMC samples after bunrin. |
thin |
the thinning parameter in MCMC sampling. |
The outputs include posteriors of the model parameter(s) and power parameter, acceptance rate in sampling .
The normalized power prior distribution is
Here and
are the initial prior distributions of
and
, respectively.
is the likelihood function of historical data
, and
is the corresponding power parameter.
A list of class "NPP" with three elements:
acceptrate |
the acceptance rate in MCMC sampling for |
lambda |
posterior of the model parameter |
delta |
posterior of the power parameter |
Qiang Zhang [email protected]
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.
PoiMNPP_MCMC1
;
PoiMNPP_MCMC2
;
PoiOMNPP_MCMC2
PoiOMNPP_MCMC1(n0=c(0,3,5),n=3,prior_gamma=c(1/2,1/2,1/2,1/2), prior_lambda=c(1,1/10), gamma_ind_prop=rep(1,4),gamma_ini=NULL, nsample = 2000, burnin = 500, thin = 2)
PoiOMNPP_MCMC1(n0=c(0,3,5),n=3,prior_gamma=c(1/2,1/2,1/2,1/2), prior_lambda=c(1,1/10), gamma_ind_prop=rep(1,4),gamma_ini=NULL, nsample = 2000, burnin = 500, thin = 2)
Multiple ordered historical data are combined individually.
Conduct posterior sampling for Poisson population with normalized power prior.
For the power parameter , a Metropolis-Hastings algorithm with independence proposal is used.
For the model parameter
, Gibbs sampling is used.
PoiOMNPP_MCMC2(n0,n,prior_gamma,prior_lambda, gamma_ind_prop,gamma_ini, nsample, burnin, thin)
PoiOMNPP_MCMC2(n0,n,prior_gamma,prior_lambda, gamma_ind_prop,gamma_ini, nsample, burnin, thin)
n0 |
a natural number vector : number of successes in historical data. |
n |
a natural number : number of successes in the current data. |
prior_gamma |
a vector of the hyperparameters in the prior distribution |
prior_lambda |
a vector of the hyperparameters in the prior distribution |
gamma_ind_prop |
a vector of the hyperparameters in the proposal distribution |
gamma_ini |
the initial value of |
nsample |
specifies the number of posterior samples in the output. |
burnin |
the number of burn-ins. The output will only show MCMC samples after bunrin. |
thin |
the thinning parameter in MCMC sampling. |
The outputs include posteriors of the model parameter(s) and power parameter, acceptance rate in sampling .
The normalized power prior distribution is
Here and
are the initial prior distributions of
and
, respectively.
is the likelihood function of historical data
, and
is the corresponding power parameter.
A list of class "NPP" with three elements:
acceptrate |
the acceptance rate in MCMC sampling for |
lambda |
posterior of the model parameter |
delta |
posterior of the power parameter |
Qiang Zhang [email protected]
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.
PoiMNPP_MCMC1
;
PoiMNPP_MCMC2
;
PoiOMNPP_MCMC1
PoiOMNPP_MCMC2(n0=c(0,3,5),n=3,prior_gamma=c(1/2,1/2,1/2,1/2), prior_lambda=c(1,1/10), gamma_ind_prop=rep(1,4), gamma_ini=NULL, nsample = 2000, burnin = 500, thin = 2)
PoiOMNPP_MCMC2(n0=c(0,3,5),n=3,prior_gamma=c(1/2,1/2,1/2,1/2), prior_lambda=c(1,1/10), gamma_ind_prop=rep(1,4), gamma_ini=NULL, nsample = 2000, burnin = 500, thin = 2)
Conduct posterior sampling for Poisson population with normalized power prior.
For the power parameter , a Metropolis-Hastings algorithm with either
independence proposal, or a random walk proposal on its logit scale is used.
For the model parameter
, Gibbs sampling is used.
PoissonNPP_MCMC(Data.Cur, Data.Hist, CompStat = list(n0 = NULL, mean0 = NULL, n1 = NULL, mean1 = NULL), prior = list(lambda.shape = 1/2, lambda.scale = 100, 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))
PoissonNPP_MCMC(Data.Cur, Data.Hist, CompStat = list(n0 = NULL, mean0 = NULL, n1 = NULL, mean1 = NULL), prior = list(lambda.shape = 1/2, lambda.scale = 100, 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))
Data.Cur |
a non-negative integer vector of each observed current data. |
Data.Hist |
a non-negative integer vector of each observed historical data. |
CompStat |
a list of four elements that represents the
"compatibility(sufficient) statistics" for
|
prior |
a list of the hyperparameters in the prior for both
|
MCMCmethod |
sampling method for |
rw.logit.delta |
the stepsize(variance of the normal distribution) for the random walk proposal of logit |
ind.delta.alpha |
specifies the first parameter |
ind.delta.beta |
specifies the first parameter |
nsample |
specifies the number of posterior samples in the output. |
control.mcmc |
a list of three elements used in posterior sampling.
|
The outputs include posteriors of the model parameter(s) and power parameter, acceptance rate in sampling , and
the deviance information criteria.
A list of class "NPP" with four elements:
lambda |
posterior of the model parameter |
delta |
posterior of the power parameter |
acceptance |
the acceptance rate in MCMC sampling for |
DIC |
the deviance information criteria for model diagnostics. |
Zifei Han [email protected]
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.
MultinomialNPP_MCMC
;
NormalNPP_MCMC
;
BerNPP_MCMC
;
set.seed(1234) DataHist <- rpois(n = 100, lambda = 49) set.seed(12345) DataCur <- rpois(n = 100, lambda = 49) PoissonNPP_MCMC(Data.Cur = DataCur, Data.Hist = DataHist, CompStat = list(n0 = 20, mean0 = 10, n1 = 30, mean1 = 11), prior = list(lambda.shape = 1/2, lambda.scale = 100, delta.alpha = 1, delta.beta = 1), MCMCmethod = 'RW', rw.logit.delta = 1, ind.delta.alpha= 1, ind.delta.beta= 1,nsample = 10000, control.mcmc = list(delta.ini = NULL, burnin = 2000, thin = 1))
set.seed(1234) DataHist <- rpois(n = 100, lambda = 49) set.seed(12345) DataCur <- rpois(n = 100, lambda = 49) PoissonNPP_MCMC(Data.Cur = DataCur, Data.Hist = DataHist, CompStat = list(n0 = 20, mean0 = 10, n1 = 30, mean1 = 11), prior = list(lambda.shape = 1/2, lambda.scale = 100, delta.alpha = 1, delta.beta = 1), MCMCmethod = 'RW', rw.logit.delta = 1, ind.delta.alpha= 1, ind.delta.beta= 1,nsample = 10000, control.mcmc = list(delta.ini = NULL, burnin = 2000, thin = 1))
The diagnostic test was developed to aid in rapidly assess the risk of spontaneouspreterm delivery within 7 days from the time of diagnosis in pre-pregnant women with signs and symptoms. The same diagnostic test was used for two populations in US and EU respectively. The number of counts in the four cells (True positive, false positive, false negative, true negative) was recorded.
data("SPDData")
data("SPDData")
A data frame with 2 observations on the following 5 variables.
Data.Region
region where the diagnostic test was conducted
TPDP
number of subjects with tested positive and the disease status positive (true positive)
TPDN
number of subjects with tested positive but the disease status negative (false positive)
TNDP
number of subjects with tested negative and the disease status positive (false negative)
TNDN
number of subjects with tested negative and the disease status negative (true negative)
https://www.accessdata.fda.gov/cdrh_docs/pdf16/P160052C.pdf
data(SPDData)
data(SPDData)
The study was designed to investigate the concomitant use of RotaTeq(Test Vaccine) and some routine pediatric vaccines between 2001-2005. The dataset includes four historical control trials. The purpose of the study is to borrow the historical controls for the non-inferiority trial. The interest is in the response rate to the routine vaccines.
data("VaccineData")
data("VaccineData")
A data frame with 6 observations on the following 7 variables.
Data.Time
indicator of historical data (coded as 0) or current data (coded as 1).
StudyID
character to distinguish different studies.
Group
indicator of control group (coded as 0) or treatment group (coded as 1).
Start.Year
start year of the trial
End.Year
end year of the trial
N
total number of patients enrolled and dosed in the group
y
total number of patients respond to the vaccine
Liu, G.F. (2018). A Dynamic Power Prior for Borrowing Historical Data in Noninferiority Trials with Binary Endpoint. Pharmaceutical Statistics 17:61-73.
data(VaccineData)
data(VaccineData)