Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • state space estimations: Setting initial variances of variables

    Dear Statalist members,

    I am trying to estimate the Hodrick-Prescott Filter in state space form, but face convergence issues. In addition to setting initial starting values, I would like to set initial variances for certain variables, but cannot figure out how to do this. The option - var(variable_name, init(#.#)) - was not allowed in this context.

    It would be really helpful and highly appreciated if you could tell me whether this is possible in Stata and if so, how.
    Thank you very much in advance!

    Johanna

  • #2
    In case some have the same problem, here is the solution: The variance of variables is set via constraints. An example would be constraint define 1 [var(u1)]_cons=0.001 and sspace (u1 L.u1, state noconstant) (u2 .u1 .u3, state noconstant), constraints (1/1)
    Best,
    Johanna

    Comment


    • #3
      You can constrain the variances of the error terms on the equations to be one and constrain the coefficients on the error terms to be the square root of the variance of the variable. Here's some code to estimate the Hodrick Prescott filter using sspace that I wrote a long while ago.

      Code:
      clear all
      webuse lutkepohl, clear
      * Define lambda
      glo l=1600
      * Filter using built in HP
      tsfilter hp investment_cyc=investment, smooth(${l})
      * Now do it with sspace
      glo y "investment"
      constraint drop _all
      constraint 1 [mu]l.mu = 1
      constraint 2 [mu]l.beta = 1
      constraint 3 [beta]l.beta = 1
      constraint 4 [investment]mu = 1
      scalar lambda = ${l}
      scalar sl = 1 / lambda
      scalar sl = sqrt(sl)
      constraint 5 ([beta]e.beta) = sl*([${y}]e.${y})
      sspace (mu l.mu l.beta , state noconstant) (beta l.beta e.beta, state noconstant) (${y} mu e.${y}, noconstant), covstate(identity) covobserved(identity) constraints(1/5)
      predict double investment_sm2 , state smethod(smooth) eq(mu)
      gen investment_cyc2=investment-investment_sm2
      * Plot to check, lines should be on top of each other
      tsline investment_cyc investment_cyc2
      Jorge Eduardo Pérez Pérez
      www.jorgeperezperez.com

      Comment


      • #4
        Dear Statalist members,

        Similarly, I am trying to estimate the Harvey (1985) -Clark (1987) model in state space form, but don't know what initial constraints should be placed.
        In the Harvey-Clark model, the trend is modeled as a local linear trend, and the cycle as an AR(2)
        process:
        μt= gt-1t-1t
        gt=gt-1+vt
        zt1zt-12zt-1t
        with μt and zt being the two unobserved componets (respectively the trend and the cycle). ηt vt and ξt are assumed to be i.i.d., mean-zero, Gaussian, and mutually uncorrelated processes, and ρ1 and ρ2 and the variances of the three shocks are parameters to be estimated (five in total).

        I guess the right command would be sspace, but don't know what contraint option should be placed.
        It would be really helpful and highly appreciated if you could tell me whether this is possible in Stata and if so, how.
        Thank you very much in advance!

        Giacomo

        Comment

        Working...
        X