Title: | Estimates Moments for a Truncated Normal Distribution using 'Stan' |
---|---|
Description: | Finds the posterior modes for the mean and standard deviation for a truncated normal distribution with one or two known truncation points. The method used extends Bayesian methods for parameter estimation for a singly truncated normal distribution under the Jeffreys prior (see Zhou X, Giacometti R, Fabozzi FJ, Tucker AH (2014). "Bayesian estimation of truncated data with applications to operational risk measurement". <doi:10.1080/14697688.2012.752103>). This package additionally allows for a doubly truncated normal distribution. |
Authors: | Mika Braginsky [aut], Leon Tran [aut], Maya Mathur [ctb], Peter Solymos [cre, ctb] |
Maintainer: | Peter Solymos <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.0.3 |
Built: | 2024-10-12 05:57:25 UTC |
Source: | https://github.com/mathurlabstanford/truncnormbayes |
Estimates the posterior modes for the mean (mu) and standard deviation (sigma) of the underlying normal distribution, given truncated data with known truncation point(s).
trunc_est(x, a, b, mu_start = 0, sigma_start = 1, ci_level = 0.95, ...)
trunc_est(x, a, b, mu_start = 0, sigma_start = 1, ci_level = 0.95, ...)
x |
Vector of observations from truncated normal. |
a |
Left truncation limit. |
b |
Right truncation limit. |
mu_start |
Initial value for mu. |
sigma_start |
Initial value for sigma. |
ci_level |
Confidence level of the interval – gives a 100*ci_level% symmetric HPD interval (defaults to 95%). |
... |
Parameters to pass to |
A list with two elements:
A data frame with two rows and the columns param
(mu
, sd
), mode
(posterior mode),
mean
(posterior mean), median
(posterior median), se
(standard error),
ci_lower
(lower CI bound), ci_upper
(upper CI bound), rhat
.
A stanfit
object (the result of fitting the model).
Zhou X, Giacometti R, Fabozzi FJ, Tucker AH (2014). “Bayesian estimation of truncated data with applications to operational risk measurement.” Quantitative Finance, 14(5), 863–888. doi:10.1080/14697688.2012.752103.
Stan Development Team (2022). “RStan: the R interface to Stan.” R package version 2.21.5. https://mc-stan.org.
set.seed(22) x <- truncnorm::rtruncnorm(100, a = -1, b = 2, mean = 0.5, sd = 0.5) trunc_est(x, a = -1, b = 2)
set.seed(22) x <- truncnorm::rtruncnorm(100, a = -1, b = 2, mean = 0.5, sd = 0.5) trunc_est(x, a = -1, b = 2)