# Bayesian Approach for Confidence Intervals of Variance on the Normal Distribution

Authors: Autcha Araveeporn
Journal: International Journal of Mathematics and Mathematical Sciences
 (2022)

---

## Abstract

This research aims to compare estimating the confidence intervals of variance based on the normal distribution with the primary method and the Bayesian approach. The maximum likelihood is the well-known method to approximate variance, and the Chi-squared distribution performs the confidence interval. The central Bayesian approach forms the posterior distribution that makes the variance estimator, which depends on the probability and prior distributions. Most introductory prior information looks for the availability of the prior distribution, informative prior distribution, and noninformative prior distribution. The gamma, Chi-squared, and exponential distributions are defined in the prior distribution. The informative prior distribution uses the Markov Chain Monte Carlo (MCMC) method to draw the random sample from the posterior distribution. The Fisher information performs the Wald confidence interval as the noninformative prior distribution. The interval estimation of the Bayesian approach is obtained from the central limit theorem. The performance of these methods considers the coverage probability and minimum value of the average width. The Monte Carlo process simulates the data from a normal distribution with the true parameter of mean and several variances and the sample sizes. The R program generates the simulated data repeated 10,000 times in each situation. The results showed that the maximum likelihood method employed on the small sample sizes. The best confidence interval estimation was when sample sizes increased the Bayesian approach with an available prior distribution. Overall, the Wald confidence interval tended to outperform the large sample sizes. For application in real data, we expressed the reported airborne particulate matter of 2.5 in Bangkok, Thailand. We used the 10–1000 records to estimate the confidence interval of variance and evaluated the interval width. The results are similar to those of the simulation study.


---

## Body

## 1. Introduction

Statistical inference is the process of using detailed statistics on the observation data set (i.e., the mean and the variance), called a statistic, that refer to the properties of the parameter with the population. It assumes that the observed data set is a random sample from a large population. Parameter estimation and hypothesis testing are part of statistical inference related to a statistic and the parameter.The parameter estimation consists of point and interval estimations. Point estimation contains a single value for estimating the population parameter or called an estimator by using the sampled data, a single number. Some error is associated with the point estimator that may be smaller or larger than the true parameter. Instead of a point estimate, confidence interval estimation uses the sampled data to approximate the range of lower and upper bounds of the population parameter. The desire of confidence interval is computed by the mean of the estimators from point estimation plus and minus the variation in that estimate based on the confidence level.The normal distribution is a continuous probability distribution consisting of parameters, namely mean and variance, which is often used in the natural and social sciences. One important parameter of the normal distribution is the variance that measures the dispersion of the data set around its mean. In statistics, variance can be computed by taking the sum of the squared differences dispersed around the mean and dividing by the total sample sizes and then squaring the differences to make them positive.Several tools are available for estimated variance using sample data: the moments method, maximum likelihood method, least-squares method, and Bayesian method. The maximum likelihood method is a primary method for estimating the parameter of probability distribution function given observation. The estimator is approximated by maximizing the likelihood function given the parameter. The maximum likelihood estimator is an interesting method because most estimators present in a class of a minimum variance unbiased estimator [1]. Then, the variance estimator from the maximum likelihood method is used to create the interval estimation from Chi-squared statistics [2]. Smithpreecha and Niwitpong [3] presented four approaches to construct confidence intervals for the common variance of normal distributions and compared the results based on the generalized confidence intervals. Iliopoulos and Kourouklis [4] constructed a confidence interval for the generalized variance of a matrix normal distribution with unknown mean and improved on the usual minimum size.The Bayesian approach method mentions the probability distribution given the parameter related to the prior distribution. Resolution of the prior distribution impacts obtaining the posterior distribution [5]. The case of the prior distribution is defined as the available prior distribution, informative prior distribution, and noninformative prior distribution. The posterior distribution is estimated by the available prior information shown in the appropriate distribution. So, the Bayesian estimator is obtained from the mean of the posterior distribution. Severini [6] studied the relationship between Bayesian and non-Bayesian confidence intervals by deriving asymptotic extensions of the posterior probability for computing the confidence regions based on the likelihood ratio test statistics. Next, Severini [7] was interested in creating an interval estimate for the population parameter and constructed the posterior probability such that the parameter lays in the interval in some specified value. Ali and Riaz [8] studied the Bayesian methodology for designing Bayesian control charts and noticed that the performance of the Bayesian charts is biased.The computer algorithm has been developed to draw a random sample from the posterior distribution in an informative prior distribution [9]. Most used the Markov Chain Monte Carlo (MCMC) [10] method as an informative prior distribution because it can draw an approximate sample from the prior distribution. Then, Gibbs sampling [11] is a process of MCMC to generate the sample values from the posterior distribution. The conjugate prior is the same family as the prior and posterior distributions. The construction of the posterior distribution is in a closed form of conjugate distribution that is made to approximate the MCMC estimator. Atchadé [12] constructed the confidence interval for the asymptotic variance and proposed that the confidence interval converges to standard central limit theorems for the Markov chains. Mahmoud et al. [13] proposed Markov Chain Monte Carlo techniques to compute the maximum likelihood estimation and the confidence intervals of coefficient of variation.The approximation of the confidence interval of variance [14] is studied by using the sample sum of squared deviations from the mean. The confidence interval of minimum length is raised concerning the shortest unbiased interval for the variance of a normal distribution. Typically, the estimated confidence interval of variance is used in the Chi-squared distribution to create the lower and upper bounds. Their importance is partly due to the central limit theorem. Rajić and Stanojević [15] considered the confidence intervals for the ratio of two variances. The F-statistic and central limit theorem proposed the confidence interval. The central limit theorem proposes the Bayesian of the available and informative prior distributions, which performs the confidence interval using the mean and variance from the posterior distribution. Abu-Shawiesh et al. [16] approximated asymptotic confidence interval for the population of standard deviation based on the sample Gini mean difference.Another problem with the prior information is that if the parameter of the prior distribution is entirely appropriate, it should be incorporated into the posterior distribution. This is not a severe problem since the noninformative prior distribution leads to discussion. Kass and Wasserman [17] stated two different interpretations of noninformative priors. The ignorance of noninformative priors was formal representations, and the prior distribution was defined as the constant value when there is insufficient information. Andrés and Álvarez Hernández [18] evaluated the confidence interval on noninformative prior distribution from Jeffrey’s Bayesian method. The Wald method was determined to create the confidence interval of a binomial proportion. Agresti and Coull [19] suggested the Wald confidence interval based on inverting the binomial test.We set out to compare the confidence interval of variance using the maximum likelihood method. The Bayesian approach depended on the available prior distribution, informative prior distribution, and noninformative prior distribution. The data are simulated from the normal distribution with varying true parameters and sample sizes.


