*
*  STRUCVAR.PRG
*  Manual example 10.4
*
*********************************************************************
*
*  Set Up Data
*
cal 1981 1 4
allocate 2003:2
open data candata.rat
data(format=rats) / canrgdps canm1s cancd90d cancpinf canusxsr usargdps
*
log canrgdps
log canm1s
log cancpinf
log canusxsr
log usargdps
*
system(model=canmodel)
variables usargdps canrgdps cancd90d canusxsr canm1s cancpinf
lags 1 to 4
det constant
end(system)
*
estimate(noprint)
*
dec frml[rect] afrml bfrml
nonlin uf1 cr1 cf1 rf2 mf1 mm2
frml  bfrml = ||1.0,0.0,uf1,0.0,0.0,0.0|$
                cr1,1.0,cf1,0.0,0.0,0.0|$
                0.0,0.0,1.0,rf2,0.0,0.0|$
                0.0,0.0,0.0,1.0,0.0,0.0|$
                mf1,0.0,0.0,0.0,1.0,mm2|$
                0.0,0.0,0.0,0.0,0.0,1.0||
compute uf1=cr1=cf1=rf2=mf1=mm2=pm2=0.0
*
*   This is estimated by using the genetic method first, then polishing the
*   estimates with bfgs. In practice, you might want to repeat this several
*   times to test whether there are global identification problems.
*
cvmodel(iters=100,method=bfgs,pmethod=genetic,piters=50,factor=bfactor) %sigma * bfrml
*
*   Because the shocks don't really correspond one-to-one with the variables,
*   the labels option is used on ERRORS to give them the desired labels.
*
errors(model=canmodel,decomp=bfactor,window='BModel',$
   labels=||'Real 1','Real 2','Fin 1','Fin 2','Nom 1','Nom 2'||) * 28


nonlin rx ur cu cr pc pr mp mc mr

frml  afrml = ||1.0,0.0,ur ,0.0,0.0,0.0|$
                cu ,1.0,cr ,0.0,0.0,0.0|$
                0.0,0.0,1.0,rx ,0.0,0.0|$
                0.0,0.0,0.0,1.0,0.0,0.0|$
                0.0,mc ,mr ,0.0,1.0,mp |$
                0.0,pc ,pr ,0.0,0.0,1.0||
compute ur=cu=cr=rx=mc=mr=mp=pc=pr=0.0
cvmodel(iters=100,method=bfgs,pmethod=genetic,piters=50,factor=afactor) %sigma afrml
errors(model=canmodel,decomp=afactor,steps=28,window='AModel')



