makePriors: Priors for internal use.

View source: R/makePriors.R

makePriorsR Documentation

Priors for internal use.

Description

Prepare the given prior settings for internal use in INLA. The input of the function makePriors are prior settings for variances and correlation or the full covariance matrix, these are then transformed to the internal parameterisation that INLA requires. This function is used internally in the main function meta4diag() but can also be used as a separate function.

Usage

makePriors(var.prior = "PC", var2.prior="PC", cor.prior = "PC",
  var.par = c(3, 0.05), var2.par, cor.par = c(1,-0.1,0.5,-0.95,0.05,0.95,0.05),
  wishart.par = c(4,1,1,0), init = c(0.01, 0.01, -0.1))

Arguments

var.prior

A string specifying the prior density for the first variance component, options are "PC" for penalised complexity prior, "Invgamma" for inverse gamma prior, "Tnormal" for truncated normal prior, "Unif" for uniform prior which allow the standard deviation uniformaly distributed on [0,1000], "Hcauchy" for half-cauchy prior and "table" for user specific prior. var.prior can also be set to "Invwishart" for inverse wishart prior for covariance matrix. When var.prior="Invwishart", no matter what var2.prior and cor.prior are given, the inverse Wishart prior covariance matrix is used for covariance matrix and the wishart.par must be given. Of note, the values of this argument is not case sensitive. The definition of the priors is as following,

  • var.prior="Invgamma": This is a prior for a variance \sigma^2. The inverse gamma prior has density,

    \pi(\sigma^2)=\frac{1}{\Gamma(a)b^a}(\sigma^2)^{-a-1}exp(-\frac{1}{b\sigma^2}),

    for \sigma^2>0 where: a>0 is the shape parameter, b>0 is the rate (1/scale) parameter. The parameters are here c(a, b), see arguments var.par.

  • var.prior="Tnormal": This is a prior for a variance \sigma^2 and defined as follows. The standard deviation \sigma=\sqrt{\sigma^2} is Gaussian distributed with mean m and variance v but truncated to be positive. The parameters are here c(m, v), see arguments var.par.

  • var.prior="PC": This is a prior for a variance \sigma^2 and defined as follows. The left tail of the distribution of standard deviation \sigma has behavior

    P(\sigma>u)=\alpha,

    which means it is unlikely that the standard deviation \sigma to be larger than a value u with probability \alpha. The parameters are here c(u, alpha), see arguments var.par.

  • var.prior="Hcauchy": This is a prior for a variance \sigma^2 and defined as follows. The standard deviation \sigma=\sqrt{\sigma^2} is half-Cauchy distributed with density,

    \pi(\sigma)=\frac{2\gamma}{\pi(\sigma^2+\gamma^2)},

    where \gamma>0 is the rate parameter. The parameters are here c(gamma), see arguments var.par.

  • var.prior="Unif": This is a prior for a variance \sigma^2 and defined as follows. The standard deviation \sigma=\sqrt{\sigma^2} is uniform distributed on (0,\infty). No parameters need to be given for this prior, see arguments var.par.

  • var.prior="Table": This is a prior for a variance \sigma^2 and defined as follows. Users have to specify a data.frame with 2 columns, one indicates the values of \sigma^2 and the other one indicates the values of \pi(\sigma^2). The parameters are this data frame, see arguments var.par.

  • var.prior="Invwishart": Instead of specifying separate prior distributions for the variance and correlation parameters we could also assume that the covariance matrix \Sigma

    \Sigma \sim Wishart^{-1}_{p}(\nu,R),p=2,

    where the Wishart distribution has density

    \pi(\Sigma)=\frac{|R|^{\frac{\nu}{2}}}{2^{\frac{p\nu}{2}}\Gamma_{p}(\frac{\nu}{2})}|\Sigma|^{-\frac{\nu+p+1}{2}}exp(-\frac{1}{2}Trace(\frac{R}{\Sigma})), \nu>p+1,

    Then,

    E(\Sigma)=\frac{R}{\nu-p-1}.

    The parameters are \nu, R_{11},R_{22} and R_{12}, where

    R=\left(\begin{array}{cc}R_{11} & R_{12} \\ R_{21} & R_{22}\end{array}\right)

    The parameters are here c(nu, R11, R22, R12), see arguments var.par.

