|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: Generating a bounded AR(1) series for Monte-Carlo Simulation
Dear Statalisters
I have a puzzle, concerning a section of a program intended to generate an
AR(1) series for `aid' that is bounded between 0 and 0.3
Prior to this section of the program, I have already generated countries,
time (and xtset the data) and a variable `aid' consisting of random draws
from a uniform distribution on [0,0.3] - all but the first observation of
which for each country, I wish to replace, using the following code:
if year>1 {
if L.aid<0 {
replace aid=const+`rho'*L.aid+rnormal(0.1,0.01)
}
else if L.aid>0.3 {
replace aid=const+`rho'*L.aid+rnormal(-0.1,0.01)
}
else {
replace aid=const+`rho'*L.aid+(rnormal()/100)
}
}
I expect this code to do the following: whenever aid wanders beyond the
bounds 0 and 0.3, the shock in the next period is set to bounce it away
from these bounds. Hence I would expect to see observations of aid that do
stray beyond 0 and 0.3 but which bounce back in the subsequent period. My
puzzle is that when I run this code with large T, the aid series never
strays beyond bounds. By my understanding, that shouldn't be happening.
I would actually like to write a program such that aid never strays beyond
bounds, but I didn't know how to; I appear to have done so inadvertently,
but the fact I don't understand what it's doing makes me fear I've gone
totally wrong.
I apologise if I'm missing something obvious; this is my first ever attempt
at programming.
This is on Stata/IC 10.1 for Windows
----------------------
Paddy Carter
Department of Economics
University of Bristol
[email protected]
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/