Learn R Programming

LaplacesDemon (version 16.1.0)

Precision: Precision

Description

Bayesians often use precision rather than variance. These are elementary utility functions to facilitate conversions between precision, standard deviation, and variance regarding scalars, vectors, and matrices, and these functions are designed for those who are new to Bayesian inference. The names of these functions consist of two different scale parameters, separated by a `2', and capital letters refer to matrices while lower case letters refer to scalars and vectors. For example, the Prec2Cov function converts a precision matrix to a covariance matrix, while the prec2sd function converts a scalar or vector of precision parameters to standard deviation parameters.

The modern Bayesian use of precision developed because it was more straightforward in a normal distribution to estimate precision \(\tau\) with a gamma distribution as a conjugate prior, than to estimate \(\sigma^2\) with an inverse-gamma distribution as a conjugate prior. Today, conjugacy is usually considered to be merely a convenience, and in this example, a non-conjugate half-Cauchy prior distribution is recommended as a weakly informative prior distribution for scale parameters.

Usage

Cov2Prec(Cov)
Prec2Cov(Prec)
prec2sd(prec=1)
prec2var(prec=1)
sd2prec(sd=1)
sd2var(sd=1)
var2prec(var=1)
var2sd(var=1)

Arguments

Cov

This is a covariance matrix, usually represented as \(\Sigma\).

Prec

This is a precision matrix, usually represented as \(\Omega\).

prec

This is a precision scalar or vector, usually represented as \(\tau\).

sd

This is a standard deviation scalar or vector, usually represented as \(\sigma\).

var

This is a variance scalar or vector, usually represented as \(\sigma^2\).

Value

Cov2Prec

This returns a precision matrix, \(\Omega\), from a covariance matrix, \(\Sigma\), where \(\Omega = \Sigma^{-1}\).

Prec2Cov

This returns a covariance matrix, \(\Sigma\), from a precision matrix, \(\Omega\), where \(\Sigma = \Omega^{-1}\).

prec2sd

This returns a standard deviation, \(\sigma\), from a precision, \(\tau\), where \(\sigma = \sqrt{\tau^{-1}}\).

prec2var

This returns a variance, \(\sigma^2\), from a precision, \(\tau\), where \(\sigma^2 = \tau^{-1}\).

sd2prec

This returns a precision, \(\tau\), from a standard deviation, \(\sigma\), where \(\tau = \sigma^{-2}\).

sd2var

This returns a variance, \(\sigma^2\), from a standard deviation, \(\sigma\), where \(\sigma^2 = \sigma \sigma\).

var2prec

This returns a precision, \(\tau\), from a variance, \(\sigma^2\), where \(\tau = \frac{1}{\sigma^2}\).

var2sd

This returns a standard deviation, \(\sigma\), from a variance, \(\sigma^2\), where \(\sigma = \sqrt{\sigma^2}\).

Details

Bayesians often use precision rather than variance, where precision is the inverse of the variance. For example, a linear regression may be represented equivalently as \(\textbf{y} \sim \mathcal{N}(\mu, \sigma^2)\), or \(\textbf{y} \sim \mathcal{N}(\mu, \tau^{-1})\), where \(\sigma^2\) is the variance, and \(\tau\) is the precision, which is the inverse of the variance.

See Also

Cov2Cor

Examples

Run this code
# NOT RUN {
library(LaplacesDemon)
Cov2Prec(matrix(c(1,0.1,0.1,1),2,2))
Prec2Cov(matrix(c(1,0.1,0.1,1),2,2))
prec2sd(0.5)
prec2var(0.5)
sd2prec(1.4142)
sd2var(01.4142)
var2prec(2)
var2sd(2)
# }

Run the code above in your browser using DataLab