Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

rtrun

Draw from Truncated Univariate Normal


Description

rtrun draws from a truncated univariate normal distribution.

Usage

rtrun(mu, sigma, a, b)

Arguments

mu

mean

sigma

standard deviation

a

lower bound

b

upper bound

Details

Note that due to the vectorization of the rnorm and qnorm commands in R, all arguments can be vectors of equal length. This makes the inverse CDF method the most efficient to use in R.

Value

Draw (possibly a vector)

Warning

This routine is a utility routine that does not check the input arguments for proper dimensions and type.

**Note also that rtrun is currently affected by the numerical accuracy of the inverse CDF function when trunctation points are far out in the tails of the distribution, where “far out” means |a - μ| / σ > 6 and/or |b - μ| / σ > 6. A fix will be implemented in a future version of bayesm.

Author(s)

Peter Rossi, Anderson School, UCLA, perossichi@gmail.com.

References

For further discussion, see Chapter 2, Bayesian Statistics and Marketing by Rossi, Allenby, and McCulloch.
http://www.perossi.org/home/bsm-1

Examples

set.seed(66)
rtrun(mu=c(rep(0,10)), sigma=c(rep(1,10)), a=c(rep(0,10)), b=c(rep(2,10)))

bayesm

Bayesian Inference for Marketing/Micro-Econometrics

v3.1-4
GPL (>= 2)
Authors
Peter Rossi <perossichi@gmail.com>
Initial release
2019-10-14

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.