Announcement

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

  • Different Outputs for the same programs

    Hello together!

    I have a STATA program that I got from a research paper and I modified it a little bit. I run the program and it returned the outcome I need. However, when I copied it to another folder and run it again, it just produced a totally different outcome. Do you have any suggestions to fix it ?

    To make it clear: I copied both the program file and the data file to the new folder, so basically I have EXACTLY the same programs and datasets in the 2 folder. I also changed the directory in the new copied file to the new folder already. I am using STATA 15.

    Here you can find the program and dataset, along with an image of the output I want.

    I'm totally new to STATA so my question my be vague ... I hope I can make it as clear as possible if you have any questions.

    Thanks in advance!

  • #2
    Tung:
    welcome to this forum.
    As per FAQ, the best way to allow other to replicate your issue(s), is to:
    -shared an example/excerpt of your dataset via -dataex- (as you know, downloading files is not risk-free);
    -using CODE delimiters to post what you typed and what Stata gave you back in both instances.
    Thanks.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Thanks Carlo for pointing it out!

      Here is what I want, and also what I got from the original program:

      Click image for larger version

Name:	gdp.png
Views:	1
Size:	46.8 KB
ID:	1713657



      Here is what I got after copying the program and data files to another folder, which is not what I expected because I'm using the same program and dataset:

      Click image for larger version

