This main repository contains three branches aimed at providing a methodology to estimate the shape parameters of the Beta distribution.
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.
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"))
To run the designed algorithms, follow these steps:
Clone this repository:
git clone https://github.com/LLerzy/Estimation-Parameter-Beta/tree/main.git
Open the R script in any compatible Integrated Development Environment (IDE):
requiredfunctions.R
.You can run the script and load all the functions with the following command:
Rscript requiredfunctions.R
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.The following branches are available in this repository:
Contributions are welcome! Please submit a pull request or open an issue if you have any suggestions or improvements.