draw from truncated normal
-
PTillmann-436
- Posts: 20
- Joined: Mon Dec 03, 2012 11:51 pm
draw from truncated normal
Dear all,
I want to draw a latent variable from a truncated normal. Here I repeat the crucial commands. First, I specifiy two policy actions, easing and tightening:
set easing= loose ==1.0
set tighhtening= tight ==-1.0
set ystar = %if(tightening,-1.0,%if(easing,1.0,0.0))
The latent variable should be above 1 for easing, below -1 for tightening and between 1 and -1 otherwise:
compute ystar(time)=%if(easing(time),%rantruncate(cmean,cstddev,1.0,%na),$
%if(tightening(time),%rantruncate(cmean,cstddev,%na,-1.0),$
%rantruncate(cmean,cstddev,-1.0,1.0)))
The problem is that the estimated ystar is never below -1 despite several tightening observations. Where is the flaw?
Thanks a lot for your help.
I want to draw a latent variable from a truncated normal. Here I repeat the crucial commands. First, I specifiy two policy actions, easing and tightening:
set easing= loose ==1.0
set tighhtening= tight ==-1.0
set ystar = %if(tightening,-1.0,%if(easing,1.0,0.0))
The latent variable should be above 1 for easing, below -1 for tightening and between 1 and -1 otherwise:
compute ystar(time)=%if(easing(time),%rantruncate(cmean,cstddev,1.0,%na),$
%if(tightening(time),%rantruncate(cmean,cstddev,%na,-1.0),$
%rantruncate(cmean,cstddev,-1.0,1.0)))
The problem is that the estimated ystar is never below -1 despite several tightening observations. Where is the flaw?
Thanks a lot for your help.
Re: draw from truncated normal
You clearly left out a bunch of code that might be important. The following seems to work fine:
Is it possible that you don't have the loop over TIME set up properly?
Code: Select all
set loose 1 500 = %ranflip(.1)
set tight 1 500 = %if(.not.loose,-%ranflip(.1),0.0)
set easing = loose==1.0
set tightening = tight ==-1.0
*
compute cmean=0.0,cstddev=2.0
*
clear ystar
*
do time=1,500
compute ystar(time)=%if(easing(time),%rantruncate(cmean,cstddev,1.0,%na),$
%if(tightening(time),%rantruncate(cmean,cstddev,%na,-1.0),$
%rantruncate(cmean,cstddev,-1.0,1.0)))
end do time
-
PTillmann-436
- Posts: 20
- Joined: Mon Dec 03, 2012 11:51 pm
Re: draw from truncated normal
Dear Tom,
Thanks for your prompt response. I am trying to generalize the codes for Dueker's Qual VAR from binary data to three alternative realizations.
Thanks again!
Thanks for your prompt response. I am trying to generalize the codes for Dueker's Qual VAR from binary data to three alternative realizations.
Thanks again!
Re: draw from truncated normal
Are you sure you have data points where tightening is non-zero and easing is zero, that is, have you checked whether the part of the program that's setting up your dummies is correct?
-
PTillmann-436
- Posts: 20
- Joined: Mon Dec 03, 2012 11:51 pm
Re: draw from truncated normal
I think it is now working (see graph). The tightening/easing periods are observed and plotted as shaded areas. The VAR-part seems to add little information as the latent variable mostly reflects the +1/-1 dummies, but at least the code seems to work.
- Attachments
-
- Graph.pdf
- (11.56 KiB) Downloaded 794 times