lm.npp | R Documentation |
Sample from the posterior distribution of a normal linear model using the NPP by Duan et al. (2006) doi:10.1002/env.752.
The power prior parameters (a_0
's) are treated as random with independent beta priors. The current and historical
data sets are assumed to have a common dispersion parameter (\sigma^2
) with an inverse-gamma prior. Conditional on
\sigma^2
, the initial priors on the regression coefficients are independent normal distributions with variance
\propto (\sigma^2)^{-1}
. In this case, the normalizing constant for the NPP has a closed form.
lm.npp(
formula,
data.list,
offset.list = NULL,
beta.mean = NULL,
beta.sd = NULL,
sigmasq.shape = 2.1,
sigmasq.scale = 1.1,
a0.shape1 = 1,
a0.shape2 = 1,
a0.lower = NULL,
a0.upper = NULL,
iter_warmup = 1000,
iter_sampling = 1000,
chains = 4,
...
)
formula |
a two-sided formula giving the relationship between the response variable and covariates. |
data.list |
a list of |
offset.list |
a list of vectors giving the offsets for each data. The length of offset.list is equal to the length of data.list. The length of each element of offset.list is equal to the number of rows in the corresponding element of data.list. Defaults to a list of vectors of 0s. |
beta.mean |
a scalar or a vector whose dimension is equal to the number of regression coefficients giving the mean parameters for the initial prior on regression coefficients. If a scalar is provided, beta.mean will be a vector of repeated elements of the given scalar. Defaults to a vector of 0s. |
beta.sd |
a scalar or a vector whose dimension is equal to the number of regression coefficients. Conditional on the variance parameter sigmasq for the outcome, beta.sd * sqrt(sigmasq) gives the sd for the initial prior on regression coefficients. If a scalar is provided, same as for beta.mean. Defaults to a vector of 10s. |
sigmasq.shape |
shape parameter for inverse-gamma prior on variance parameter. Defaults to 2.1. |
sigmasq.scale |
scale parameter for inverse-gamma prior on variance parameter. Defaults to 1.1. |
a0.shape1 |
first shape parameter for the i.i.d. beta prior on a0 vector. When |
a0.shape2 |
second shape parameter for the i.i.d. beta prior on a0 vector. When |
a0.lower |
a scalar or a vector whose dimension is equal to the number of historical data sets giving the lower bounds for each element of the a0 vector. If a scalar is provided, a0.lower will be a vector of repeated elements of the given scalar. Defaults to a vector of 0s. |
a0.upper |
a scalar or a vector whose dimension is equal to the number of historical data sets giving the upper bounds for each element of the a0 vector. If a scalar is provided, same as for a0.lower. Defaults to a vector of 1s. |
iter_warmup |
number of warmup iterations to run per chain. Defaults to 1000. See the argument |
iter_sampling |
number of post-warmup iterations to run per chain. Defaults to 1000. See the argument |
chains |
number of Markov chains to run. Defaults to 4. See the argument |
... |
arguments passed to |
The function returns an object of class draws_df
giving posterior samples.
Duan, Y., Ye, K., and Smith, E. P. (2005). Evaluating water quality using power priors to incorporate historical information. Environmetrics, 17(1), 95–106.
if (instantiate::stan_cmdstan_exists()) {
data(actg019)
data(actg036)
data_list = list(currdata = actg019, histdata = actg036)
lm.npp(
formula = cd4 ~ treatment + age + race,
data.list = data_list,
chains = 1, iter_warmup = 500, iter_sampling = 1000
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.