Modified UhligAccept

Use this forum to post complete RATS "procedures". Please be sure to include instructions on using the procedure and detailed references where applicable.

Modified UhligAccept

Postby jonasdovern » Tue Mar 29, 2011 10:39 am

I modified the UhligAccept function to be able to provide different number of periods for the constrains for different variables.

I know that this is done also in a lot of papers that are around; thus, it might be helpful for some RATS users.

Code: Select all
**************************************************************************
* UhligAccept2(q,first,last,constrained) returns a 1 (accept) or 0
* (reject) for the weight vector <<q>> (applied to the impulse responses
* in the global RECT[SERIES] impulses). <<first>> and <<last>> are the
* range of responses constrained (1 = impact response). <<constrained>>
* is a VECT[INTEGER] with the variable positions being constrained. Use
* +slot for a positivity constraint and -slot for a negativity
* constraint. That is, if you want the first 4 responses to be positive
* on the 2nd variable and the first 3 negative on the 3rd, you would use the function
*
* UhligAccept2(q,||1,1||,||4,3||,||2,-3||)
*
* If this returns 0, you would reject the draw, as not meeting the
* constraints.
*
function UhligAccept2 q first last constrained
type integer   UhligAccept2
type vector    *q
type vec[int]  first last
type vect[int] constrained
*
local integer      i k
local vector       ik
dec   rect[series] impulses
*
if %rows(first)<>%rows(constrained).or.%rows(last)<>%rows(constrained) {
   disp "Error. Dimensions do not match!"
   return
}
do i=1,%rows(constrained)
   do k=first(i),last(i)
         compute ik=%xt(impulses,k)*q
         if constrained(i)<0
            compute value= ik(-constrained(i))
         else
            compute value=-ik(constrained(i))
         if value>0.0 {
            *
            * If we fail on the first slot being checked, just flip the sign
            * of q and ik and continue.
            *
            if k==first(i).and.i==1
               compute q=-1.0*q,ik=-1.0*ik
            else {
               compute UhligAccept2=0
               return
            }
         }
      end do k
end do i
compute UhligAccept2=1
end
**************************************************************************
jonasdovern
 
Posts: 68
Joined: Sat Apr 11, 2009 10:30 am

Return to RATS Procedures

Who is online

Users browsing this forum: No registered users and 2 guests