Dynamic Latent Factor Model

Discussion of State Space and Dynamic Stochastic General Equilibrium Models

Dynamic Latent Factor Model

Postby sleu123 » Wed Oct 14, 2009 4:41 am

Hello everyone,

I am wondering if there are people who have tried coding up:

(1) "The macroeconomy and the yield curve: a dynamic latent factor approach" by Diebold, Rudebusch, and Aruoba in Journal of Econometrics (2006)

That's at http://www.estima.com/forum/viewtopic.php?f=8&t=1028

(2) "The multi-state latent factor intensity model for credit rating transitions" by Koopman, Lucas, and Monteiro in Journal of Econometrics (2008)

I would gratefully appreciate if you would happy to share these codes with me.

Kind Regards,

Shawn Leu
sleu123
 
Posts: 6
Joined: Sat Apr 11, 2009 3:53 am

Re: Dynamic Latent Factor Model

Postby buianhtuan2000 » Mon Jan 04, 2010 6:35 pm

Dear Tom

I am very interested in Diebold's model and would like to run similar regression base on the difference in interest rate among countries.

Could you please suggest me the coding of this model? I would like to attach the data of the differece in interest rates in various maturities

Thank you very much

I am looking forward to your reply
Last edited by buianhtuan2000 on Wed Jan 06, 2010 6:20 pm, edited 1 time in total.
buianhtuan2000
 
Posts: 5
Joined: Sun Jan 03, 2010 10:05 pm

Re: Dynamic Latent Factor Model

Postby TomDoan » Tue Jan 05, 2010 10:16 am

This is a full running example of the base model that should work with version 7.0. It should be a simple modification to switch the data sets. You might have to change the guess values for mu, but everything else should go through the same as with this. An updated version which uses some features added with version 7.3 is available at: http://www.estima.com/forum/viewtopic.php?f=8&t=1028

drajoe2006_v7.prg
(2.2 KiB) Downloaded 348 times

DRA Data.txt
(46.57 KiB) Downloaded 288 times
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

Re: Dynamic Latent Factor Model

Postby buianhtuan2000 » Tue Jan 05, 2010 5:10 pm

Thank you very much Tom

Could you please advise me
What are cu pi ffr ?
and, How can I save the loading i.e. Lt,St, and Ct for each point of time in an excel file?

I look forward to hearing your relpy.
All the best
buianhtuan2000
 
Posts: 5
Joined: Sun Jan 03, 2010 10:05 pm

Re: Dynamic Latent Factor Model

Postby TomDoan » Wed Jan 20, 2010 12:19 pm

buianhtuan2000 wrote:Thank you very much Tom

Could you please advise me
What are cu pi ffr ?


Those are the three observable "factors". CU is capacity utilization, PI is price inflation and FFR is the Federal Funds rate.

buianhtuan2000 wrote:and, How can I save the loading i.e. Lt,St, and Ct for each point of time in an excel file?

I look forward to hearing your relpy.
All the best


Add the TYPE=SMOOTH option and the XSTATES parameter to the DLM instruction. Then pull out the factors from the states and do a COPY.

Code: Select all
dlm(startup=%(DRASetup3(),sw=%diag(swdiag)),$
  a=a,sw=sw,sv=sv,c=lambda,y=%eqnxvector(yvars,t)-muy,$
   presample=ergodic,method=bfgs,iters=400,$
   type=smooth) / xstates
set lt = xstates(t)(1)
set st = xstates(t)(2)
set ct = xstates(t)(3)
copy(format=xls,org=columns) / lt st ct
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

Re: Dynamic Latent Factor Model

Postby atbui » Thu May 27, 2010 8:39 pm

TomDoan wrote:This is a full running example of the base model that should work with version 7. It should be a simple modification to switch the data sets. You might have to change the guess values for mu, but everything else should go through the same as with this.


Dear Tom

Could you please show me how you estimate the guess value of mu, a, sw, swdiag, svdiag and lam. I wonder if the results change when we use a difference set of guess value or not?

Thank you very much
atbui
 
Posts: 8
Joined: Mon Jan 04, 2010 12:27 am

Re: Dynamic Latent Factor Model

Postby TomDoan » Fri May 28, 2010 3:12 am

Unfortunately, I don't really have any good advice on that; mine (particularly the mu's) came largely from the published results, and the authors don't seem to have a record of where they started. The estimation behavior seems to be especially sensitive to the choice of mu if the data are near unit-root; it doesn't seem to be as sensitive to the guess values for the variances.
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

Re: Dynamic Latent Factor Model

Postby mike80 » Tue Mar 22, 2011 6:24 am

Dear Tom,

I tried to get the shocks from the transition equation (etas in equation 5 on page 313). Is it right that these shocks can be obained by inlcuding the "what" option in the DLM instruction?

dlm(startup=%(DRASetup3(),sw=%diag(swdiag)),$
a=a,sw=sw,sv=sv,c=lambda,y=%eqnxvector(yvars,t)-muy,$
presample=ergodic,method=bfgs,iters=400,what=shocks)
then
set shockL %regstart() %regend() = shocks(t)(1)