## 2. Estimated Methods

The variance of the normal distribution is estimated by the maximum likelihood method and the Bayesian approach as the point estimation. Then, the confidence intervals are computed from the point estimation to construct the lower and upper bounds depending on the significance level. The central limit theorem is the main point in creating the confidence interval of the Bayesian approach.


### 2.1. Maximum Likelihood Method

The maximum likelihood method is the most popular method to approximate a parameter on several distributions. The concept of the maximum likelihood method is to start from the likelihood function of a random variableX. Let X1,…,Xn be independent and identically distributed (iid) random variables via normal distribution with parameter μ and σ2 ; hence, the probability density function is written by(1)fxi|μ,σ2=2πσ2−1exp−xi−μ22σ2,−∞<xi<∞.And it is defined asX∼Nμ,σ2.The likelihood function has used the multiplication of probability function as follows:(2)Lμ,σ2=∏i=1nfxi|μ,σ2=2πσ2−n/2exp−∑i=1nxi−μ22σ2.From (2), take ln on likelihood function following (3)lnLμ,σ2=−n2ln2π−n2lnσ2−∑i=1nxi−μ22σ2.From (3), differential with respect to parameter σ2,(4)∂∂σ2lnLμ,σ2=−n2σ2+∑i=1nxi−μ22σ22=0.We obtain theσ^2=∑i=1nxi−μ2/n , so this estimator is a biased estimator, but it is a sufficient and consistent estimator. The performance estimator has supported this property such as unbiased estimator, minimum of variance, consistency, and sufficiency. This estimator is adjusted from the maximum likelihood estimator and defined the property as σ^Aj.ML2=∑i=1nxi−μ2/n−1. We know that x¯ is an unbiased estimator, and we get the unbiased estimator in terms of x¯ following σ^Aj.ML2=∑i=1nxi−x¯2/n−1.The confidence interval at1−α100% of σ2 is approximated from σ^Aj.ML2 by using the concept of Chi-squared distribution at degree of freedom n−1 [2] following n−1σ^Aj.ML2/σ2∼χn−12; then it can be rewritten as(5)Pn−1σ^Aj.ML2χα/2,n−12<σ2<n−1σ^Aj.ML2χ1−α/2,n−12=1−α.The code for the maximum likelihood method in R programming language is as follows (the example of 90% confidence interval)> MLE = var(x)> l90_percen=(n − 1)/qchisq(1–0.1/2,n − 1)> u90_percen=(n − 1)/qchisq(0.1/2,n − 1)> LCL90_MLE = MLE∗ l90_percen> UCL90_MLE = MLE∗ u90_percen


### 2.2. Bayesian Approach with Available Prior Distribution

From the maximum likelihood method, we know that the probability density function of random variables is a normal distribution asX∼Nμ,σ2 The estimation of the Bayesian approach is considered by adjusting the parameter of normal distribution by X∼Nμ,ϕ−1, where ϕ−1=σ2 and μ is a constant value; then, the probability distribution function from (1) can be rewritten by(6)fxi|μ,ϕ=ϕ2π1/2exp−ϕ2xi−μ2,−∞<xi<∞.From (2), the likelihood function is changed parameter by (7)Lμ,ϕ=ϕ2πn/2exp−ϕ2∑i=1nxi−μ2.The prior distribution ofϕ is considered in form of a gamma distribution with parameter α,λ denoted by Gammaα,λ or rewritten as(8)gϕ;α,λ=λαΓαϕα−1exp−ϕλ,ϕ>0.The resulting posterior distribution is a gamma distribution that is implied by the conjugate distribution from normal distribution on (6) and gamma distribution on (8) as (9)hϕ|xi∝Lμ,ϕgϕ;α,λ∝ϕ2πn/2exp−ϕ2∑i=1nxi−μ2λαΓαϕα−1exp−ϕλ∝ϕn/2+α−1exp−ϕλ+12∑i=1nxi−μ2.Recognizing that this result is displayed in the form of gamma distribution:(10)hϕ|xi∝ϕA−1exp−ϕB∝BAΓAϕA−1exp−ϕB=GammaA,B,where A=n/2+α and B=λ+1/2∑i=1nxi−μ2. μ is approximated by using x¯; then, it can be rewritten as B=λ+1/2∑i=1nxi−x¯2 [5].With the parameterization, the posterior distribution ofσ2=1/ϕ is fσ2|x1,x2,...,xn∼IGA,B , where IGA,B is called the inverse gamma distribution with parameters A and B .The inverse gamma distribution [20] is the same distribution as the reciprocal of a gamma distribution and the relationship of Y=1/X, X∼Gammaα,λ is defined to the inverse gamma distribution as Y∼IGα,λ. The inverse gamma distribution in the form of random variable Y is written as(11)fYy;α,λ=λαΓαy−α−1e−λ/y,y>00,otherwise.The mean of inverse gamma distribution isEY=λ/α−1, and the variance is VarY=λ2/α−12α−2.A similar way to estimate the variance of the Bayesian method is defined as(12)σ^Bayes2=Eσ2|x1,…,xn=BA−1=λ+1/2∑i=1nxi−x¯2n/2+α−1,and the variance of Bayesian estimator is calculated as(13)Varσ2|x1,...,xn=B2A−12A−2=λ+1/2∑i=1nxi−x¯22n/2+α−12n/2+α−2.To evaluate our proposed method, the prior distribution ofϕ is proposed in the form of gamma distribution with parameters α and λ or denoted by Gammaα,λ. Then, the parameter of gamma distribution is an available prior distribution as the gamma, Chi-squared, and exponential distributions by Gamma2,1, Gamma2,0.5, and Gamma1,0.2, shown in Figure 1.Figure 1
Gamma probability density with parameters (α, λ) as Gamma2,1, Gamma2,0.5, and Gamma1,0.2.From central limit theorem [15] with n⟶∞, it can approximate in the form of standard normal distribution by(14)Z=σ^Bayes2−σ2Varσ2=B/A−1−σ2B2/A−12A−2∼N0,1.This is an asymptotic confidence interval that will only give an approximation as the large sample size, which has better coverage rates for small samples [21].The definition of the confidence interval can be expressed as(15)P−Zα/2≤Z≤Zα/2=1−α.Putting these together, (14) and (15), it is often written as(16)P−Zα2≤B/A−1−σ2B2/A−12A−2≤Zα2=1−α.Then,(17)P−Zα2B2A−12A−2≤BA−1−σ2≤Zα2B2A−12A−2=1−α.The confidence interval at1−α100% of σ2 is approximated by(18)PBA−1−Zα2B2A−12A−2≤σ2≤BA−1+Zα2B2A−12A−2=1−α,where A=n/2+α and B=λ+1/2∑i=1nxi−x¯2.The code of R programming language for the Bayesian approach with available prior distribution is set as the constant values of prior distribution as follows (the example of 90% confidence interval).> lamma_bayes.g = 2; alpha_bayes.g = 1> lamma_bayes.c = 2; alpha_bayes.c = 0.5> lamma_bayes.e = 1; alpha_bayes.e = 0.2> B.g = lamma_bayes.g + var(x) ∗ (n − 1)/2); A.g = alpha_bayes.g + (n/2)> B.c = lamma_bayes.c + (var(x) ∗ (n − 1)/2); A.c = alpha_bayes.c + (n/2)> B.e = lamma_bayes.e + (var(x) ∗ (n − 1)/2); A.e = alpha_bayes.e + (n/2)> Bayes.g = B.g/(A.g − 1); Bayes.c = B.c/(A.c − 1); Bayes.e =B.e/(A.e − 1)> SE_Bayes.g = sqrt((B.g ^ 2)/(((A.g − 1)^2)∗(A.g − 2)))> SE_Bayes.c = sqrt((B.c ^ 2)/(((A.c − 1)^2)∗(A.c − 2)))> SE_Bayes.e = sqrt((B.e ^ 2)/(((A.e − 1) ^ 2)∗(A.e − 2)))> LCL90_Bayes.g = Bayes.g − (qnorm90_percen∗ SE_Bayes.g)> LCL90_Bayes.c = Bayes.c − (qnorm90_percen∗ SE_Bayes.c)> LCL90_Bayes.e = Bayes.e − (qnorm90_percen∗ SE_Bayes.e)> UCL90_Bayes.g = Bayes.g + (qnorm90_percen∗ SE_Bayes.g)> UCL90_Bayes.c = Bayes.c + (qnorm90_percen∗ SE_Bayes.c)> UCL90_Bayes.e = Bayes.e + (qnorm90_percen∗ SE_Bayes.e)


