Skip to content

This repository contains the code for estimating the shape parameters of the Beta distribution using a Bayesian approach. It includes implementations of Bayesian techniques, such as empirical and subjective methods.

Notifications You must be signed in to change notification settings

LLerzy/Estimation-Parameter-Beta

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 

Repository files navigation

Posterior Estimation of the Shape Parameters of the Beta Distribution

This main repository contains three branches aimed at providing a methodology to estimate the shape parameters of the Beta distribution.

Table of Contents

Overview

This repository presents a set of functions designed to estimate, from a Bayesian approach, the shape parameters of the Beta distribution, whose density function is:

$$f_X(x|\alpha,\beta)=\dfrac{1}{beta(\alpha,\beta)}x^{\alpha-1}(1-x)^{\beta-1};\hspace{1cm}x\in[0,1],$$

where $beta(\alpha,\beta)$ is the Beta function, and $\alpha>0$ and $\beta>0$. For the shape parameters $(\alpha,\beta)$, a new bivariate distribution is used, for which the joint moments have been analytically derived. A sampling algorithm has been designed, the convergence of various chains generated by this algorithm has been monitored, and a simulation study has been carried out considering different scenarios for the shape parameters.

Installation

To run the code, you need to have R installed with the following packages:

  • ggplot2
  • gridExtra
  • tidyr
  • plotly
  • coda
  • foreach
  • doParallel
  • betafunctions
  • openxlsx
  • xtable

You can install the required packages using the following command:

install.packages(c("ggplot2", "gridExtra", "tidyr","plotly","coda","foreach","doParallel","betafunctions","openxlsx","xtable"))

Usage

To run the designed algorithms, follow these steps:

  1. Clone this repository:

    git clone https://github.com/LLerzy/Estimation-Parameter-Beta/tree/main.git
  2. Open the R script in any compatible Integrated Development Environment (IDE):

    • For the script that contains the main functions in the shape parameter estimation process, refer to requiredfunctions.R.
  3. You can run the script and load all the functions with the following command:

    Rscript requiredfunctions.R

Included Functions

The functions defined in the requiredfunctions.R script include:

  • Prior: Defines the proposed prior probability density function, referred to as combination 1 in the New-Biv-Dist branch.
  • FC_X1_Given_v: Full conditional distribution of $X_1$ given $X_2 = v$.
  • Graph_Fc_X1: Plots the full conditional distribution for given parameter values.
  • Gen_FC_X1_X2: Metropolis-Hastings algorithm with random walk to generate samples from the full conditional distribution.
  • Mon_Measure: Monitors acceptance rates and ESS (effective sample size) for different values of $v$ and precision.
  • Mon_R_Hat: Monitors the Gelman-Rubin diagnostic ($R$-hat) for different values of $v$ and precision.
  • Graphs: Generates histograms, density plots, trace plots, and convergence diagnostics using averages.
  • Gen_Joint_Dist: Gibbs sampling to generate samples from the joint distribution of the random vector $(X_1,X_2)$.
  • Mtovar_vs2: Generalizes Tovar’s method to obtain hyperparameter values.
  • Mom_Prior_Dist: Computes the joint moments of order $l$ for the proposed prior distribution.
  • Measure_Diagnostic: Compares analytical and numerical results for user-provided data samples.
  • Measure_Analy: Computes the analytical results for the proposed prior distribution.
  • Hyperparameters: Obtains hyperparameter values using empirical and subjective Bayesian approaches.
  • Est_Post: Posterior estimation of the Beta distribution's shape parameters $\alpha$ and $\beta$ using importance sampling.
  • Sim_study: Conducts simulation studies to compare posterior estimates using different hyperparameters and sample sizes.
  • Individual_Graphs: Creates individual graphs to monitor posterior estimates using bias and MSE as indicators.
  • Comparison_Hyper: Compares joint density functions for different sets of hyperparameters.

Notes:

  • It is recommended to review and adapt each function according to the specific needs of each analysis.
  • Make sure you understand each function before using it to ensure accurate results and avoid potential errors.

Branches

The following branches are available in this repository:

  • New-Biv-Dist: Presents numerically approximated characteristics for seven of the 25 proposed probability distributions representing the random behavior of the Beta distribution’s shape parameters. Additionally, some numerical and theoretical approximations for combination 1 are compared.
  • Algorithm-Sim-Samples: Monitors the convergence of chains generated by an algorithm using MCMC methods to generate random samples from a new proposed probability distribution, referred to as combination 1 in the New-Biv-Dist branch.
  • Post-Estimate: Conducts a simulation study to estimate the shape parameters of the Beta distribution. This study involves: two questions that can be used in an elicitation process, hyperparameter determination methods, three scenarios for the shape parameters, hypothetical expert information with different levels of bias, and graphs comparing posterior estimators through mean estimation, bias, mean squared error, coverage probability, and average length.

Contributions

Contributions are welcome! Please submit a pull request or open an issue if you have any suggestions or improvements.

About

This repository contains the code for estimating the shape parameters of the Beta distribution using a Bayesian approach. It includes implementations of Bayesian techniques, such as empirical and subjective methods.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages