Identifier LAGS is Not Recognizable

Use this forum to post questions about syntax problems or general programming issues. Questions on implementing a particular aspect of econometrics should go in "Econometrics Issues" below.

Identifier LAGS is Not Recognizable

Postby atjanke » Wed Mar 16, 2011 10:28 am

Hi Everyone,

I am new to this board, RATS and time series generally. I am trying to write a very simple (practice) procedure which gives me the statistics of a series restricted depending on previous values. So, I want my procedure to tell me the statistics of a series if I restrict the series to the observations which are preceded by two periods of values greater than zero (for example).

I am getting this error which I try to source the code file:

## SX11. Identifier LAGS is Not Recognizable. Incorrect Option Field or Parameter Order?
>>>> if 2==lags<<<<

I've spent some time pouring over the User Guide and Reference Manual, but can't seem to find the problem. I want to be able to use 'series' and 'lags' in the code. Hope you can help. Thanks.

Code: Select all
procedure unit series
type series series
local series
OPTION INTEGER lags
OPTION REAL shock 0
set first = %if(series{1}>shock,1,0)
set second = %if(series{2}>shock,1,0)
set third = %if(series{3}>shock,1,0)
set fourth = %if(series{4}>shock,1,0)
set fifth = %if(series{5}>shock,1,0)
set sixth = %if(series{6}>shock,1,0)
set seventh = %if(series{7}>shock,1,0)
set eighth = %if(series{8}>shock,1,0)
set ninth = %if(series{9}>shock,1,0)
set tenth = %if(series{10}>shock,1,0)
set eleventh = %if(series{11}>shock,1,0)
set twelfth = %if(series{12}>shock,1,0)
   if 1==lags
      set great = %if(first = 1,1,0)
      dis 'If we restrict the series to values preceded by chosen shocks, then we obtain the following data.'
      stat(smpl=great) series
   end if
   if 2==lags
      set great = %if(first + second = 2,1,0)
      dis 'If we restrict the series to values preceded by chosen shocks, then we obtain the following data.'
      stat(smpl=great) series
   end if
   if 3==lags
      set great = %if(first+second+third = 3,1,0)
      dis 'If we restrict the series to values preceded by chosen shocks, then we obtain the following data.'
      stat(smpl=great) series
   end if
   if 4==lags
      set great = %if(first+second+third+fourth = 4,1,0)
      dis 'If we restrict the series to values preceded by chosen shocks, then we obtain the following data.'
      stat(smpl=great) series
   end if
   if 5==lags
      set great = %if(first+second+third+fourth+fifth = 5,1,0)
      dis 'If we restrict the series to values preceded by chosen shocks, then we obtain the following data.'
      stat(smpl=great) series
   end if
   if 6=lags
      set great = %if(first+second+third+fourth+fifth+sixth = 6,1,0)
      dis 'If we restrict the series to values preceded by chosen shocks, then we obtain the following data.'
      stat(smpl=great) series
   end if
   if 7==lags
      set great = %if(first+second+third+fourth+fifth+sixth+seventh = 7,1,0)
      dis 'If we restrict the series to values preceded by chosen shocks, then we obtain the following data.'
      stat(smpl=great) (series)
   end if
   if 8==lags
      set great = %if(first+second+third+fourth+fifth+sixth+seventh+eighth = 8,1,0)
      dis 'If we restrict the series to values preceded by chosen shocks, then we obtain the following data.'
      stat(smpl=great) series
   end if
   if 9==lags
      set great = %if(first+second+third+fourth+fifth+sixth+seventh+eighth+ninth = 9,1,0)
      dis 'If we restrict the series to values preceded by chosen shocks, then we obtain the following data.'
      stat(smpl=great) series
   end if
   if 10==lags
      set great = %if(first+second+third+fourth+fifth+sixth+seventh+eighth+ninth+tenth = 10,1,0)
      dis 'If we restrict the series to values preceded by chosen shocks, then we obtain the following data.'
      stat(smpl=great) series
   end if
   if 11==lags
      set great = %if(first+second+third+fourth+fifth+sixth+seventh+eighth+ninth+tenth+eleventh = 11,1,0)
      dis 'If we restrict the series to values preceded by chosen shocks, then we obtain the following data.'
      stat(smpl=great) series
   end if
   if 12==lags
      set great = %if(first+second+third+fourth+fifth+sixth+seventh+eighth+ninth+tenth+eleventh+twelfth = 12,1,0)
      dis 'If we restrict the series to values preceded by chosen shocks, then we obtain the following data.'
   stat(smpl=great) series
   end if
end unit
atjanke
 
Posts: 2
Joined: Wed Mar 16, 2011 9:29 am

Re: Identifier LAGS is Not Recognizable

Postby TomDoan » Wed Mar 16, 2011 10:50 am

RATS is not an "IF---END IF" language; instead it's an IF {...} language. So instead of:

Code: Select all
   if 1==lags
      set great = %if(first = 1,1,0)
      dis 'If we restrict the series to values preceded by chosen shocks, then we obtain the following data.'
      stat(smpl=great) series
   end if


