Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Imposing truncated normal distribution on intervals


From   "Reza Daniels" <[email protected]>
To   <[email protected]>
Subject   st: Imposing truncated normal distribution on intervals
Date   Wed, 23 May 2007 17:03:28 +0200

Dear Statalisters,

I have income data in categories. I want to impose a truncated normal
distribution onto the (log transformed) values within the bounds of the
categories ordered from lowest to highest. I can work out how to do this
by imposing a uniform distribution within the bounds, but I cannot work
out the code for a truncated normal distribution.

Let me give an example: Firstly, let the variable for income category
be "ycat". Let it take on 3 values, and they can be anything (e.g. ycat
== 1 => income between 0 and $10,000; ycat == 2 => income between
$10,001=$100,000;  ycat == 3 => income between $100,000 and $500,000).
This is hypothetical and simplifies the problem.

The code for the uniform would be something similar to the following.
Let ycat_max be the upper bound of each interval and ycat_min be the
lower bound. Then the following operations give me my income  variable
with a uniform distribution within each interval:

==========

forval i = 1 / 3 {
gen u`i' = uniform() if ycat==`i'
}

gen ycat_uniform=.
forval i= 1 / 3 {
replace ycat_uniform = ycat_min + (ycat_max - ycat_min) * u`i' if ycat
== `i'
}

==========

Any assistance with the code for the truncated normal would be greatly
appreciated.

Thanks,
Reza


*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index