Announcement

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

  • command tsvmat is unrecognized

    Hi, I am trying to run CSDiD model for staggered policy assignments.
    I was wondering if anyone could help me with how to fix this error message: command tsvmat is unrecognized while I was running the following code:
    FYI, my lab is currently not connected to internet, meaning I can't update the package in easy way. I suspect that the error might be related to the update issue with the related packages because the code runs well in my personal laptop.
    Thanks.


    Code:
    foreach policy in `POLICIES' {
        local gvar = "`G_`policy''"
        local ttl  = "`T_`policy''"
    
        eststo clear
        local i = 0
        foreach yvar in `OUTCOMES' {
    
            eststo model_`policy'_`i': csdid `yvar' `CONTROLS', ///
                ivar(uniqueid) time(year) gvar(`gvar') method(dripw) notyet ///
                cluster(uniqueid_cluster)
    
            estat event, estore(event_`policy'_`i') window(-6 6)
    
            local vartitle: variable label `yvar'
            if "`vartitle'"=="" local vartitle "`yvar'"
            csdid_plot, title("`ttl'" "Effect on `vartitle'")
            graph export "$OUT_GRAPHS/csdid_`policy'_`yvar'.png", as(png) replace
        }
    
        cd "$OUT_TABLES"
        capture noisily esttab event_`policy'_* using "table_event_`policy'_star.csv", ///
            b(%9.3f) se(%9.3f) star(* 0.10 ** 0.05 *** 0.01) replace compress unstack nonotes
        capture noisily esttab model_`policy'_* using "table_att_`policy'_star.csv", ///
            b(%9.3f) se(%9.3f) star(* 0.10 ** 0.05 *** 0.01) replace compress unstack nonotes
    }

  • #2
    Please explain the provenance of community-contributed commands you are using (FAQ Advice #12).

    csdid and estout are from SSC.

    tsvmat is bundled with the csdid package.

    Code:
    . ssc type tsvmat.ado
    
    *! V1 Creates Temporary new variables
    
    *capture program drop tsvmat
    program define tsvmat, return
            syntax anything, name(string)
            version 7
                     
            local nx = rowsof(matrix(`anything'))
            local nc = colsof(matrix(`anything'))
            ***************************************
            // here is where the safegards will be done.
            if _N<`nx' {
                display as result "Expanding observations to `nx'"
                    set obs `nx'
            }
            // here we create all variables
            foreach i in `name' {
                            local j = `j'+1
                            qui:gen `type' `i'=matrix(`anything'[_n,`j'])                    
            }
            // here is where they are renamed.
    
    end

    Comment


    • #3
      Thanks Nick, sorry for the insufficient source information.
      I am using csdid in Stata 18 and the analysis is based on firm-level business data (unbalanced panel). I will make sure of this from now.

      Comment

      Working...
      X