var2.prior

See var.prior.

cor.prior

A string specifying the prior density for the correlation, options are "PC" for penalised complexity prior, "Invgamma" for inverse gamma prior, "Beta" for beta prior and "table" for user specific prior. cor.prior can also be set to "Invwishart" for inverse wishart prior for covariance matrix. When cor.prior="Invwishart", no matter what var.prior and var2.prior are given, the inverse Wishart prior for covariance matrix is used and the wishart.par must be given. Of note, the values of this argument is not case sensitive. The definition of the priors is as following,

  • cor.prior="Normal": This is a prior for a correlation \rho and defined as follows. The correlation parameter is constrained to [-1, 1]. We reparameterise the correlation parameter \rho using Fisher's z-transformation as

    \rho^{\star}=logit(\frac{\rho+1}{2}),

    which assumes values over the whole real line and assign the following prior distribution to \rho,

    \rho \sim Gaussian(\mu,\sigma^2).

    The prior variance of 2.5 and prior mean of 0 corresponds, roughly, to a uniform prior on [-1,1] for \rho . The parameters are here c(mean, variance), see arguments cor.par.

  • cor.prior="PC": This is a prior for a correlation \rho and defined as follows. The prior is defined around at a reference point with value \rho_{0}. To define the density behavior, three strategy can be applied. The first strategy is to define the left tail behavior and the density weight on the left-hand side of the reference point \rho_{0},

    P(\rho<u_{1})=a_{1},

    and

    P(\rho<\rho_{0})=\omega,

    which means it is unlikely that the value of \rho is smaller than a small value u_{1} with probability a_{1} and the probability that \rho is smaller than \rho_0 is \omega. The parameters for the first strategy are here c(1, rho0, omega, u1, a1, NA, NA), see arguments cor.par. The second strategy is to define the right tail behavior and the density weight on the left-hand side of the reference point \rho_{0},

    P(\rho>u_{2})=a_{2},

    and

    P(\rho<\rho_{0})=\omega,

    which means it is unlikely that the value of \rho is larger than a big value u_{2} with probability a_{2} and the probability that \rho is smaller than \rho_0 is \omega. The parameters for the second strategy are here c(2, rho0, omega, NA, NA, u2, a2), see arguments cor.par. The third strategy is to define both tail behaviors,

    P(\rho<u_{1})=a_{1},

    and

    P(\rho>u_{2})=a_{2}.

    The parameters for the third strategy are here c(3, rho0, NA, u1, a1, u2, a2), see arguments cor.par. The parameters of the PC prior for the correlation here is c(strategy, rho0, omega, u1, a1, u2, a2), see arguments cor.par.

  • cor.prior="Beta": This is a prior for a correlation \rho and defined as follows. The correlation parameter \rho has a Beta(a,b) distribution scaled to have domain in (-1, 1):

    \pi(\rho)=0.5\frac{\Gamma(a+b)}{\Gamma(a)\Gamma(b)}\rho^{a-1}(1-\rho)^{b-1}

    , where a,b>0 are the shape parameter. The parameters are here c(a, b), see arguments cor.par.

  • cor.prior="Table": This is a prior for a correlation \rho and defined as follows. Users have to specify the data.frame with 2 columns, one indicates the values of \rho and the other one indicates the values of \pi(\rho). The parameters are this data frame, see arguments cor.par.

  • cor.prior="Invwishart": Instead of specifying separate prior distributions for the hyperparameters we could also assume that the covariance matrix \Sigma

    \Sigma \sim Wishart^{-1}_{p}(\nu,R),p=2,

    where the inverse Wishart distribution has density

    \pi(\Sigma)=\frac{|R|^{\frac{\nu}{2}}}{2^{\frac{p\nu}{2}}\Gamma_{p}(\frac{\nu}{2})}|\Sigma|^{-\frac{\nu+p+1}{2}}exp(-\frac{1}{2}Trace(\frac{R}{\Sigma})), \nu>p+1,

    Then,

    E(\Sigma)=\frac{R}{\nu-p-1}.

    The parameters are \nu, R_{11},R_{22} and R_{12}, where

    R=\left(\begin{array}{cc}R_{11} & R_{12} \\ R_{21} & R_{22}\end{array}\right)

    The parameters are here c(nu, R11, R22, R12), see arguments cor.par.

