diff --git a/csdid3/csdid.mata b/csdid3/csdid.mata index 13847c5..7923e7f 100644 --- a/csdid3/csdid.mata +++ b/csdid3/csdid.mata @@ -234,7 +234,11 @@ 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,] @@ -242,8 +246,7 @@ void csdid::csdid_setup(){ 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() @@ -522,8 +525,8 @@ 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,] @@ -531,7 +534,8 @@ void csdid::csdid(){ wvar = wvar[ord,] frif = frif[ord,] frwt = frwt[ord,] - } + }*/ + aux = J(0,0,.) } @@ -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,.) } diff --git a/csdid3/csdid_stats.mata b/csdid3/csdid_stats.mata index cbba56e..7725e22 100644 --- a/csdid3/csdid_stats.mata +++ b/csdid3/csdid_stats.mata @@ -212,17 +212,25 @@ 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){ @@ -230,7 +238,7 @@ void csdid_estat::atts_wboot(class csdid scalar csdid){ if (test_type==1) { // ATTGT error=0 - erif_attgt() + erif_attgt(csdid) onames=attgt_names(csdid)' mboot_any(csdid) make_table()