Skip to content

Commit

Permalink
s
Browse files Browse the repository at this point in the history
  • Loading branch information
friosavila committed Mar 8, 2024
1 parent b14b04c commit f1a76c8
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 20 deletions.
20 changes: 12 additions & 8 deletions csdid3/csdid.mata
Original file line number Diff line number Diff line change
Expand Up @@ -234,16 +234,19 @@ void csdid::csdid_setup(){
// if panel, first sort
type_data = 1
oid = 1::rows(yvar)
ord = order((ivar,tvar),(1,2))
if (length(cvar)>0) ord = order((cvar,ivar,tvar,),(1,2,3,4))
else ord = order((ivar,tvar),(1,2,3))
// If panel order by cluster, then individual, then time
//ord = order((ivar,tvar),(1,2))
if (ord!=oid) {
yvar=yvar[ord,]
if (length(xvar)>0) xvar=xvar[ord,]
tvar=tvar[ord,]
gvar=gvar[ord,]
if (length(wvar)>0) wvar=wvar[ord,]
ivar=ivar[ord,]
if (length(cvar)>0) cvar=cvar[ord,]
if (length(cvar)>0) cvar=cvar[ord,]
}
// then recode
makeid()
Expand Down Expand Up @@ -522,16 +525,17 @@ void csdid::csdid(){
if (length(cvar)>0) cvar= aux[,4]
}
/// Very last step. Sort important variables by Cvar?
if (length(cvar)>0) {
/// Very last step. Sort important variables by Cvar?: everything is sorted by this
/*if (length(cvar)>0) {
ord = order( (cvar,oid), (1,2) )
oid = oid[ord,]
cvar = cvar[ord,]
gvar = gvar[ord,]
wvar = wvar[ord,]
frif = frif[ord,]
frwt = frwt[ord,]
}
}*/
aux = J(0,0,.)
}
Expand Down Expand Up @@ -648,12 +652,12 @@ void csdid::spcsdid(){
}
/// Very last step. Sort important variables by Cvar?
if (length(cvar)>0) {
/*if (length(cvar)>0) {
sortcvar = order( (cvar,oid), (1,2) )
//oid = oid[ord,];cvar = cvar[ord,]
//gvar = gvar[ord,];wvar = wvar[ord,]
//frif = frif[ord,];frwt = frwt[ord,]
}
}*/
aux = J(0,0,.)
}
Expand Down
32 changes: 20 additions & 12 deletions csdid3/csdid_stats.mata
Original file line number Diff line number Diff line change
Expand Up @@ -212,25 +212,33 @@ void csdid_estat::fixrif(real matrix erif){
}
// erif should have only the important ERIFs
// This Saves
void csdid_estat::erif_attgt(){
real matrix spind, tosel
tosel = select_data(csdid)'
spind = select(csdid.spindex,tosel)
real scalar i
erif = J(rows(csdid.oid),length(spind),.)
for(i=1;i<=length(spind);i++){
erif[,i]=csdid.spcsdid[i].attgt[csdid.spcsdid[i].index,]
}
//
fixrif(erif)
void csdid_estat::erif_attgt(class csdid scalar csdid){
if (csdid.sparse == 1) {
// IF Sparse, then Reconstruct eRIF
real matrix spind, tosel
tosel = select_data(csdid)'
spind = select(csdid.spindex,tosel)
real scalar i
erif = J(rows(csdid.oid),length(spind),.)
for(i=1;i<=length(spind);i++){
erif[,i]=csdid.spcsdid[i].attgt[csdid.spcsdid[i].index,]
}
//
fixrif(erif)
}
else {
// If not. Just get the data
erif = select(csdid.frif,select_data(csdid)')
}
}
void csdid_estat::atts_wboot(class csdid scalar csdid){
// Estimate effects
if (test_type==1) {
// ATTGT
error=0
erif_attgt()
erif_attgt(csdid)
onames=attgt_names(csdid)'
mboot_any(csdid)
make_table()
Expand Down

0 comments on commit f1a76c8

Please sign in to comment.