Announcement

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

  • Concatenating Temporary Matrices

    When we run the code

    Code:
    clear *
    net from "https://raw.githubusercontent.com/jgreathouse9/FDIDTutorial/main"
    net install fdid, replace
    
    
    cls
    
    u "https://github.com/jgreathouse9/FDIDTutorial/raw/main/smoking.dta"
    
    qui fdid cigsale, tr(treated) unitnames(state)
    
    loc T = e(T)
    
    mkf eventframe
    
    cwf eventframe
    
    svmat e(didframe), names(col)
    
    xtset id year
    
    cap qui xtdidregress (cigsale) (treat), ///
    group(id) time(year) ///
    vce(bootstrap, reps(50) seed(1466) dots(10))
    cls
    cap qui estat grangerplot, post nodraw
    ereturn list
    
    tempname cis effs unc point
    
    mat `cis'= e(ci_normal)'
    
    matrix `unc' = `cis'[(rowsof(`cis')+1) - `T'..., 1..2]
    cls
    mat `effs' = e(b)'
    
    matrix `point' = `effs'[(rowsof(`effs')+1) - `T'..., 1]
    
    mat l `unc'
    
    mat l `point'
    
    mat effs = `point'\`unc'
    we get

    Code:
    . mat l `unc'
    
    __000002[31,2]
                     ll          ul
    _lead19  -8.4543431   15.704343
    _lead18   -11.51243   12.912432
    _lead17   -17.82874   15.878735
    _lead16  -19.797317   18.297321
    _lead15  -17.689872   19.189864
    _lead14  -17.309823   20.459825
    _lead13  -15.092363   18.142366
    _lead12  -9.9613119   13.211312
    _lead11  -7.2719302    13.02193
    _lead10  -9.3121778   10.862177
     _lead9  -8.8646666   8.9146621
     _lead8  -10.672925   10.272923
     _lead7  -11.774687   10.224688
     _lead6  -9.4302961   8.8803045
     _lead5  -12.886588   17.036593
     _lead4  -5.6067273    8.356735
     _lead3  -4.9207772   8.9207657
     _lead2   .38994673   3.2100556
      _lag0  -5.2844066  -2.6655865
      _lag1  -8.3759589  -2.4740358
      _lag2  -19.509309   3.2593053
      _lag3  -22.172043   6.9720417
      _lag4  -25.949461   5.8494668
      _lag5  -32.395063    4.045065
      _lag6  -34.984833   3.7348332
      _lag7  -33.874241   4.1742399
      _lag8  -35.182563    5.932559
      _lag9  -35.370716  -.12928449
     _lag10  -35.605481   -5.744518
     _lag11  -35.784331  -3.5656713
      _cons    104.8436    161.1064
    
    .
    . mat l `point'
    
    __000003[31,1]
                     y1
    _lead19       3.625
    _lead18   .70000076
    _lead17  -.97500229
    _lead16  -.74999809
    _lead15   .74999619
    _lead14   1.5750008
    _lead13   1.5250015
    _lead12       1.625
    _lead11       2.875
    _lead10   .77499962
     _lead9   .02499771
     _lead8  -.20000076
     _lead7  -.77499962
     _lead6   -.2749958
     _lead5   2.0750027
     _lead4   1.3750038
     _lead3   1.9999943
     _lead2   1.8000011
      _lag0  -3.9749966
      _lag1  -5.4249973
      _lag2  -8.1250019
      _lag3  -7.6000004
      _lag4  -10.049997
      _lag5  -14.174999
      _lag6     -15.625
      _lag7      -14.85
      _lag8  -14.625002
      _lag9      -17.75
     _lag10  -20.674999
     _lag11  -19.675001
      _cons     132.975
    I wish to concatenate these together into a one matrix such that we have our point estimates and upper and lower bounds alongside each other. But when I do this, I get

    Code:
    mat effs = `point'\`unc'
    __000003`unc not found
    r(111);
    Why might this be? And how would I navigate this issue?
    Last edited by Jared Greathouse; 03 Sep 2024, 11:05.

  • #2
    use , not \

    Comment


    • #3
      Why? Because the backslash is an escape character and prevents macro substitution.
      Code:
      tempname a b
      
      matrix `a' = 1,2
      matrix `b' = 3,4
      mat c = `a'\\`b'
      
      matlist c

      Comment

      Working...
      X