### 2.3. Bayesian Approach with Informative Prior

Evaluation of the suitable value on the prior distribution is an important problem because of the difficulty of estimating parameters via the posterior distribution. The solution problem of available prior information has been developed using a sampling algorithm, such as this Markov Chain Monte Carlo (MCMC) method or called the informative prior. This algorithm of the MCMC method is to draw a random sample from the posterior distribution without the conveniently estimated prior distribution. The process is employed by sampling parameters from the Markov Chain method for estimating parameters on prior distribution by the Gibbs sampling algorithm [10]. Then, the posterior distribution uses a Markov Chain and Gibbs sampling to approximate parameters from the MCMC method. We carry out the rjags package, which provides an interface from R [22] to rjags library to generate a sequence of dependent samples from the posterior distribution. Sampling process from the MCMC method is as follows:(1)
DrawX1,…,Xn from the normal distribution with parameter mean μ and variance σ2.(2)
The parameterμ is generated from the normal distribution and the σ2 is generated from the inverse gamma distribution with parameters a and b.(3)
Set initial valuea0t from an exponential distribution and b0t from the gamma distribution with constant values.(4)
Generateσo2t from the posterior distribution based on the inverse gamma distribution with parameters a0t and b0t for t=1,2,…,T, where T is the number of Gibbs sampling algorithm.(5)
Calculate the mean and standard deviation from the posterior distribution function.For each chain, the first 2000 iterations were discarded, and the last 5000 iterations were used to obtain the posterior distribution of the parameter.Thus, the MCMC estimator isσ^MCMC2=∑t=1Tσ2t/T.The confidence interval is created by computing the mean and the variance from the MCMC process as(19)Eσ^MCMC2=∑t=1Tσ2tTand Varσ^MCMC2=∑t=1Tσ2t−σ^MCMC22T−1.According to the central limit theorem withn⟶∞, we have(20)Z=σ^MCMC2−σ2Varσ2=∑t=1Tσ2t/T−σ2∑t=1Tσ2t−σ^MCMC22/T−1∼N0,1,and P−Zα/2≤Z≤Zα/2=1−α.Therefore,(21)P−Zα/2≤∑t=1Tσ2t/T−σ2∑t=1Tσ2t−σ^MCMC22/T−1≤Zα/2=1−α.Then,(22)P−Zα/2∑t=1Tσ2t−σ^MCMC22T−1≤∑t=1Tσ2tT−σ2≤Zα/2∑t=1Tσ2t−σ^MCMC22T−1=1−α.We say that the confidence interval at1−α100% of σ2 by MCMC at 1−α100% is(23)P∑t=1Tσ2tT−Zα2∑t=1Tσ2t−σ^MCMC22T−1≤σ2≤∑t=1Tσ2tT+Zα2∑t=1Tσ2t−σ^MCMC22T−1=1−α.The “rjags” package in the software R is used to estimate the MCMC estimator and confidence interval following (the example of 90% confidence interval):> library(rjags)> dataset = list(x = x, n = n)> inits = list(mu = 0.01, tau = 0.01)> jagmod < −jags.model(“model_normal.txt,” data = dataset, inits = inits,n.chains = 1, n.adapt = 2000)> update(jagmod, n.iter = 20, progress.bar = “text”)> posterior = coda.samples(jagmod,c(“mu,” “sigma”),n.iter = 5000, progress.bar = “text,” thin = 2)> post = as.data.frame(as.matrix(posterior))> var.mcmc = (post$sigma) ^ 2> mcmc.est = mean(var.mcmc)> SE_MCMC = sd(var.mcmc)> LCL90_mcmc.est = mcmc.est − (qnorm90_percen∗ SE_MCMC)> UCL90_mcmc.est = mcmc.est + (qnorm90_percenv∗ SE_MCMC)


