Page 1 of 1

Code Error

Posted: Wed Mar 08, 2023 3:06 pm
by Ozmando
I please need help with fixing an error on this code:
I have created a time dummy and country dummy but this seems to e nerate the error message:

## SX11. Identifier DUMMY is Not Recognizable. Incorrect Option Field or Parameter Order?
>>>>onstant time dummy<<<<
If the name isn't mistyped, it's possible that you have a poorly formatted instruction
Common errors are
* a space before the ( in an option field
* a missing space before = in a SET or FRML
* a missing $ at the end of a long line which continues to the next


Show last error indicates that the problem is at "det constant time dummy"

Code: Select all

open data "panel.csv"
*calendar(a) 1970:1
data(format=prn,nolabels,org=columns) 1970:01 2015:01 g t r p h
calendar(panelobs=46) 1970

allocate 18//2015:1
*
COMPUTE N = 18				;*Number of countries
COMPUTE YYY = 46   		;*Number of observations for each country
*  this created country specific dummies and linear trend
*
SET LTREND = %PERIOD(T)
dec vector[series] dummies(N) time(YYY) trend(N) qtrend(N)
do p=1,N
	set dummies(p) = %indiv(t)==p
	set trend(p)    = (%indiv(t)==p)*ltrend
	set qtrend(p)    = (%indiv(t)==p)*ltrend*ltrend
end do p
*
* time dummy
*
do p=1,YYY
set time(p)    = (%period(t)==p)
end do p
*print / time

compute nlags=5
*
system(model=basevar)
variables g t r p h
lags 1 to nlags
det constant time dummy
end(system)
*
compute varlabels=||"g","t","r"||
*
estimate
compute nregeqn=%nreg
*
* This sets the shocks to be used and the labels for the graph. In
* this case, the shocks are Cholesky shocks, so they are associated
* 1-1 with the variables. To use different shocks, change the way
* <<fshock>> is computed and make the required adjustment to the
* <<shocklabels>>
*
compute nstep=12
compute fshock=%decomp(%sigma)
compute nshock=%cols(fshock)
compute shocklabels=||"g","t","r"||
*
* Do the shocks using the standard VAR methods, saved into baseirf
*
impulse(steps=nstep+1,factor=fshock,model=basevar,results=baseirf)
*
dec rect pix(%nvar,%nvar) pixvar(%nvar,%nvar)
dec rect[series] linprjirf(%nvar,nshock)
dec rect[series] linprjstderr(%nvar,nshock)
clear(length=nstep+1) linprjirf linprjstderr
dec rect deltawt(%nregsystem,%nvar)
dec integer k
*
* The impacts are the ones specified by the choice of the <<fshock>>
* matrix. Because RATS series are based at entry 1, the impacts go
* in entry 1 and the h step responses into h+1.
*
compute %pt(linprjirf,1,fshock)
do h=1,nstep
   system(model=linvar)
   variables g t r p h
   lags h to h+nlags-1
   det constant  time dummy
   end(system)
   *
   * Estimate by SUR with system Newey-West covariance matrix
   *
   sur(model=linvar,robust,lwindow=newey,lags=h-1,noprint)
   *
   * Pull out the leading lag matrix and post-multiply by the
   * desired factor of the covariance matrix.
   *
   compute pix=%modellagmatrix(linvar,h)
   compute %pt(linprjirf,h+1,pix*fshock)
   *
   do i=1,%nvar
      do j=1,%nvar
         ewise deltawt(k,j)=(k==(i-1)*nregeqn+(j-1)*nlags+1)
      end do j
      compute pixvar=%mqform(%xx,deltawt)
      do j=1,nshock
         compute linprjstderr(i,j)(h+1)=sqrt(%qform(pixvar,%xcol(fshock,j)))
      end do j
   end do i
end do h
*
dec vect[series] lower(nshock) upper(nshock)
*spgraph(hfields=nshock,vfields=%nvar,xlabels=varlabels,ylabels=shocklabels,$
*   footer="Figure 5. Impulse Responses for the New Keynesian Model based on a VAR and Linear Projections")
 do i=1,%nvar
   *
   * Compute the upper and lower bounds for each of the responses
   * for variable i, then find the max and min across all the shocks
   *
   do j=1,nshock
      set lower(j) 1 nstep+1 = linprjirf(i,j)-2.0*linprjstderr(i,j)
      set upper(j) 1 nstep+1 = linprjirf(i,j)+2.0*linprjstderr(i,j)
   end do j
   table(noprint) 1 nstep+1 lower upper
   do j=1,nshock
      *graph(row=i,col=j,number=0,min=%minimum,max=%maximum) 3 
compute header="Response of "+varlabels(1,i)+" to "+shocklabels(1,j)
graph(row=i,col=j,number=0,min=%minimum,max=%maximum,header=header) 3
      *# baseirf(i,j)
      # linprjirf(i,j) /6
      # lower(j) / 3
      # upper(j) / 3
   end do j
 end do i
*spgraph(done)
Thanks.

Re: Code Error

Posted: Thu Mar 09, 2023 4:02 pm
by TomDoan
You called it DUMMIES, not DUMMY. If DUMMY is supposed to be something other than the full set, you haven't defined it.

You also have an issue here (and throughout the program):

data(format=prn,nolabels,org=columns) 1970:01 2015:01 g t r p h

"T" is a standard name for the time subscript in SET instructions. Using it as a series name won't work. Given that you are reading as NOLABELS, you can pick something else.

Re: Code Error

Posted: Fri Mar 10, 2023 2:02 pm
by Ozmando
TomDoan wrote:You called it DUMMIES, not DUMMY. If DUMMY is supposed to be something other than the full set, you haven't defined it.

You also have an issue here (and throughout the program):

data(format=prn,nolabels,org=columns) 1970:01 2015:01 g t r p h

"T" is a standard name for the time subscript in SET instructions. Using it as a series name won't work. Given that you are reading as NOLABELS, you can pick something else.
Thanks Tom.