Announcement

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

  • Estimating confidence intervals of the cumulative structural impulse–response functions

    Hello,

    I have estimated csirf following the instructions from this post: https://blog.stata.com/2016/10/27/lo...utoregression/

    But I wonder how can I estimate the CIs considering that there are no standard erros for the cumulative structural impulse–response functions I just created.

    Thanks,
    JL

  • #2
    Try removing noci.


    Code:
    clear all
    use http://www.stata-press.com/data/r13/lutkepohl2
    
    var dln_inv dln_inc dln_consump if qtr<=tq(1978q4), lags(1/5) dfk
    
    irf create irf_graph, step(10) set(my_irf)
    irf graph cirf, impulse(dln_inc) response(dln_consump)
    Click image for larger version

Name:	ex_irf.png
Views:	1
Size:	215.9 KB
ID:	1547277
    Last edited by Justin Niakamal; 16 Apr 2020, 10:22.

    Comment


    • #3
      Thanks very much Justin! This is highly appreacited.

      However, as you can see from the post, he creates the cummulative structural irf ("csirf") by adding up the structural irf ("sirf"). What I need to create is the confidence interval for the "csirf" which is something not available in the lrirf.irf file.

      For instance, if you take a look at the lrirf.irf file, there's a variable called "stdcirf" which are the standard errors of the cirf which when multiplied by +-2 give the confidence interval analog to the picture you are showing.

      But if you investiguate the lrirf.irf file further, you'll see there is another variable called sirf which is the one that he adds to get the csirf. You'll also note there is a stdsirf, but there is no equivalent stdcsirf because csirf is something that is being calculated "manually".

      My question is: is there a way to produce the standard errors of the cummulative sirf (i.e. csirf) that he builds?

      Regards,
      JLS
      Last edited by Jose Luis Saboin; 16 Apr 2020, 13:07.

      Comment


      • #4
        I think you can accomplish this by specifying graph coirf without the noci option specified. Here's an example which you can compare the two (the data are similar to what's used). Hope this helps.

        Code:
        clear
        tempfile temp 
        
        local v = "UNRATE" // unemployment rate 
        !curl -L https://fred.stlouisfed.org/series/`v'/downloaddata/`v'.csv > "`v'.csv"
        insheet using "`v'.csv", comma clear
                    
        gen quarter = qofd(date(date, "YMD"))    
        collapse (mean) value, by(quarter)              
        
        ren value unrate 
        save `temp'
        
        local v = "A001RP1Q027SBEA" // GNP
        !curl -L https://fred.stlouisfed.org/series/`v'/downloaddata/`v'.csv > "`v'.csv"
        insheet using "`v'.csv", comma clear
                       
        ren value growth   
        gen quarter = qofd(date(date, "YMD"))    
        merge 1:1 quarter using `temp', keep(match) nogen 
        drop date 
        format quarter %tq
        
        gen year = yofd(dofq(quarter))
        
        keep if year >= 1952 & year <= 1987
        gen t = _n 
        tsset quarter, quarterly  
        
        quietly regress unrate t
        predict unrate_adj, resid
        
        generate bp1 = (year<1974)
        generate bp2 = (year>=1974)
        
        quietly regress growth bp1 bp2, noconstant
        predict growth_adj, resid
        
        matrix C = (., 0 \ .,.)
        svar growth_adj unrate_adj, lags(1/8) lreq(C)
        
        
        irf create lr, set(lrirf) step(40) replace
        irf graph sirf, yline(0,lcolor(black)) xlabel(0(4)40) byopts(yrescale)
        
        use lrirf.irf, clear
        
        sort irfname impulse response step
        
        gen csirf = sirf
        
        by irfname impulse: replace csirf = sum(sirf) if response=="growth_adj"
        order irfname impulse response step sirf csirf
        
        save lrirf2.irf, replace
        
        use lrirf.irf, clear
        
        irf graph coirf, yline(0,lcolor(black))  xlabel(0(4)40) byopts(yrescale)
        graph export coirf.png , replace 
        
        irf set lrirf2.irf
        irf graph csirf, yline(0,lcolor(black)) noci xlabel(0(4)40) byopts(yrescale)
        graph export blogpost.png , replace 
        
        exit

        Comment


        • #5
          Thanks Justin! Just tried it on my project and unfortunately, for the case I'm studying, csirf and coirf are not the same/similar. Any other ideas on how to build those confidence intervals for csirf?

          Comment


          • #6
            I'm not sure. To get the standard errors from SVAR you need to use bsp in irf create. I suppose one crude way would be simply just to create a rolling sum of the standard errors. I'm not sure how inappropriate that is honestly. If it were me, I would use a software that can produce GIRFs with confidence intervals (I think Eviews does this but it's been a while).

            Code:
            use http://www.stata-press.com/data/r13/m1gdp, clear 
            
            matrix lr = (.,0\0,.)
            svar d.ln_m1 d.ln_gdp, lreq(lr)
            
            irf create lr, set(lrirf)  bsp  step(20) replace
            use lrirf.irf, clear
            
            sort irfname impulse response step
            
            gen double csirf = sirf
            gen double stdcsirf = stdsirf
            
            bys irfname  response impulse (step): replace csirf    = sum(sirf) 
            bys irfname  response impulse (step): replace stdcsirf = sum(stdsirf) 
            order irfname impulse response step sirf csirf stdcsirf
            
            save lrirf2.irf, replace
            
            irf set lrirf2.irf
            irf graph csirf, yline(0,lcolor(black))  xlabel(0(1)20) byopts(yrescale)

            Comment


            • #7
              Thanks Justin! I agree with you that Eviews would do better. In fact, what I'm actually doing is trying to replicate the CSIRFs that were produced in Eviews in Stata. Everything looks the same except the CIs. I actually did the rolling sum, and the CIs were clerarly wider than those reported by Eviews. That's why I came here in the first place. Let me show you some pictures:

              Eviews:
              Click image for larger version

Name:	ev.PNG
Views:	1
Size:	38.4 KB
ID:	1547535


              Stata (column 1 here is column 2 in Eviews)
              Click image for larger version

Name:	st.PNG
Views:	1
Size:	56.2 KB
ID:	1547536



              Attached Files

              Comment


              • #8
                I have the same problem. Does anyone know how to build the standard error (and therefore the confidence interval) for the cumulative sirf in STATA? Many thanks!

                Comment


                • #9
                  Originally posted by Justin Niakamal View Post
                  I'm not sure. To get the standard errors from SVAR you need to use bsp in irf create. I suppose one crude way would be simply just to create a rolling sum of the standard errors. I'm not sure how inappropriate that is honestly. If it were me, I would use a software that can produce GIRFs with confidence intervals (I think Eviews does this but it's been a while).

                  Code:
                  use http://www.stata-press.com/data/r13/m1gdp, clear
                  
                  matrix lr = (.,0\0,.)
                  svar d.ln_m1 d.ln_gdp, lreq(lr)
                  
                  irf create lr, set(lrirf) bsp step(20) replace
                  use lrirf.irf, clear
                  
                  sort irfname impulse response step
                  
                  gen double csirf = sirf
                  gen double stdcsirf = stdsirf
                  
                  bys irfname response impulse (step): replace csirf = sum(sirf)
                  bys irfname response impulse (step): replace stdcsirf = sum(stdsirf)
                  order irfname impulse response step sirf csirf stdcsirf
                  
                  save lrirf2.irf, replace
                  
                  irf set lrirf2.irf
                  irf graph csirf, yline(0,lcolor(black)) xlabel(0(1)20) byopts(yrescale)
                  I tried this way, and found that cumulative standard errors would be smaller if they are generated by sqrt(sum(stdsirf^2)), instead of by sum(stdsirf).

                  Comment

                  Working...
                  X