update_par_nichisq {RARtrials} | R Documentation |
Update Parameters of a Normal-Inverse-Chi-Squared Distribution with Available Data
Description
Update parameters of a Normal-Inverse-Chi-Squared distribution
Usage
update_par_nichisq(y, par)
Arguments
y |
observed data. |
par |
a vector of current parameters including mu, kappa, nu, sigsq from a Normal-Inverse-Chi-Squared distribution. |
Details
This function updates parameters of a Normal-Inverse-Chi-Squared
((\mu,\sigma^2) \sim NIX(mean=\mu,effective sample size=\kappa,degrees of freedom=\nu,variance=\sigma^2/\kappa)
)
distribution with available data to parameters of a posterior Normal-Inverse-Gamma
((\mu,\sigma^2) \sim NIG(mean=m,variance=V \times \sigma^2,shape=a,rate=b)
)distribution.
Those updated parameters can be converted to parameters in a Normal-Inverse-Gamma distribution
for continuous outcomes with unknown variances using convert_chisq_to_gamma
.
Value
a list of parameters including mu, kappa, nu, sigsq for a posterior Normal-Inverse-Chi-Squared distribution incorporating available data.
References
Murphy K (2007). “Conjugate Bayesian analysis of the Gaussian distribution.” University of British Columbia. https://www.cs.ubc.ca/~murphyk/Papers/bayesGauss.pdf.
Examples
para<-list(V=1/2,a=0.5,m=9.1/100,b=0.00002)
par<-convert_gamma_to_chisq(para)
set.seed(123451)
y1<-rnorm(100,0.091,0.009)
update_par_nichisq(y1, par)
set.seed(123452)
y2<-rnorm(90,0.09,0.009)
update_par_nichisq(y2, par)