### 2.4. Bayesian Approach with Noninformative Prior

The Bayesian theorem is dependent on the likelihood function and the prior distribution, which is used to calculate the posterior distribution. If the prior distribution defines the prior information, it will approximate the estimator on the posterior distribution. If we have no information on prior distribution, we call it a noninformative prior. Agresti and Coull [19] studied the approximation of the interval estimation of binomial proportions based on inverting the Wald large-sample normal test. Then, we used the Wald confidence intervals to construct the confidence interval of variance. The Fisher information in a single observation is needed as(24)Iσ2=E∂∂σ2lnLμ,σ22=−E∂2∂σ22lnLμ,σ2.From (4) and (24), the Fisher information is defined as(25)Iσ2=−E∂∂σ2−n2σ2+∑i=1nxi−μ22σ22=−En2σ22−2∑i=1nxi−μ22σ23=−n2σ22+E∑i=1nxi−μ2σ23=n2σ22.The asymptotic Wald confidence interval based on the maximum likelihood estimator tends to the central limit theorem as(26)Z=σ^Aj.ML2−σ2Iσ2=σ^Aj.ML2−σ2n/2σ^Aj.ML22∼N0,1,and P−Zα/2≤Z≤Zα/2=1−α.We infer that in large sample,n⟶∞(27)P−Zα2≤σ^Aj.ML2−σ21/σ^Aj.ML2n/2≤Zα2=1−α.The Wald confidence interval at1−α100% of σ2 at 1−α100% is(28)Pσ^Aj.ML2−Zα2σ^Aj.ML22n≤σ2≤σ^Aj.ML2+Zα2σ^Aj.ML22n=1−α.The motivation of noninformative prior is that the fisher information indicates the amount of information by the observation about the parameter. The code for the Bayesian approach with noninformative prior based on Wald method in R programming language is as follows (the example of 90% confidence interval).> LCL90_Wald = MLE − (qnorm90_percen∗ sqrt(2/n) ∗ MLE)> UCL90_Wald = MLE + (qnorm90_percen∗ sqrt(2/n) ∗ MLE).


## 2.1. Maximum Likelihood Method

The maximum likelihood method is the most popular method to approximate a parameter on several distributions. The concept of the maximum likelihood method is to start from the likelihood function of a random variableX. Let X1,…,Xn be independent and identically distributed (iid) random variables via normal distribution with parameter μ and σ2 ; hence, the probability density function is written by(1)fxi|μ,σ2=2πσ2−1exp−xi−μ22σ2,−∞<xi<∞.And it is defined asX∼Nμ,σ2.The likelihood function has used the multiplication of probability function as follows:(2)Lμ,σ2=∏i=1nfxi|μ,σ2=2πσ2−n/2exp−∑i=1nxi−μ22σ2.From (2), take ln on likelihood function following (3)lnLμ,σ2=−n2ln2π−n2lnσ2−∑i=1nxi−μ22σ2.From (3), differential with respect to parameter σ2,(4)∂∂σ2lnLμ,σ2=−n2σ2+∑i=1nxi−μ22σ22=0.We obtain theσ^2=∑i=1nxi−μ2/n , so this estimator is a biased estimator, but it is a sufficient and consistent estimator. The performance estimator has supported this property such as unbiased estimator, minimum of variance, consistency, and sufficiency. This estimator is adjusted from the maximum likelihood estimator and defined the property as σ^Aj.ML2=∑i=1nxi−μ2/n−1. We know that x¯ is an unbiased estimator, and we get the unbiased estimator in terms of x¯ following σ^Aj.ML2=∑i=1nxi−x¯2/n−1.The confidence interval at1−α100% of σ2 is approximated from σ^Aj.ML2 by using the concept of Chi-squared distribution at degree of freedom n−1 [2] following n−1σ^Aj.ML2/σ2∼χn−12; then it can be rewritten as(5)Pn−1σ^Aj.ML2χα/2,n−12<σ2<n−1σ^Aj.ML2χ1−α/2,n−12=1−α.The code for the maximum likelihood method in R programming language is as follows (the example of 90% confidence interval)> MLE = var(x)> l90_percen=(n − 1)/qchisq(1–0.1/2,n − 1)> u90_percen=(n − 1)/qchisq(0.1/2,n − 1)> LCL90_MLE = MLE∗ l90_percen> UCL90_MLE = MLE∗ u90_percen


## 2.2. Bayesian Approach with Available Prior Distribution