In doing so, I have a problem with the generated series. The new series are generally not filled except an "na" as the third observation. In addition, the range of dates (heavily) exceeds the defined one. I am working with Rats 7.3.

Thanks in advance.

Kind regards.
mike80
 
Posts: 3
Joined: Mon Aug 04, 2008 8:42 am

Re: Dynamic Latent Factor Model

Postby TomDoan » Tue Mar 22, 2011 5:59 pm

mike80 wrote:Dear Tom,

I tried to get the shocks from the transition equation (etas in equation 5 on page 313). Is it right that these shocks can be obained by inlcuding the "what" option in the DLM instruction?

dlm(startup=%(DRASetup3(),sw=%diag(swdiag)),$
a=a,sw=sw,sv=sv,c=lambda,y=%eqnxvector(yvars,t)-muy,$
presample=ergodic,method=bfgs,iters=400,what=shocks)
then
set shockL %regstart() %regend() = shocks(t)(1)

In doing so, I have a problem with the generated series. The new series are generally not filled except an "na" as the third observation. In addition, the range of dates (heavily) exceeds the defined one. I am working with Rats 7.3.

Thanks in advance.

Kind regards.


WHAT's aren't computed when you filter, just when you smooth (or simulate). If you use the same instruction, but add TYPE=SMOOTH, you'll get the full sample estimates for the state disturbances.
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

Re: Dynamic Latent Factor Model

Postby econometrics » Wed Aug 10, 2011 3:35 pm

Hi Tom,

I've run your model with the original data saved the L,S and C -the estimated betas -in excel but the number of observations exceeds the t and each beta should be estimated for each period t.Can you pls give me some help with that ?

Thank you,
Rosa
econometrics
 
Posts: 6
Joined: Wed Aug 10, 2011 10:36 am

Re: Dynamic Latent Factor Model

Postby TomDoan » Wed Aug 10, 2011 4:27 pm

econometrics wrote:Hi Tom,

I've run your model with the original data saved the L,S and C -the estimated betas -in excel but the number of observations exceeds the t and each beta should be estimated for each period t.Can you pls give me some help with that ?

Thank you,
Rosa


There are 348 data points, and I get a file with 348 rows of numbers, so I'm not sure what you mean.
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

Re: Dynamic Latent Factor Model

Postby econometrics » Wed Aug 10, 2011 5:27 pm

When I added the code for the betas I just added and not replaced and that 's why I had some added betas. Thank you for your quick replay. I am new to Rats , I just used it a little in the past. Also Tom how can I get the residuals from the fitted curve month by month?

Thank you.
econometrics
 
Posts: 6
Joined: Wed Aug 10, 2011 10:36 am

Re: Dynamic Latent Factor Model

Postby TomDoan » Fri Aug 12, 2011 4:08 am

econometrics wrote:When I added the code for the betas I just added and not replaced and that 's why I had some added betas. Thank you for your quick replay. I am new to Rats , I just used it a little in the past. Also Tom how can I get the residuals from the fitted curve month by month?

Thank you.


Add a VHAT option to the DLM instruction. That will generate a SERIES of VECTORS. To pull out a specific component of that (assuming the option was VHAT=VHAT), you would do something like:

set r1 = vhat(t)(1)
set r2 = vhat(t)(2)
...
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

Re: Dynamic Latent Factor Model

Postby econometrics » Wed Aug 17, 2011 5:16 pm

Thank you Tom for all your help and patience.
I've wrote the code as you said and run it on the data provided for Diebold et al and are approximately the same. What I’ve did is just add a new DLM function modified for the residuals and run it separately, saving a copy in excel , but I’ve noticed that the estimated parameters have changed. I tried to run several times with just the added what=what and set the residuals for all the vectors in the DLM function, not adding a new DLM function but then the window to save the residuals didn’t appeared. Maybe you can give me some advise on how to treat the new DLM function.

Regards,
Rosa
econometrics
 
Posts: 6
Joined: Wed Aug 10, 2011 10:36 am

Re: Dynamic Latent Factor Model

Postby econometrics » Fri Aug 19, 2011 5:43 pm

Hi Tom,

I have a problem with the estimated betas. I’ve run the program on my data and plotted the estimated factors with the empirical ones and it didn’t look good, the gap is too big especially the level. I thought to plot also the Diebold estimated betas with the empirical ones and see if are ok, the same behaviour. I must be doing something wrong and I can’t figure it out. The estimated level should be positive and starts at 5-6 percent in Diebold’s paper and the level that I’ve estimated is negative. I will attach the excel file just to see what betas I’ve got.
Thank you Tom.
Regards,
Rosa
Attachments
trial.xlsx
(136.91 KiB) Downloaded 90 times
econometrics
 
Posts: 6
Joined: Wed Aug 10, 2011 10:36 am

Next

Return to State Space Models/DSGE

Who is online

Users browsing this forum: No registered users and 0 guests