var.par

A numerical vector specifying the parameter of the prior density for the first variance component.

  • var.par=c(rate, shape) when var.prior="Invgamma".

  • var.par=c(u, alpha) when var.prior="PC".

  • var.par=c(m, v) when var.prior="Tnormal".

  • var.par=c(gamma) when var.prior="Hcauchy".

  • var.par=c() when var.prior="Unif".

  • var.par is a data frame with 2 columns, one indicates the values of \sigma^2 and the other one indicates the values of \pi(\sigma^2) when var.prior="Table".

  • var.par doesn't need to be given when var.prior="Invwishart".

See also argument var.prior.

var2.par

A numerical vector specifying the parameter of the prior density for the second variance component. If not given, function will copy the setting for the first variance component. The definition of the priors is the same as for var.par.

cor.par

A numerical vector specifying the parameter of the prior density for the correlation. See also examples.

  • cor.par=c(mean, variance) when cor.prior="normal".

  • cor.par=c(strategy, rho0, omega, u1, a1, u2, a2) when cor.prior="PC".

  • cor.par=c(a, b) when var.prior="beta".

  • cor.par is a data frame with 2 columns, one indicates the values of \rho and the other one indicates the values of \pi(\rho) when cor.prior="Table".

  • cor.par doesn't need to be given when cor.prior="Invwishart".

See also argument cor.prior.

wishart.par

A numerical vector specifying the parameter of the prior density for the covariance matrix. wishart.par must be given and wishart.par=c(nu, R11, R22, R12) when any of var.prior, var2.prior or cor.prior is "Invwishart". See also examples.

init

A numerical vector specifying the initial value of the first variance, the second variance and correlation.

Value

A list of prior settings with the components:

prec1

a list of prior settings for the first log precision (the log inverse of the first variance in the model).

prec2

a list of prior settings for the second log precision (the log inverse of the second variance in the model).

cor

a list of prior settings for the transformed correlation (some functions of correlation in the model).

lambdas

a vector of rate parameters for the PC correlation if cor.prior="PC".

density

a list of prior densities for precisions and correlations.

original.setting

a list of input prior settings.

wishart.flag

Boolean indicating whether a inverse Wishart prior is setting or not.

Author(s)

Jingyi Guo and Andrea Riebler

References

Simpson DP, Martins TG, Riebler A, Fuglstad GA, Rue H, Sorbye SH (2014) Penalised Model Component Complexity: A principled, Practical Approach to Constructing Priors. Arxiv e-prints. 1403.4630

Examples

## Not run: 
if(requireNamespace("INLA", quietly = TRUE)){
require("INLA", quietly = TRUE)
makePriors(var.prior = "PC", cor.prior = "PC", var.par = c(3, 0.05), 
  cor.par = c(1, -0.1, 0.5, -0.95, 0.05, NA, NA))
makePriors(var.prior = "PC", cor.prior = "PC", var.par = c(3, 0.05), 
  cor.par = c(2, -0.1, 0.5, NA, NA, 0.95, 0.05))
makePriors(var.prior = "PC", cor.prior = "PC", var.par = c(3, 0.05), 
  cor.par = c(3, -0.1, NA, -0.95, 0.05, 0.95, 0.05))
makePriors(var.prior = "invgamma", cor.prior = "normal", 
  var.par = c(0.25, 0.025), cor.par = c(0, 5))
makePriors(var.prior = "invwishart", wishart.par=c(4,1,2,0.1))
}

## End(Not run)

meta4diag documentation built on Nov. 29, 2023, 3:01 a.m.