Anjan Panday
2011-Jun-30 15:21 UTC
[R] Specifying State Space model to decompose structural shocks
Dear all: Greetings! I am trying to replicate a simple state space model in R, using the package 'dlm'. This model has two observation equations and three state equations. Each observation equation represents structural shocks based on SVAR for country i, where i=1 to 2. The structural shocks (S1 and S2) are to be decomposed into common (sv1) and country-specific (sv2, sv3) shocks. We are interested only in the coefficient of common shock. Moreover, the transition equation is represented as a random noise. Observation equation: S1=c(1)*sv1+sv2 S2=c(2)*sv1+sv3 Transition equation: sv1=(variance=1) sv2=(c(3)) sv3=(c(4)) The variance (of the region-specific shock) in the first State equation is set to 1, while the variances of second and third state equations are to be estimated. Total four parameters to be estimated. I have also attached the paper that uses this specification. To specify above model in R, I am considering the dlm package, which suggests that multivariate series can be represented by combining two univariate expressions. First, I need to write a function and then use dlmMLE to estimate it. For example, I can start by writing a function x, which combines two univariate expressions: ab<-function(x) { dlmModPoly()%+%dlmModPoly() } fit<-dlmMLE(data, parm=c(....), build=ab) However, I am not sure how to write my model within this function. For instance, when I just run the expression inside above function, I get:> dlmModPoly()%+%dlmModPoly()$FF [,1] [,2] [,3] [,4] [1,] 1 0 0 0 [2,] 0 0 1 0 $V [,1] [,2] [1,] 1 0 [2,] 0 1 $GG [,1] [,2] [,3] [,4] [1,] 1 1 0 0 [2,] 0 1 0 0 [3,] 0 0 1 1 [4,] 0 0 0 1 $W [,1] [,2] [,3] [,4] [1,] 0 0 0 0 [2,] 0 1 0 0 [3,] 0 0 0 0 [4,] 0 0 0 1 $m0 [1] 0 0 0 0 $C0 [,1] [,2] [,3] [,4] [1,] 1e+07 0e+00 0e+00 0e+00 [2,] 0e+00 1e+07 0e+00 0e+00 [3,] 0e+00 0e+00 1e+07 0e+00 [4,] 0e+00 0e+00 0e+00 1e+07 I am wondering how do I specify the coefficient for common shock and country-specific shocks in the FF matrix. Similarly, how do I write three transition equations? Do I change all of the elements in GG matrix to zero, since this is a model with pure noise in state equation? Moreover, am I correct to use dlmModPoly to build a function for my state space model? Kindly suggest to help me estimate the model. Best regards, Anjan Panday American University Washington, DC -------------- next part -------------- A non-text attachment was scrubbed... Name: state space.pdf Type: application/pdf Size: 150565 bytes Desc: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20110630/c61f55c2/attachment.pdf>