update_normal_gamma: Conjugate Model Normal - Normal Gamma

Description Usage Arguments Value Examples

View source: R/update_normal_gamma.R

Description

The conjugate model is (x| mu,tau) ~ Normal(mu, tau); (mu, tau) ~ Normal-Gamma(mu0,v0,alpha0,beta0) See wikipedia for details https://en.wikipedia.org/wiki/Conjugate_prior

Usage

1
2
3
4
5
6
7
8
update_normal_gamma(
  suff_stat_data,
  mu0,
  v0,
  alpha0,
  beta0,
  sufficient_statistics
)

Arguments

suff_stat_data

a vector of sufficient statistics: sample_size, sample_mean and sample_sd. If sufficient_statistics = FALSE, then it is vector of observed data

mu0

prior hyperparameter mu0 for the normal-gamma distribution

v0

prior hyperparameter v0 for the normal-gamma distribution

alpha0

prior hyperparameter alpha0 for the normal-gamma distribution

beta0

prior hyperparameter beta0 for the normal-gamma distribution

sufficient_statistics

logical; if TRUE, sufficient statistics, suff_stat_data, are given as input data, otherwise suff_stat_data is given as observed data. Default is TRUE

Value

param A list with the prior and posterior hyperparameters. It constains the following components

prior

A list with the prior hyperparameters mu, v, alpha, beta

posterior

A list with the posterior hyperparameters mu, v, alpha, beta

Examples

1
2
3
dta <- rnorm(100)
update_normal_gamma(suff_stat_data = dta, mu0 = 0,
                   v0 = 5, alpha0 = 1, beta0 = 1, sufficient_statistics = FALSE)

Iraices/PrecisePvsBoundedP documentation built on Jan. 18, 2021, 11:32 p.m.