From the maximum likelihood method, we know that the probability density function of random variables is a normal distribution asX∼Nμ,σ2 The estimation of the Bayesian approach is considered by adjusting the parameter of normal distribution by X∼Nμ,ϕ−1, where ϕ−1=σ2 and μ is a constant value; then, the probability distribution function from (1) can be rewritten by(6)fxi|μ,ϕ=ϕ2π1/2exp−ϕ2xi−μ2,−∞<xi<∞.From (2), the likelihood function is changed parameter by (7)Lμ,ϕ=ϕ2πn/2exp−ϕ2∑i=1nxi−μ2.The prior distribution ofϕ is considered in form of a gamma distribution with parameter α,λ denoted by Gammaα,λ or rewritten as(8)gϕ;α,λ=λαΓαϕα−1exp−ϕλ,ϕ>0.The resulting posterior distribution is a gamma distribution that is implied by the conjugate distribution from normal distribution on (6) and gamma distribution on (8) as (9)hϕ|xi∝Lμ,ϕgϕ;α,λ∝ϕ2πn/2exp−ϕ2∑i=1nxi−μ2λαΓαϕα−1exp−ϕλ∝ϕn/2+α−1exp−ϕλ+12∑i=1nxi−μ2.Recognizing that this result is displayed in the form of gamma distribution:(10)hϕ|xi∝ϕA−1exp−ϕB∝BAΓAϕA−1exp−ϕB=GammaA,B,where A=n/2+α and B=λ+1/2∑i=1nxi−μ2. μ is approximated by using x¯; then, it can be rewritten as B=λ+1/2∑i=1nxi−x¯2 [5].With the parameterization, the posterior distribution ofσ2=1/ϕ is fσ2|x1,x2,...,xn∼IGA,B , where IGA,B is called the inverse gamma distribution with parameters A and B .The inverse gamma distribution [20] is the same distribution as the reciprocal of a gamma distribution and the relationship of Y=1/X, X∼Gammaα,λ is defined to the inverse gamma distribution as Y∼IGα,λ. The inverse gamma distribution in the form of random variable Y is written as(11)fYy;α,λ=λαΓαy−α−1e−λ/y,y>00,otherwise.The mean of inverse gamma distribution isEY=λ/α−1, and the variance is VarY=λ2/α−12α−2.A similar way to estimate the variance of the Bayesian method is defined as(12)σ^Bayes2=Eσ2|x1,…,xn=BA−1=λ+1/2∑i=1nxi−x¯2n/2+α−1,and the variance of Bayesian estimator is calculated as(13)Varσ2|x1,...,xn=B2A−12A−2=λ+1/2∑i=1nxi−x¯22n/2+α−12n/2+α−2.To evaluate our proposed method, the prior distribution ofϕ is proposed in the form of gamma distribution with parameters α and λ or denoted by Gammaα,λ. Then, the parameter of gamma distribution is an available prior distribution as the gamma, Chi-squared, and exponential distributions by Gamma2,1, Gamma2,0.5, and Gamma1,0.2, shown in Figure 1.Figure 1
Gamma probability density with parameters (α, λ) as Gamma2,1, Gamma2,0.5, and Gamma1,0.2.From central limit theorem [15] with n⟶∞, it can approximate in the form of standard normal distribution by(14)Z=σ^Bayes2−σ2Varσ2=B/A−1−σ2B2/A−12A−2∼N0,1.This is an asymptotic confidence interval that will only give an approximation as the large sample size, which has better coverage rates for small samples [21].The definition of the confidence interval can be expressed as(15)P−Zα/2≤Z≤Zα/2=1−α.Putting these together, (14) and (15), it is often written as(16)P−Zα2≤B/A−1−σ2B2/A−12A−2≤Zα2=1−α.Then,(17)P−Zα2B2A−12A−2≤BA−1−σ2≤Zα2B2A−12A−2=1−α.The confidence interval at1−α100% of σ2 is approximated by(18)PBA−1−Zα2B2A−12A−2≤σ2≤BA−1+Zα2B2A−12A−2=1−α,where A=n/2+α and B=λ+1/2∑i=1nxi−x¯2.The code of R programming language for the Bayesian approach with available prior distribution is set as the constant values of prior distribution as follows (the example of 90% confidence interval).> lamma_bayes.g = 2; alpha_bayes.g = 1> lamma_bayes.c = 2; alpha_bayes.c = 0.5> lamma_bayes.e = 1; alpha_bayes.e = 0.2> B.g = lamma_bayes.g + var(x) ∗ (n − 1)/2); A.g = alpha_bayes.g + (n/2)> B.c = lamma_bayes.c + (var(x) ∗ (n − 1)/2); A.c = alpha_bayes.c + (n/2)> B.e = lamma_bayes.e + (var(x) ∗ (n − 1)/2); A.e = alpha_bayes.e + (n/2)> Bayes.g = B.g/(A.g − 1); Bayes.c = B.c/(A.c − 1); Bayes.e =B.e/(A.e − 1)> SE_Bayes.g = sqrt((B.g ^ 2)/(((A.g − 1)^2)∗(A.g − 2)))> SE_Bayes.c = sqrt((B.c ^ 2)/(((A.c − 1)^2)∗(A.c − 2)))> SE_Bayes.e = sqrt((B.e ^ 2)/(((A.e − 1) ^ 2)∗(A.e − 2)))> LCL90_Bayes.g = Bayes.g − (qnorm90_percen∗ SE_Bayes.g)> LCL90_Bayes.c = Bayes.c − (qnorm90_percen∗ SE_Bayes.c)> LCL90_Bayes.e = Bayes.e − (qnorm90_percen∗ SE_Bayes.e)> UCL90_Bayes.g = Bayes.g + (qnorm90_percen∗ SE_Bayes.g)> UCL90_Bayes.c = Bayes.c + (qnorm90_percen∗ SE_Bayes.c)> UCL90_Bayes.e = Bayes.e + (qnorm90_percen∗ SE_Bayes.e)


## 2.3. Bayesian Approach with Informative Prior

