trunc_est: Estimate truncated normal distribution

View source: R/models.R

trunc_estR Documentation

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 rstan::sampling().

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

\insertRef

zhou2014truncnormbayes

\insertRef

stan2022truncnormbayes

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)

truncnormbayes documentation built on Aug. 23, 2023, 9:06 a.m.