Name:	symplot_y.png
Views:	1
Size:	19.7 KB
ID:	1713658




      Hereunder are my program and a part of my dataset:

      Code:
      clear all
      
      *** Replicate Romer and Romer (2017) 
      *** Folder & data
      cd "E:/Goethe/GOETHE courses/Seminar/Banking and Macro/Replication - Topic 9/Figure 2 - GDP"
      use data
      
      *** Country and time variables
      gen time = _n
      tsset time
      xtset id date
       
       *** Dependent variable
      gen y = ln(gdp)
      local lhs "y"   /* LeftHandSide variables: variables that IRFs are created for */
      local H = 11            /* Impulse response horizon */
      local lag = 4       /* Lag length */  
       
       *** Crisis variable
      gen x = crisis
      gen z = ln(gdp)
      
      foreach v in `lhs'  {
      quietly:    tsrevar F(0/`H').`v'
      quietly:    rename (`r(varlist)') `v'_#, addnumber
      quietly:    gen `v' = `v'_1
      }
      
      * 3.7 EA, 7 US
      foreach v in `lhs'  {
      forvalues i=1/`H' {
      xtreg `v'_`i' L(0/`lag').x L(1/`lag').y i.date i.id, fe robust 
      quietly: est sto irf_`v'_`i'
      * Rescale by 7, i.e. effect of a moderate financial crisis-minus
      quietly: generate beta_`v'_`i' = _b[x]*7
      quietly: generate se_`v'_`i' = _se[x]*7
      }
      }
       
      *preserve
      keep beta* se*
      drop if _n > 1
      gen i=_n
      reshape long beta_y_ se_y_, i(i) j(time)
      gen t = time -1
      
      foreach v in `lhs'  {
      gen ub_`v' = beta_`v'_ + 1.64*se_`v'_ /* 90% CI: beta +/- 1.64*SE */
      gen lb_`v' = beta_`v'_ - 1.64*se_`v'_ 
      twoway (line beta_`v'_ t ) (line ub_`v' t ) (line lb_`v' t), name(symplot_`v')  legend(off) ytitle(`v')
      }

      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input int date str14 country byte id float gdp byte crisis
       1 "Australia" 1  215022.7 .
       2 "Australia" 1  221020.9 .
       3 "Australia" 1 227456.03 .
       4 "Australia" 1  238985.5 .
       5 "Australia" 1  242319.8 .
       6 "Australia" 1 251883.36 .
       7 "Australia" 1 261735.63 .
       8 "Australia" 1 265908.53 .
       9 "Australia" 1 266415.72 .
      10 "Australia" 1    274636 0
      11 "Australia" 1  277648.9 0
      12 "Australia" 1 278936.94 0
      13 "Australia" 1 286702.78 0
      14 "Australia" 1  296848.8 0
      15 "Australia" 1  290835.5 0
      16 "Australia" 1  294636.8 0
      17 "Australia" 1 304903.38 0
      18 "Australia" 1 297140.06 0
      19 "Australia" 1  311762.8 0
      20 "Australia" 1  316578.5 0
      21 "Australia" 1  319310.2 0
      22 "Australia" 1  316857.2 0
      23 "Australia" 1  322089.6 0
      24 "Australia" 1  329340.7 0
      25 "Australia" 1  333119.4 0
      26 "Australia" 1  342733.2 0
      27 "Australia" 1  345098.3 0
      28 "Australia" 1  353017.3 0
      29 "Australia" 1  359708.5 0
      30 "Australia" 1  365543.6 0
      31 "Australia" 1    365988 0
      32 "Australia" 1  357717.5 0
      33 "Australia" 1    353286 0
      34 "Australia" 1  369385.1 0
      35 "Australia" 1 382245.25 0
      36 "Australia" 1  389197.6 0
      37 "Australia" 1    403278 0
      38 "Australia" 1  408020.8 0
      39 "Australia" 1  409823.6 0
      40 "Australia" 1  418003.7 0
      41 "Australia" 1  428827.6 0
      42 "Australia" 1  445082.4 0
      43 "Australia" 1  448268.6 0
      44 "Australia" 1  457975.2 0
      45 "Australia" 1  472645.7 0
      46 "Australia" 1  475018.3 0
      47 "Australia" 1    479593 0
      48 "Australia" 1  480137.8 0
      49 "Australia" 1 472552.75 0
      50 "Australia" 1  475118.8 0
      51 "Australia" 1  482585.8 0
      52 "Australia" 1 496786.75 0
      53 "Australia" 1    503596 0
      54 "Australia" 1  513588.8 0
      55 "Australia" 1  528575.7 0
      56 "Australia" 1 536241.06 0
      57 "Australia" 1 541486.06 0
      58 "Australia" 1    553583 0
      59 "Australia" 1  565288.2 0
      60 "Australia" 1  576162.4 0
      61 "Australia" 1 595942.25 0
      62 "Australia" 1    605320 0
      63 "Australia" 1  616236.8 0
      64 "Australia" 1  635587.4 0
      65 "Australia" 1  643985.9 0
      66 "Australia" 1  658289.8 0
      67 "Australia" 1  670424.4 0
      68 "Australia" 1  668538.8 0
      69 "Australia" 1  681529.5 0
      70 "Australia" 1  696473.6 0
      71 "Australia" 1  713142.7 0
      72 "Australia" 1  721937.9 0
      73 "Australia" 1  726673.2 0
      74 "Australia" 1  750849.4 0
      75 "Australia" 1  760423.1 0
      76 "Australia" 1  772823.8 0
      77 "Australia" 1  783484.5 0
      78 "Australia" 1  799169.3 0
      79 "Australia" 1  802247.5 0
      80 "Australia" 1  824043.6 0
      81 "Australia" 1  842871.8 0
      82 "Australia" 1  854998.9 0
      83 "Australia" 1  867274.1 2
      84 "Australia" 1  867477.4 4
      85 "Australia" 1    881829 1
      86 "Australia" 1  890988.3 0
      87 "Australia" 1  900192.8 0
      88 "Australia" 1  914895.9 0
      89 "Australia" 1  922691.9 0
      90 "Australia" 1  943332.9 0
      91 "Australia" 1  958229.4 0
      92 "Australia" 1  968897.6 0
       1 "Austria"   2 109520.88 0
       2 "Austria"   2 110551.05 0
       3 "Austria"   2 113272.77 0
       4 "Austria"   2 116357.67 0
       5 "Austria"   2  119713.9 0
       6 "Austria"   2 123842.02 0
       7 "Austria"   2 129449.08 0
       8 "Austria"   2 133593.97 0
      end

      Comment

      Working...
      X