Evaluation of the suitable value on the prior distribution is an important problem because of the difficulty of estimating parameters via the posterior distribution. The solution problem of available prior information has been developed using a sampling algorithm, such as this Markov Chain Monte Carlo (MCMC) method or called the informative prior. This algorithm of the MCMC method is to draw a random sample from the posterior distribution without the conveniently estimated prior distribution. The process is employed by sampling parameters from the Markov Chain method for estimating parameters on prior distribution by the Gibbs sampling algorithm [10]. Then, the posterior distribution uses a Markov Chain and Gibbs sampling to approximate parameters from the MCMC method. We carry out the rjags package, which provides an interface from R [22] to rjags library to generate a sequence of dependent samples from the posterior distribution. Sampling process from the MCMC method is as follows:(1)
DrawX1,…,Xn from the normal distribution with parameter mean μ and variance σ2.(2)
The parameterμ is generated from the normal distribution and the σ2 is generated from the inverse gamma distribution with parameters a and b.(3)
Set initial valuea0t from an exponential distribution and b0t from the gamma distribution with constant values.(4)
Generateσo2t from the posterior distribution based on the inverse gamma distribution with parameters a0t and b0t for t=1,2,…,T, where T is the number of Gibbs sampling algorithm.(5)
Calculate the mean and standard deviation from the posterior distribution function.For each chain, the first 2000 iterations were discarded, and the last 5000 iterations were used to obtain the posterior distribution of the parameter.Thus, the MCMC estimator isσ^MCMC2=∑t=1Tσ2t/T.The confidence interval is created by computing the mean and the variance from the MCMC process as(19)Eσ^MCMC2=∑t=1Tσ2tTand Varσ^MCMC2=∑t=1Tσ2t−σ^MCMC22T−1.According to the central limit theorem withn⟶∞, we have(20)Z=σ^MCMC2−σ2Varσ2=∑t=1Tσ2t/T−σ2∑t=1Tσ2t−σ^MCMC22/T−1∼N0,1,and P−Zα/2≤Z≤Zα/2=1−α.Therefore,(21)P−Zα/2≤∑t=1Tσ2t/T−σ2∑t=1Tσ2t−σ^MCMC22/T−1≤Zα/2=1−α.Then,(22)P−Zα/2∑t=1Tσ2t−σ^MCMC22T−1≤∑t=1Tσ2tT−σ2≤Zα/2∑t=1Tσ2t−σ^MCMC22T−1=1−α.We say that the confidence interval at1−α100% of σ2 by MCMC at 1−α100% is(23)P∑t=1Tσ2tT−Zα2∑t=1Tσ2t−σ^MCMC22T−1≤σ2≤∑t=1Tσ2tT+Zα2∑t=1Tσ2t−σ^MCMC22T−1=1−α.The “rjags” package in the software R is used to estimate the MCMC estimator and confidence interval following (the example of 90% confidence interval):> library(rjags)> dataset = list(x = x, n = n)> inits = list(mu = 0.01, tau = 0.01)> jagmod < −jags.model(“model_normal.txt,” data = dataset, inits = inits,n.chains = 1, n.adapt = 2000)> update(jagmod, n.iter = 20, progress.bar = “text”)> posterior = coda.samples(jagmod,c(“mu,” “sigma”),n.iter = 5000, progress.bar = “text,” thin = 2)> post = as.data.frame(as.matrix(posterior))> var.mcmc = (post$sigma) ^ 2> mcmc.est = mean(var.mcmc)> SE_MCMC = sd(var.mcmc)> LCL90_mcmc.est = mcmc.est − (qnorm90_percen∗ SE_MCMC)> UCL90_mcmc.est = mcmc.est + (qnorm90_percenv∗ SE_MCMC)


## 2.4. Bayesian Approach with Noninformative Prior

The Bayesian theorem is dependent on the likelihood function and the prior distribution, which is used to calculate the posterior distribution. If the prior distribution defines the prior information, it will approximate the estimator on the posterior distribution. If we have no information on prior distribution, we call it a noninformative prior. Agresti and Coull [19] studied the approximation of the interval estimation of binomial proportions based on inverting the Wald large-sample normal test. Then, we used the Wald confidence intervals to construct the confidence interval of variance. The Fisher information in a single observation is needed as(24)Iσ2=E∂∂σ2lnLμ,σ22=−E∂2∂σ22lnLμ,σ2.From (4) and (24), the Fisher information is defined as(25)Iσ2=−E∂∂σ2−n2σ2+∑i=1nxi−μ22σ22=−En2σ22−2∑i=1nxi−μ22σ23=−n2σ22+E∑i=1nxi−μ2σ23=n2σ22.The asymptotic Wald confidence interval based on the maximum likelihood estimator tends to the central limit theorem as(26)Z=σ^Aj.ML2−σ2Iσ2=σ^Aj.ML2−σ2n/2σ^Aj.ML22∼N0,1,and P−Zα/2≤Z≤Zα/2=1−α.We infer that in large sample,n⟶∞(27)P−Zα2≤σ^Aj.ML2−σ21/σ^Aj.ML2n/2≤Zα2=1−α.The Wald confidence interval at1−α100% of σ2 at 1−α100% is(28)Pσ^Aj.ML2−Zα2σ^Aj.ML22n≤σ2≤σ^Aj.ML2+Zα2σ^Aj.ML22n=1−α.The motivation of noninformative prior is that the fisher information indicates the amount of information by the observation about the parameter. The code for the Bayesian approach with noninformative prior based on Wald method in R programming language is as follows (the example of 90% confidence interval).> LCL90_Wald = MLE − (qnorm90_percen∗ sqrt(2/n) ∗ MLE)> UCL90_Wald = MLE + (qnorm90_percen∗ sqrt(2/n) ∗ MLE).


## 3. Simulation Study

