Page 1 of 1
DLM for UCM-NAWRU
Posted: Thu Feb 18, 2016 9:31 am
by fioramanti
Hi everybody,
I'm a newbie in RATS and I want to estimate the NAIRU (to be precise NAWRU) using a bivariate unobserved component model in SS form.
My SS form is like in the one in the figure, where u and deltapi are the observables (unemployment and change in wage inflation)
I went through fabiani-mestre and Laubach and Williams examples (togheter with RATS manuals), but, to be honest, I'm far away from understanding how DLM works.
Is there anyone available for helping me in coding this SS?
Thanks in advance.
M
Re: DLM for UCM-NAWRU
Posted: Thu Feb 18, 2016 10:18 am
by TomDoan
There appear to be some typos in that. I assume you want a + between the first two components on the right-side. And is there supposed to be a 1 in the (2,1) element of the transition matrix? That looks like it should be a zero.
Re: DLM for UCM-NAWRU
Posted: Thu Feb 18, 2016 10:42 am
by fioramanti
1. Yes, a plus is missing.
2. No, actual unemployment just equal to nawru plus un.gap.
Re: DLM for UCM-NAWRU
Posted: Thu Feb 18, 2016 10:45 am
by fioramanti
2. I mean it is a zero.
Re: DLM for UCM-NAWRU
Posted: Thu Feb 18, 2016 11:30 am
by TomDoan
In RATS options, the first 5-vector is your "Z". The 5 x 5 matrix is your "A". Your "F" matrix will be
1 0 0
0 1 0
0 0 0
0 0 0
0 0 1
The SW will (I assume) be a 3 x 3 diagonal matrix with three free variances. SV will be the symmetric matrix ||0.0|0.0,sigsqpi|| (or whatever you want to call that variance). C will be (since it's transposed)
1 0
1 beta0
0 beta1
0 beta2
0 0
The Z, A, SW, SV and C all have free parameters, so they'll have to be defined as FRML's of the proper type. For instance, something like:
Code: Select all
dec frml[vect] zf
frml zf = ||0.0,mu_u,0.0,0.0,0.0||
dec frml[rect] af
frml af = ||1.0 ,0.0, 0.0,0.0,1.0|$
0.0,phi1,phi2,0.0,0.0|$
0.0, 1.0, 0.0,0.0,0.0|$
0.0, 0.0, 1.0,0.0,0.0|$
0.0, 0.0, 0.0,0.0,1.0||
similarly for the other system matrices. You have to do a NONLIN to define the free parameters before you can create those matrices, and you'll have to come up with some process for getting guess values for them.
Re: DLM for UCM-NAWRU
Posted: Thu Feb 18, 2016 12:27 pm
by fioramanti
Many thanks Tom. I'll let you know if I succeed.
I'll try tomorrow.
M
Re: DLM for UCM-NAWRU
Posted: Fri Feb 19, 2016 5:16 am
by fioramanti
Dear Tom,
Sorry, but I have some additional questions.
Attached the program I wrote following your instructions. No starting values yet.
Qs:
1. I get the error msg "DLM2. No Observations Produce Valid Output. Check Data and Initial Values". Is this simply related to the lack of starting values, meaning the code is (so far) correct?
2. Is the vector of observables (y) correctly coded ?
3. To give specific starting value, is it correct to:
compute beta0=anynumber, beta1=anynumber
NONLIN(PARMSET=mysv) beta0 beta 1
and then call among dlm options "parmset=mysv"?
4. Is it possible (how?) to constraint parameters to be "lowerbound<=estimatedparameter<=upperbound (i need it for the variances)?
Your help would be very much appreciated,
M
Re: DLM for UCM-NAWRU
Posted: Fri Feb 19, 2016 8:15 am
by TomDoan
fioramanti wrote:Dear Tom,
Sorry, but I have some additional questions.
Attached the program I wrote following your instructions. No starting values yet.
Qs:
1. I get the error msg "DLM2. No Observations Produce Valid Output. Check Data and Initial Values". Is this simply related to the lack of starting values, meaning the code is (so far) correct?
If you haven't given guess values to the variances (in particular), the model predicts zero variances, which means no computable likelihood.
fioramanti wrote:
2. Is the vector of observables (y) correctly coded ?
Yes.
fioramanti wrote:
3. To give specific starting value, is it correct to:
compute beta0=anynumber, beta1=anynumber
NONLIN(PARMSET=mysv) beta0 beta 1
and then call among dlm options "parmset=mysv"?
Yes.
fioramanti wrote:
4. Is it possible (how?) to constraint parameters to be "lowerbound<=estimatedparameter<=upperbound (i need it for the variances)?
You need to split each into multiple constraints, as in:
nonlin(parmset=constraints) vslo>=lowerslo vslo<=upperslo
then use parmset=mysv+constraints on the DLM to provide both the parameter list and the constraints.
BTW, on
dlm(y=yf, a=af, z=zf, f=ff, sw=swf, c=cf, sv=svf, type=smooth) 1965 2017
you want 1965:1 and 2017:1 on the range. (1965 and 2017 are numbers, not dates).
Re: DLM for UCM-NAWRU
Posted: Fri Feb 19, 2016 8:39 am
by fioramanti
It seems to work now (it produces a graph which is the last line of the code), but I get "## DLM5. Probable Model Error. Diffuse prior was not reduced to zero rank" even if I use different "presample" options.
What does it mean?
Thanks
M
Re: DLM for UCM-NAWRU
Posted: Fri Feb 19, 2016 8:44 am
by fioramanti
Sorry, with "presample=ergodic" no error msg.
I think it works now
Many many thanks,
M
Re: DLM for UCM-NAWRU
Posted: Mon Feb 22, 2016 8:31 am
by fioramanti
Dear Tom,
I have another issue.
My code is:
Code: Select all
end(reset)
calendar(a) 1960:1
allocate 2017:1
open data WF2016.RAT
data(format=rats)
* Starting values
compute phi1=1.4203, phi2=-0.6216, mu=-0.0015, beta0=-0.0339, beta1=0.0560, beta2=-0.0272
compute vtr=0.1, vcyc=0.11, vslo=0.02, vpc=0.0004837
compute LB=0, UBvtr=0.1, UBvcyc=0.11, LBvslo=0.02, UBvslo=0.035, UBvpc=0.000816139288671913
nonlin(parmset=coeff) phi1 phi2 mu beta0 beta1 beta2
nonlin(parmset=vlist) vtr vcyc vslo vpc
nonlin(parmset=varia) vtr>=LB vtr<=UBvtr vcyc>=LB vcyc<=UBvcyc vslo>=LBvslo vslo<=UBvslo $
vpc>=LB vpc<=UBvpc
decl frml[rect] af
frml af = ||1.0 ,0.0, 0.0,0.0,1.0|$
0.0,phi1,phi2,0.0,0.0|$
0.0, 1.0, 0.0,0.0,0.0|$
0.0, 0.0, 1.0,0.0,0.0|$
0.0, 0.0, 0.0,0.0,1.0||
decl frml[vector] zf
frml zf = ||0.0,mu,0.0,0.0,0.0||
decl rect ff
compute ff=||1.0,0.0,0.0|$
0.0,1.0,0.0|$
0.0,0.0,0.0|$
0.0,0.0,0.0|$
0.0,0.0,1.0||
decl frml[symmetric] swf
frml swf = ||vtr, 0.0, 0.0|$
0.0,vcyc, 0.0|$
0.0, 0.0,vslo||
decl frml[rect] cf
frml cf = ||1.0, 0.0|$
1.0,beta0|$
0.0,beta1|$
0.0,beta2|$
0.0, 0.0||
decl frml[symmetric] svf
frml svf = ||0.0, 0.0|$
0.0, vpc||
decl frml[vector] yf
frml yf =||u,ddw||
dlm(presample=ergodic,parmset=coeff+vlist+varia, print,y=tr(yf), a=af, z=zf, f=ff, sw=swf, $
c=cf, sv=svf, method=simplex) 1965:1 2017:1 xstates vstates
I have two problems here:
1. Variances constraints do not bite;
2. One of the variances is negative.

- Cattura.JPG (45.07 KiB) Viewed 15323 times
Ho can it be possible?
Thanks,
M
Re: DLM for UCM-NAWRU
Posted: Mon Feb 22, 2016 10:10 am
by TomDoan
SIMPLEX, by it's nature, can't handle the constraints. Instead, you have to use METHOD=BFGS---see Section 4.4 in the User's Guide.
You have four fundamental shocks for two observables. The only requirement to compute the likelihood is that the predictive covariance matrix be positive-definite, which can be true even if some of the variances are (theoretically) negative. If that's the case, then the optimum is an edge solution, which requires using constrained estimation.
Re: DLM for UCM-NAWRU
Posted: Mon Feb 22, 2016 10:36 am
by fioramanti
Indeed with bfgs all the variances are positive and constraints are satisfied.
Thanks,
M