Skip to content

Commit

Permalink
s
Browse files Browse the repository at this point in the history
s
  • Loading branch information
friosavila committed Apr 24, 2024
1 parent 9eae769 commit b51145f
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 9 deletions.
16 changes: 15 additions & 1 deletion jwdid/jwdid_estat.ado
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*! v1.71 FRA. Bug with Pretrend
*! v1.72 FRA. Anticipation without Never
* v1.71 FRA. Bug with Pretrend
* v1.7 FRA. Fixes how to Store Table (with new names)
* v1.6 FRA. Fixes to esave, and Orestriction
* v1.51 FRA. adds Window to event
Expand Down Expand Up @@ -317,6 +318,19 @@ program define jwdid_event, rclass

*qui:replace __event__ =__event__ - 1 if __event__ <0
if "`e(type)'"=="notyet" {
****
local nvr = "on"
capture drop __event2__
qui:sum __event__ , meanonly
local rmin = r(min)
qui:replace __event__=1+__event__-r(min)
qui:levelsof __event__, local(lv)
foreach i of local lv {
label define __event__ `i' "`=-1+`i'+`rmin''", modify
}
label values __event__ __event__

****
if "`asis'"=="" {
qui:margins [`weight'`exp'], subpop(if `sel' & __etr__==1 & `tosel') at(__tr__=(0 1)) ///
over(__event__) noestimcheck contrast(atcontrast(r)) ///
Expand Down
16 changes: 8 additions & 8 deletions jwdid/jwdid_plot.ado
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ program jwdid_plot_wh
qui:replace `kk'="`i'" in `k'
}
tempname k2
qui:encode `kk', gen(`k2')
qui:destring `kk', gen(`k2')

jwdid_plot_group `k2' `mm1' `mm5' `mm6' , ///
`style' `title' `name' `ytitle' `xtitle' `legend' `options'
Expand Down Expand Up @@ -145,7 +145,7 @@ program jwdid_plot_wh
qui:replace `kk'="`i'" in `k'
}
tempname k2
qui:encode `kk', gen(`k2')
qui:destring `kk', gen(`k2')

jwdid_plot_calendar `k2' `mm1' `mm5' `mm6' , ///
`style' `title' `name' `ytitle' `xtitle' `legend' `options'
Expand Down Expand Up @@ -370,18 +370,18 @@ program jwdid_plot_group
gettoken ll rest:rest
gettoken uu rest:rest

qui:levelsof `t', local(tlev)
/*qui:levelsof `t', local(tlev)
local tlb: value label `t'
local xlab 0 " "
foreach i of local tlev {
local j = `j'+1
local xlab `xlab' `i' "`:label `tlb' `i''"
}
}*/

if `"`xtitle'"'=="" local xtitle xtitle("Groups")
if `"`ytitle'"'=="" local ytitle ytitle("ATT")

local xlab `xlab' `=`j'+1' " "
*local xlab `xlab' `=`j'+1' " "

jwdid_default , `options' `style'
local gf11 `s(df11)'
Expand All @@ -406,19 +406,19 @@ program jwdid_plot_calendar
gettoken ll rest:rest
gettoken uu rest:rest

qui:levelsof `t', local(tlev)
/*qui:levelsof `t', local(tlev)
local tlb: value label `t'
local xlab 0 " "
foreach i of local tlev {
local j = `j'+1
local xlab `xlab' `i' "`:label `tlb' `i''"
}
}*/

if `"`xtitle'"'=="" local xtitle xtitle("Periods")
if `"`ytitle'"'=="" local ytitle ytitle("ATT")


local xlab `xlab' `=`j'+1' " "
*local xlab `xlab' `=`j'+1' " "

jwdid_default , `options' `style'
local gf11 `s(df11)'
Expand Down
60 changes: 60 additions & 0 deletions jwdid/unit_test.do
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
** Unit test
clear
set seed 1
set obs 2000
gen ivar = _n
gen gvar = runiformint(3,6)
replace gvar = 0 if runiform()<.2
gen x1 = runiform()
xtile dx=x1, n(2)
expand 10
bysort ivar:gen tvar = _n
gen te = 1*(t>=(g-1) )*(g!=0)
gen y = (rnormal()) + te

** installation
capture program drop _all
net install jwdid, from(C:\Users\Fernando\Documents\GitHub\stpackages\) replace
** Run
cd "C:\Users\Fernando\Documents\GitHub\stpackages\jwdid"


jwdid y , ivar(ivar) tvar(tvar) gvar(gvar) anti(3)
estat event, predict(xb)
estat plot
estat group, predict(xb)
estat plot
estat calendar, predict(xb)
estat plot
estat simple, over(dx) predict(xb)
estat plot

jwdid y , tvar(tvar) gvar(gvar)
estat event, predict(xb)
estat plot
estat group, predict(xb)
estat plot
estat calendar, predict(xb)
estat plot
estat simple, over(dx) predict(xb)
estat plot

jwdid y , ivar(ivar) tvar(tvar) gvar(gvar) never
estat event, predict(xb)
estat plot
estat group, predict(xb)
estat plot
estat calendar, predict(xb)
estat plot
estat simple, over(dx) predict(xb)
estat plot

jwdid y x1, tvar(tvar) gvar(gvar) never cluster(ivar)
estat event, pretrend
estat plot
estat group
estat plot
estat calendar
estat plot
estat simple, over(dx)
estat plot

0 comments on commit b51145f

Please sign in to comment.