The details of simulated data and the results are stated in this section. The random variableX is generated from a normal distribution with the R program by setting the true parameter as mean μ at 2 and variance σ2 at 2, 6, and 12 as shown in Figure 2.Figure 2
Normal probability density with parameters (μ,σ2) as N2,2, N2,6, and N2,12.The sample sizes (n) are studied at 10 and 30 for small sample sizes, 50 and 100 for moderate sample sizes, and 500 and 1000 for large sample sizes. The estimated confidence intervals are obtained from the maximum likelihood method and Bayesian approach at the confidence interval level 90%, 95%, and 99%. Suppose the estimated confidence intervals cover the true parameter or population variance σ2 as 2, 6, and 12. We will count the number and compute the proportion denoted by the coverage probability (CP). The coverage probability is compared with the fixed confidence interval that we define the significance level at 0.05 (Z0.05/2  = 1.96). If the fixed confidence interval range can cover the coverage probability, we will perform these methods and consider the minimum of the average width. The average width of a confidence interval is evaluated by computing the average of the difference values between the upper limit and lower limit. Hence, the coverage probability covers the range of the fixed confidence interval by computing(29)P0−Zα/2P01−P010,000≤CP≤P0+Zα/2P01−P010,000.In this case, we defineP0  = 0.9, 0.95, and 0.99 that followed the level of confidence interval 90%, 95%, and 99%. The range of the fixed confidence interval is shown in Table 1.Table 1
The range of the fixed confidence interval depended onP0.
P0The range of the fixed confidence interval0.90(0.8941, 0.9058)0.95(0.9457, 0.9542)0.99(0.9880, 0.9919)The R program generates data and estimates confidence intervals at 10,000 replications in each situation. The estimating confidence intervals of variance by Maximum Likelihood (ML), Bayesian approach with available prior distribution (gamma, Chi-squared, and exponential distributions), informative prior distribution (MCMC method), and noninformative prior distribution (Wald confidence interval) in Tables2–4. The first column shows the true variance parameter, and the second column demonstrates the several sample sizes. The coverage probability (CP) and average width (AW) are presented in the following twelve columns for these methods. The minimizing AW values illustrate the performance of these methods in the form of underline AW values. However, some AW values are shown blank because the coverage probability is not in the range of the fixed confidence interval from Table 1. By observing the CP and AW, the results appear as follows.Table 2
The coverage probability (CP) and average width (AW) via 90% confidence interval.
σ2nMLBayesian approach with prior distributionMCMCWaldGammaChi-squaredExponentialCPAWCPAWCPAWCPAWCPAWCPAW2100.90254.3450.9456—0.9373—0.9512—0.9480—0.8196—500.89941.4070.9112—0.9220—0.9140—0.9151—0.8810—1000.89860.9610.9084—0.9116—0.9097—0.9098—0.8924—3000.8930—0.89620.5400.89810.5430.89700.5430.89580.5450.8904—5000.89970.4190.90190.4170.90230.4190.90210.4190.90110.4200.89900.41610000.90410.2950.90520.2940.90530.2950.90520.2950.90420.2950.90280.2946100.902513.030.8522—0.904411.320.9094—0.9480—0.8196—500.89944.2220.8878—0.90214.1170.90504.1670.9151—0.8810—1000.89862.8850.89582.8070.90312.8490.90492.8660.9083—0.8924—3000.8930—0.8924—0.89421.6230.89501.6260.89521.6350.8904—5000.89971.2570.89951.2500.90101.2540.90111.2550.90181.2600.89901.24810000.90410.8850.90270.8830.90400.8840.90450.8850.90470.8860.90280.88212100.902526.070.8229—0.8812—0.898224.050.9496—0.8196—500.89948.4460.8811—0.8974—0.90188.3050.9157—0.8810—1000.89865.7710.8915—0.90095.6800.90315.7230.9089—0.8924—3000.8930—0.8916—0.8932—0.89443.2500.89553.1710.8904—5000.89972.5140.89882.4990.90062.5060.90102.5100.90112.5250.89902.49710000.90411.7710.90231.7660.90371.7680.90391.7700.90431.7730.90281.765Note. The appearance in AW denotes CP in the range of the fixed confidence interval between 0.8941 and 0.9058 and italics minimum of AW.Table 3
The coverage probability (CP) and average width (AW) via 95% confidence interval.
σ2nMLBayesian approach with prior distributionMCMCWaldGammaChi-squaredExponentialCPAWCPAWCPAWCPAWCPAWCPAW2100.95065.7140.9657—0.9832—0.9669—0.9628—0.8538—500.95311.7060.95171.6280.9614—0.9554—0.9568—0.9256—1000.94801.1550.94951.1290.95371.1470.95001.1460.95111.1590.9381—3000.94670.6490.94700.6440.94950.6470.94750.6470.94790.6490.9404—5000.95100.5000.95050.4980.95050.4990.95040.4990.95050.5000.94830.49610000.95040.3520.95160.3510.95190.3510.95170.3510.95060.3520.95000.3506100.950617.140.8865—0.9307—0.9346—0.9617—0.8538—500.95315.1180.9297—0.9442—0.94664.9650.9562—0.9256—1000.94803.4670.9397—0.94573.3950.94763.4150.95113.4770.9381—3000.94671.9470.9415—0.9445—0.9454—0.94781.9490.9404—5000.95101.5000.94951.4900.94961.4940.94991.4960.95091.5010.94831.48810000.95041.0560.95001.0520.95111.0540.95151.0540.95071.0560.95001.05112100.950634.280.8607—0.9081—0.9241—0.9627—0.8538—500.953110.230.9246—0.9384—0.9438—0.9567—0.9256—1000.94806.9340.9379—0.9434—0.94596.8200.95116.9570.9381—3000.94673.8940.9401—0.9435—0.9444—0.94823.8980.9404—5000.95103.0010.94892.9780.94962.9870.94982.9910.95113.0030.94832.97610000.95042.1120.94882.1040.95082.1070.95122.1090.95152.1130.95002.103Note. The appearance in AW denotes CP in the range of the fixed confidence interval between 0.9457 and 0.9542 and italics minimum of AW.Table 4
The coverage probability (CP) and average width (AW) via 99% confidence interval.
σ2nMLBayesian approach with prior distributionMCMCWaldGammaChi-squaredExponentialCPAWCPAWCPAWCPAWCPAWCPAW2100.99139.6020.9841—0.9949—0.9826—0.9771—0.9000—500.99072.3380.9825—0.9868—0.9834—0.9838—0.9697—1000.98961.5500.9849—0.9862—0.9852—0.9856—0.9774—3000.98880.8580.9862—0.98670.5430.98650.5430.98590.5450.9848—5000.99050.6600.98950.6540.98990.6560.98970.6560.98970.6570.98830.65110000.98860.4630.98920.4610.98930.4620.98910.4620.98950.4620.98880.4606100.991328.800.9321—0.9629—0.9636—0.9765—0.9000—500.99077.0140.9718—0.9793—0.9802—0.9840—0.9697—1000.98964.6510.9783—0.9824—0.9836—0.9856—0.9774—3000.98881.9470.9850—0.9861—0.9860—0.9864—0.9848—5000.99051.9800.98821.9580.98941.9640.98951.9660.98961.9730.98831.95510000.98861.3910.98881.3830.98931.3850.98921.3860.98871.3880.98881.38212100.991357.610.9096—0.9476—0.9561—0.9766—0.9000—500.990714.020.9687—0.9765—0.9793—0.9839—0.9697—1000.98969.3030.9765—0.9813—0.9824—0.9853—0.9774—3000.98885.1530.9846—0.9857—0.9860—0.9869—0.9848—5000.99053.9600.9876—0.98903.9250.98933.9310.9903.9460.99833.91110000.98862.7820.98302.7650.98922.7700.98932.7720.98952.7780.98882.765Note. The appearance in AW denotes CP in the range of the fixed confidence interval between 0.9880 and 0.9919 and italics minimum of AW.Simulation results in Table2 show that the maximum likelihood (ML) method has a reasonable coverage probability for small sample sizes. Nevertheless, the Bayesian approach with prior distribution in gamma, chi-squared, and exponential distributions presents the most minimum AW, especially with moderate sample sizes. For large sample sizes, the Wald confidence interval has a good performance. Furthermore, the AW is shown to decrease as sample sizes increase. The CP of all methods is represented in Figure 3.Figure 3
The trend of CP for all methods varies by the sample sizes at 90% confidence interval. (a) Variance = 2. (b) Variance = 4. (c) Variance = 12.
(a)(b)(c)From Figure3, the CP values of ML and Wald present the exact value of all variances for each sample size and play in the range of the fixed confidence interval. The CP of Wald tends to increase when sample sizes increase. However, the MCMC method decreases when sample sizes increase. All methods fall in the range following the increasing sample sizes. When the variance increases in Figure 4, the CP is shown the slightly different in large sample sizes.Figure 4
The trend of CP for all methods varies by variance at 90% confidence interval. (a)n = 10. (b) n = 50. (c) n = 100. (d) n = 300. (e) n = 500. (f) n = 1000.
(a)(b)(c)(d)(e)(f)In Table3, the ML and Bayesian approach results with available prior distribution are similar to those in Table 2. However, the ML method shows the minimum AW in large variance at n = 300. The trends of CP of all methods are presented in Figure 5.Figure 5
The trend of CP for all methods varies by the sample sizes at 95% confidence interval. (a) Variance = 2. (b) Variance = 4. (c) Variance = 12.
(a)(b)(c)In Figure5, the CP values of the Bayesian approach of gamma, Chi-squared, exponential distributions, and Wald trend to increase when the sample sizes also increase. Furthermore, when the variance increases in Figure 6, there is no affectation on the CP.Figure 6
The trend of CP for all methods varies by variance at 95% confidence interval. (a)n = 10. (b) n = 50. (c) n = 100. (d) n = 300. (e) n = 500. (f) n = 1000.
(a)(b)(c)(d)(e)(f)From Table4, it is shown that the AW of ML has the minimum at small and moderate sample sizes. When the sample sizes are larger, the Wald has a good performance. The CP of all methods is presented in Figure 7.Figure 7
The trend of CP for all methods varies by the sample sizes at 99% confidence interval. (a) Variance = 2. (b) Variance = 4. (c) Variance = 12.
(a)(b)(c)Figure7 shows that the CP values of ML are in the range of the fixed confidence interval. For the large sample sizes and variances, the CP values of all methods are in the range of the fixed confidence interval shown in Figure 8.Figure 8
The trend of CP for all methods varies by variance at 99% confidence interval. (a)n = 10. (b) n = 50. (c) n = 100. (d) n = 300. (e) n = 500. (f) n = 1000.
(a)(b)(c)(d)(e)(f)


