Title: | Estimates Moments for a Truncated Normal Distribution using 'Stan' |
Version: | 0.0.3 |
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. |
URL: | https://github.com/mathurlabstanford/truncnormbayes, https://mathurlabstanford.github.io/truncnormbayes/ |
BugReports: | https://github.com/mathurlabstanford/truncnormbayes/issues |
License: | GPL (≥ 3) |
Encoding: | UTF-8 |
RoxygenNote: | 7.2.3 |
Biarch: | true |
RdMacros: | Rdpack |
Depends: | R (≥ 3.4.0) |
Imports: | methods, Rcpp (≥ 0.12.0), RcppParallel (≥ 5.0.1), Rdpack, rstan (≥ 2.18.1), rstantools (≥ 2.2.0), stats |
LinkingTo: | BH (≥ 1.66.0), Rcpp (≥ 0.12.0), RcppEigen (≥ 0.3.3.3.0), RcppParallel (≥ 5.0.1), rstan (≥ 2.18.1), StanHeaders (≥ 2.18.0) |
Suggests: | testthat (≥ 3.0.0), truncnorm (≥ 1.0), withr (≥ 2.5.0) |
Config/testthat/edition: | 3 |
SystemRequirements: | GNU make |
NeedsCompilation: | yes |
Packaged: | 2023-08-23 02:06:23 UTC; root |
Author: | Mika Braginsky [aut],
Leon Tran [aut],
Maya Mathur [ctb],
Peter Solymos |
Maintainer: | Peter Solymos <peter@analythium.io> |
Repository: | CRAN |
Date/Publication: | 2023-08-23 07:30:02 UTC |
truncnormbayes: 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.
Author(s)
Maintainer: Peter Solymos peter@analythium.io (ORCID) [contributor]
Authors:
Mika Braginsky mika.br@gmail.com
Leon Tran leontk@stanford.edu
Other contributors:
Maya Mathur mmathur@stanford.edu [contributor]
References
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.
See Also
Useful links:
Report bugs at https://github.com/mathurlabstanford/truncnormbayes/issues
Estimate truncated normal distribution
Description
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).
Usage
trunc_est(x, a, b, mu_start = 0, sigma_start = 1, ci_level = 0.95, ...)
Arguments
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 |
Value
A list with two elements:
- stats
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
.- fit
A
stanfit
object (the result of fitting the model).
References
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.
Examples
set.seed(22)
x <- truncnorm::rtruncnorm(100, a = -1, b = 2, mean = 0.5, sd = 0.5)
trunc_est(x, a = -1, b = 2)