Highest Posterior Density Region and Central Credible Region

前端 未结 7 1021
情深已故
情深已故 2021-01-31 09:36

Given a posterior p(Θ|D) over some parameters Θ, one can define the following:

Highest Posterior Density Region:

The Highest Posterior Density Region

7条回答
  •  闹比i
    闹比i (楼主)
    2021-01-31 10:06

    In R you can use the stat.extend package

    If you are dealing with standard parametric distributions, and you don't mind using R, then you can use the HDR functions in the stat.extend package. This package has HDR functions for all the base distributions and some of the distributions in extension packages. It computes the HDR using the quantile function for the distribution, and automatically adjusts for the shape of the distribution (e.g., unimodal, bimodal, etc.). Here are some examples of HDRs computed with this package for standard parametric distributions.

    #Load library
    library(stat.extend)
    
    #---------------------------------------------------------------
    #Compute HDR for gamma distribution
    HDR.gamma(cover.prob = 0.9, shape = 3, scale = 4)
    
            Highest Density Region (HDR) 
     
    90.00% HDR for gamma distribution with shape = 3 and scale = 4 
    Computed using nlm optimisation with 6 iterations (code = 1) 
    
    [1.76530758147504, 21.9166988492762]
    
    #---------------------------------------------------------------
    #Compute HDR for (unimodal) beta distribution
    HDR.beta(cover.prob = 0.9, shape1 = 3.2, shape2 = 3.0)
    
            Highest Density Region (HDR) 
     
    90.00% HDR for beta distribution with shape1 = 3.2 and shape2 = 3 
    Computed using nlm optimisation with 4 iterations (code = 1) 
    
    [0.211049233508331, 0.823554556452285]
    
    #---------------------------------------------------------------
    #Compute HDR for (bimodal) beta distribution
    HDR.beta(cover.prob = 0.9, shape1 = 0.3, shape2 = 0.4)
    
            Highest Density Region (HDR) 
     
    90.00% HDR for beta distribution with shape1 = 0.3 and shape2 = 0.4 
    Computed using nlm optimisation with 6 iterations (code = 1) 
    
    [0, 0.434124342324438] U [0.640580807770818, 1]
    

提交回复
热议问题