## 4. Application in Real Data

The real data are collected from the airborne particulate matter 2.5 (PM 2.5: mg/m3) from the air monitoring quality station of Bansomdejchaopraya Rajabhat University, Bangkok, Thailand, from April 1, 2019, to 2022. These data were obtained from Thailand’s Pollution Control Department (https://www.aqmthai.com) and used 10–1000 records for computing the confidence interval of variance. The distributions of PM 2.5 were presented in Figure 9, which showed the right skewness for the large sample sizes. Thus, the Shapiro–Wilk test was used to test the normal distribution of such data. From the p-values, it was evident that the sample sizes (10, 50, and 100) confirmed normal distribution except for the large sample sizes (300, 500, and 1000). Moreover, normal Q-Q plots were constructed to show the normal distributions from the six sample sizes (Figure 10), which verified that the small sample sizes followed the normal distribution. Table 5 reported the interval width of 90%, 95%, and 99% confidence interval for the airborne particulate matter 2.5 (PM 2.5: mg/m3).Figure 9
The density of daily PM 2.5 in the six sample sizes.Figure 10
The normal Q-Q plots of daily PM 2.5 in the six sample sizes.Table 5
The interval width via 90%, 95%, and 99% confidence interval.
Confidence Interval Level (%)nInterval width of methodsMLBayes’ with prior distributionMCMCWaldGammaChi-squaredExponential901030.48631.33437.21941.26854.13347.7415065.14665.21367.24968.49372.370102.01910062.38062.40263.35663.93165.35197.68630043.65543.16543.38253.51243.02643.16150033.65233.42533.52633.58534.60733.423100026.15426.06626.10526.12826.06526.002951036.32637.33744.35049.17364.50359.2605077.62777.70780.13281.61486.23584.66510074.33074.35675.49476.17877.87177.57930052.16251.43451.69351.84751.26951.43050040.16539.82839.94840.02041.23739.826100031.19031.05931.10631.13430.98430.059991047.74149.06958.28664.62584.77299.59050102.019102.124105.311107.260113.332116.03210097.68697.72199.215100.116102.340104.07530069.01867.59767.93768.13967.37967.59050053.00152.34452.50152.59554.19452.341100041.07440.81940.88040.91740.72040.018Note. The shortest interval width is shown in bold font.The results show that the 10, 50, and 100 sample sizes of the maximum likelihood (ML) method had the shortest interval width, which corresponds with the simulation results. For the large sample sizes (500 and 1000), the Wald method attended the shortest interval width, similar to the simulation results. Furthermore, the MCMC method shows the shortest of 300 sample sizes. Therefore, it is a good choice for constructing the confidence interval when the data set supports a nonnormal form.


## 5. Conclusion

In this research, we have concentrated on estimating the confidence interval of variance via normal distribution by using maximum likelihood and the Bayesian approach. The coverage probability and average width are the criteria for the efficient method. Through a simulation study, the maximum likelihood method performs a reasonable method in small sample sizes following the Chi-squared distribution that creates the confidence interval (see [14]). The Bayesian approach depends on the gamma, Chi-squared, and exponential prior distribution, making a suitable performance method in moderate sample sizes. The Wald confidence is a reasonable working method for the large sample sizes in all cases. In particular, the CP of the Wald interval is such low values for the small sample sizes, but the large sample sizes converge into the range. Surprisingly, the MCMC method is weak even though the estimator obtains from the sampling algorithm. However, approximate results benefit normal distribution because of the inherent evolution of exact distribution. Form real data, the airborne particulate matter 2.5 is collected to estimate the confidence interval. It is clear from the results that the maximum likelihood and Wald methods are the reasonable working methods in small and large sample sizes, same as the simulation data set.



---

*Source: 8043260-2022-08-27.xml*