You want

Code: Select all
   if 1==lags {
      set great = %if(first = 1,1,0)
      dis 'If we restrict the series to values preceded by chosen shocks, then we obtain the following data.'
      stat(smpl=great) series
   }


(and similarly for all the other such constructions in your procedure). The END IF's become END's for the procedure itself, hence the option LAGS is no longer an active variable.

Also, in that SET GREAT instruction, you want to use FIRST==1, not FIRST=1. The latter is legal (assigns the value 1 to FIRST), but obviously isn't what you want.
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

Re: Identifier LAGS is Not Recognizable

Postby atjanke » Wed Mar 16, 2011 11:09 am

I have fixed those mistakes. But I am still getting the same error message:

## SX11. Identifier LAGS is Not Recognizable. Incorrect Option Field or Parameter Order?
>>>> if 2==lags {<<<<

Thanks a bunch for the help.

Code: Select all
procedure unit series
type series series
local series
OPTION INTEGER lags
OPTION REAL shock 0
set first = %if(series{1}>shock,1,0)
set second = %if(series{2}>shock,1,0)
set third = %if(series{3}>shock,1,0)
set fourth = %if(series{4}>shock,1,0)
set fifth = %if(series{5}>shock,1,0)
set sixth = %if(series{6}>shock,1,0)
set seventh = %if(series{7}>shock,1,0)
set eighth = %if(series{8}>shock,1,0)
set ninth = %if(series{9}>shock,1,0)
set tenth = %if(series{10}>shock,1,0)
set eleventh = %if(series{11}>shock,1,0)
set twelfth = %if(series{12}>shock,1,0)
   if 1==lags {
      set great = %if(first == 1,1,0)
      dis 'If we restrict the series to values preceded by chosen shocks, then we obtain the following data.'
      stat(smpl=great) series
}
   end if
   if 2==lags {
      set great = %if(first + second == 2,1,0)
      dis 'If we restrict the series to values preceded by chosen shocks, then we obtain the following data.'
      stat(smpl=great) series
}
   end if
   if 3==lags {
      set great = %if(first+second+third == 3,1,0)
      dis 'If we restrict the series to values preceded by chosen shocks, then we obtain the following data.'
      stat(smpl=great) series
}
   end if
   if 4==lags {
      set great = %if(first+second+third+fourth == 4,1,0)
      dis 'If we restrict the series to values preceded by chosen shocks, then we obtain the following data.'
      stat(smpl=great) series
}
   end if
   if 5==lags {
      set great = %if(first+second+third+fourth+fifth == 5,1,0)
      dis 'If we restrict the series to values preceded by chosen shocks, then we obtain the following data.'
      stat(smpl=great) series
}
   end if
   if 6=lags {
      set great = %if(first+second+third+fourth+fifth+sixth == 6,1,0)
      dis 'If we restrict the series to values preceded by chosen shocks, then we obtain the following data.'
      stat(smpl=great) series
}
   end if
   if 7==lags {
      set great = %if(first+second+third+fourth+fifth+sixth+seventh == 7,1,0)
      dis 'If we restrict the series to values preceded by chosen shocks, then we obtain the following data.'
      stat(smpl=great) series
}
   end if
   if 8==lags {
      set great = %if(first+second+third+fourth+fifth+sixth+seventh+eighth == 8,1,0)
      dis 'If we restrict the series to values preceded by chosen shocks, then we obtain the following data.'
      stat(smpl=great) series
}
   end if
   if 9==lags {
      set great = %if(first+second+third+fourth+fifth+sixth+seventh+eighth+ninth == 9,1,0)
      dis 'If we restrict the series to values preceded by chosen shocks, then we obtain the following data.'
      stat(smpl=great) series
}
   end if
   if 10==lags {
      set great = %if(first+second+third+fourth+fifth+sixth+seventh+eighth+ninth+tenth == 10,1,0)
      dis 'If we restrict the series to values preceded by chosen shocks, then we obtain the following data.'
      stat(smpl=great) series
}
   end if
   if 11==lags {
      set great = %if(first+second+third+fourth+fifth+sixth+seventh+eighth+ninth+tenth+eleventh == 11,1,0)
      dis 'If we restrict the series to values preceded by chosen shocks, then we obtain the following data.'
      stat(smpl=great) series
}
   end if
   if 12==lags {
      set great = %if(first+second+third+fourth+fifth+sixth+seventh+eighth+ninth+tenth+eleventh+twelfth == 12,1,0)
      dis 'If we restrict the series to values preceded by chosen shocks, then we obtain the following data.'
   stat(smpl=great) series
}
   end if
end unit
atjanke
 
Posts: 2
Joined: Wed Mar 16, 2011 9:29 am

Re: Identifier LAGS is Not Recognizable

Postby TomDoan » Wed Mar 16, 2011 1:27 pm

You put in the {...}, but didn't delete the END IF's. You have to do both.
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm


Return to Help With Programming

Who is online

Users browsing this forum: No registered users and 1 guest