Announcement

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

  • How to save a matrix into stata data.

    Hello,
    I have the following dataset and I am using fect to estimate the ATT via interactive fixed effect method.
    (P.S: cap ado uninstall fect; net install fect, from(https://raw.githubusercontent.com/xu..._stata/master/) replace)

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float(index year ProdT_PPP D ProdT_PPPgr)
    1 1989  81.14477 0  81.14477
    1 1990  85.35793 0  85.35793
    1 1991  89.70922 0  89.70922
    1 1992  91.94646 0  91.94646
    1 1993  94.41286 0  94.41286
    1 1994  93.21414 0  93.21414
    1 1995  99.31738 0  99.31738
    1 1996 100.45268 0 100.45268
    1 1997 103.12508 0         0
    1 1998 109.81855 0         0
    1 1999 112.01806 0         0
    1 2000 116.20132 0         0
    1 2001 119.38148 0         0
    1 2002  117.9591 0         0
    1 2003  124.5746 0         0
    1 2004 125.54611 0         0
    1 2005 127.56765 0         0
    1 2006 128.66103 0         0
    1 2007 132.35184 0         0
    2 1989  48.57048 0  48.57048
    2 1990  51.36518 0  51.36518
    2 1991  52.63591 0  52.63591
    2 1992  52.96748 0  52.96748
    2 1993  52.90728 0  52.90728
    2 1994  55.69024 0  55.69024
    2 1995  58.72229 0  58.72229
    2 1996  60.95268 0  60.95268
    2 1997  63.42138 0         0
    2 1998   65.2895 0         0
    2 1999  68.05096 0         0
    2 2000 72.001686 0         0
    2 2001  73.03482 0         0
    2 2002 73.757256 0         0
    2 2003  74.78975 0         0
    2 2004  78.02372 0         0
    2 2005  80.86581 0         0
    2 2006  86.72974 0         0
    2 2007  93.44541 0         0
    3 1989  75.44291 0  75.44291
    3 1990  77.74706 0  77.74706
    3 1991  78.13865 0  78.13865
    3 1992  78.15627 0  78.15627
    3 1993  78.15464 0  78.15464
    3 1994  83.12341 0  83.12341
    3 1995  86.50258 0  86.50258
    3 1996  88.51806 0  88.51806
    3 1997  94.66062 0         0
    3 1998  96.68208 0         0
    3 1999   98.3532 0         0
    3 2000 102.19103 0         0
    3 2001 101.34123 0         0
    3 2002 104.22236 0         0
    3 2003 105.21182 0         0
    3 2004 110.96603 0         0
    3 2005  111.2371 0         0
    3 2006 113.77498 0         0
    3 2007  118.8219 0         0
    4 1989  7.739137 0  7.739137
    4 1990  7.230895 0  7.230895
    4 1991  7.283728 0  7.283728
    4 1992  7.200002 0  7.200002
    4 1993   7.58943 0   7.58943
    4 1994 8.1546545 0 8.1546545
    4 1995   8.47676 0   8.47676
    4 1996   9.14346 0   9.14346
    4 1997  9.452968 0         0
    4 1998  9.931542 0         0
    4 1999   9.43828 0         0
    4 2000 10.437926 0         0
    4 2001 11.094223 0         0
    4 2002 11.242044 0         0
    4 2003  11.32276 0         0
    4 2004 11.191737 0         0
    4 2005 10.972522 0         0
    4 2006 11.476481 0         0
    4 2007  12.18267 0         0
    5 1989  83.44241 0  83.44241
    5 1990  85.43155 0  85.43155
    5 1991  87.63772 0  87.63772
    5 1992  91.15511 0  91.15511
    5 1993  95.93752 0  95.93752
    5 1994 100.76215 0 100.76215
    5 1995  102.6278 0  102.6278
    5 1996   102.726 0   102.726
    5 1997  106.0936 0         0
    5 1998  110.9217 0         0
    5 1999 115.35303 0         0
    5 2000 120.64643 0         0
    5 2001 120.57237 0         0
    5 2002 121.96509 0         0
    5 2003 123.46539 0         0
    5 2004 126.66003 0         0
    5 2005 135.59502 0         0
    5 2006  141.3567 0         0
    5 2007 150.28378 0         0
    6 1989  1.463788 0  1.463788
    6 1990  1.450202 0  1.450202
    6 1991 1.5148412 0 1.5148412
    6 1992 1.6992654 0 1.6992654
    6 1993  1.952383 0  1.952383
    end
    I use fect to estimate the treatment effect via the following code:
    fect ProdT_PPP, treat(D) unit(index) time(year) cov(ProdT_PPPgr) method("ife") r(6) counterfactual nlambda(15) se nboots(200) ylabel(" ") title(" ")
    I then access the following matrix which has the period-wise treatment effects and their p-values, plus CIs.
    mat list e(ATTs)
    Click image for larger version

Name:	Screenshot 2022-02-20 at 16.34.40.png
Views:	1
Size:	184.8 KB
ID:	1650997


    Question: How can I save the above matrix as dataset?

    I attempted to use svmat or svmat2 (as shown below) but to no avail. Perhaps I am missing something. Please help!
    svmat2 ATTs, names(col) rnames(var) full
    Click image for larger version

Name:	Screenshot 2022-02-20 at 16.36.21.png
Views:	1
Size:	18.7 KB
ID:	1650998

  • #2
    Clearly you have no matrix called "ATTs". That's not the name of "e(ATTs)". You could always include lines like


    Code:
    matrix ATTs = e(ATTs)
    and then call -svmat2- as you did. (I can't test this because your output listing is not between CODE delimiters.)

    Comment


    • #3
      Stephen Jenkins thank you so much. It has worked.

      Comment

      Working...
      X