Skip to content

Commit

Permalink
Fix #34 - hdfe was not allowing weights
Browse files Browse the repository at this point in the history
Also added test suite for that
  • Loading branch information
sergiocorreia committed Jul 26, 2015
1 parent f1bd03f commit 3ec56c5
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 20 deletions.
Binary file modified misc/reghdfe.zip
Binary file not shown.
13 changes: 7 additions & 6 deletions package/hdfe.ado
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*! reghdfe 3.2.1 25jul2015
*! reghdfe 3.2.2 26jul2015
*! Sergio Correia (sergio.correia@duke.edu)


Expand Down Expand Up @@ -1942,7 +1942,8 @@ program define hdfe, eclass
local keepvars `r(varlist)'
}

local 0 `partial' `anything' [`weight'`exp'] , absorb(`absorb') `options' ///
if ("`weight'"!="") local weight_part [`weight'=`exp']
local 0 `partial' `anything' `weight_part' , absorb(`absorb') `options' ///
cluster(`clustervars') cache(save, keepvars(`keepvars'))

* INITIAL CLEANUP
Expand All @@ -1962,7 +1963,7 @@ program define hdfe, eclass
GenUID `uid'
}

* PROBLEM:z
* PROBLEM:
* I can translate L(1/2).x into __L__x __L2__x
* But how can I translate i.x if I don't have the original anymore?

Expand Down Expand Up @@ -2109,7 +2110,7 @@ end
// -------------------------------------------------------------

program define Version, eclass
local version "3.2.1 25jul2015"
local version "3.2.2 26jul2015"
ereturn clear
di as text "`version'"
ereturn local version "`version'"
Expand Down Expand Up @@ -2223,7 +2224,7 @@ program define Parse

* Check that weights are correct (e.g. with fweight they need to be integers)
local num_type = cond("`weight'"=="fweight", "integers", "reals")
local basenote "weight {res}`weightvar'{txt} can only contain strictly positive `num_type', but"
local basenote "{txt}weight {res}`weightvar'{txt} can only contain strictly positive `num_type', but"
qui cou if `weightvar'<0
Assert (`r(N)'==0), msg("`basenote' `r(N)' negative values were found!") rc(402)
qui cou if `weightvar'==0
Expand All @@ -2232,7 +2233,7 @@ program define Parse
if (`r(N)'>0) di as text "`basenote' `r(N)' missing values were found (will be dropped)"
if ("`weight'"=="fweight") {
qui cou if mod(`weightvar',1) & `weightvar'<.
Assert (`r(N)'==0), msg("`basenote' `r(N)' non-integer values were found!") rc(401)
Assert (`r(N)'==0), msg("`basenote' `r(N)' non-integer values were found!" "{err} Stopping execution") rc(401)
}
}
local allkeys `allkeys' weightvar weighttype weightexp
Expand Down
2 changes: 1 addition & 1 deletion package/hdfe.pkg
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ d KW: within
d
d Requires: Stata version 11.2
d
d Distribution-Date: 20150725
d Distribution-Date: 20150726
d

f hdfe.ado
Expand Down
8 changes: 4 additions & 4 deletions package/reghdfe.ado
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*! reghdfe 3.2.1 25jul2015
*! reghdfe 3.2.2 26jul2015
*! Sergio Correia (sergio.correia@duke.edu)


Expand Down Expand Up @@ -2045,7 +2045,7 @@ end
// -------------------------------------------------------------

program define Version, eclass
local version "3.2.1 25jul2015"
local version "3.2.2 26jul2015"
ereturn clear
di as text "`version'"
ereturn local version "`version'"
Expand Down Expand Up @@ -2448,7 +2448,7 @@ program define Parse

* Check that weights are correct (e.g. with fweight they need to be integers)
local num_type = cond("`weight'"=="fweight", "integers", "reals")
local basenote "weight {res}`weightvar'{txt} can only contain strictly positive `num_type', but"
local basenote "{txt}weight {res}`weightvar'{txt} can only contain strictly positive `num_type', but"
qui cou if `weightvar'<0
Assert (`r(N)'==0), msg("`basenote' `r(N)' negative values were found!") rc(402)
qui cou if `weightvar'==0
Expand All @@ -2457,7 +2457,7 @@ program define Parse
if (`r(N)'>0) di as text "`basenote' `r(N)' missing values were found (will be dropped)"
if ("`weight'"=="fweight") {
qui cou if mod(`weightvar',1) & `weightvar'<.
Assert (`r(N)'==0), msg("`basenote' `r(N)' non-integer values were found!") rc(401)
Assert (`r(N)'==0), msg("`basenote' `r(N)' non-integer values were found!" "{err} Stopping execution") rc(401)
}
}
local allkeys `allkeys' weightvar weighttype weightexp
Expand Down
2 changes: 1 addition & 1 deletion package/reghdfe.pkg
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ d KW: GMM
d
d Requires: Stata version 11.2
d
d Distribution-Date: 20150725
d Distribution-Date: 20150726
d

f reghdfe.ado
Expand Down
5 changes: 3 additions & 2 deletions source/hdfe.ado
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ program define hdfe, eclass
local keepvars `r(varlist)'
}

local 0 `partial' `anything' [`weight'`exp'] , absorb(`absorb') `options' ///
if ("`weight'"!="") local weight_part [`weight'=`exp']
local 0 `partial' `anything' `weight_part' , absorb(`absorb') `options' ///
cluster(`clustervars') cache(save, keepvars(`keepvars'))

* INITIAL CLEANUP
Expand All @@ -67,7 +68,7 @@ program define hdfe, eclass
GenUID `uid'
}

* PROBLEM:z
* PROBLEM:
* I can translate L(1/2).x into __L__x __L2__x
* But how can I translate i.x if I don't have the original anymore?

Expand Down
2 changes: 1 addition & 1 deletion source/hdfe.pkg
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ d KW: within
d
d Requires: Stata version 11.2
d
d Distribution-Date: 20150725
d Distribution-Date: 20150726
d

f hdfe.ado
Expand Down
4 changes: 2 additions & 2 deletions source/internal/Parse.ado
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ program define Parse

* Check that weights are correct (e.g. with fweight they need to be integers)
local num_type = cond("`weight'"=="fweight", "integers", "reals")
local basenote "weight {res}`weightvar'{txt} can only contain strictly positive `num_type', but"
local basenote "{txt}weight {res}`weightvar'{txt} can only contain strictly positive `num_type', but"
qui cou if `weightvar'<0
Assert (`r(N)'==0), msg("`basenote' `r(N)' negative values were found!") rc(402)
qui cou if `weightvar'==0
Expand All @@ -88,7 +88,7 @@ program define Parse
if (`r(N)'>0) di as text "`basenote' `r(N)' missing values were found (will be dropped)"
if ("`weight'"=="fweight") {
qui cou if mod(`weightvar',1) & `weightvar'<.
Assert (`r(N)'==0), msg("`basenote' `r(N)' non-integer values were found!") rc(401)
Assert (`r(N)'==0), msg("`basenote' `r(N)' non-integer values were found!" "{err} Stopping execution") rc(401)
}
}
local allkeys `allkeys' weightvar weighttype weightexp
Expand Down
2 changes: 1 addition & 1 deletion source/reghdfe.pkg
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ d KW: GMM
d
d Requires: Stata version 11.2
d
d Distribution-Date: 20150725
d Distribution-Date: 20150726
d

f reghdfe.ado
Expand Down
2 changes: 1 addition & 1 deletion source/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.2.1 25jul2015
3.2.2 26jul2015
4 changes: 3 additions & 1 deletion test/test-hdfe.do
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,11 @@ cscript "hdfe" adofile reghdfe

* syntax()
sysuse auto, clear

hdfe price weight length, a(turn trunk) gen(R_) sample(smpl) clusterv(trunk)
hdfe price weight length, a(turn trunk) clear keepv(make) keepids clusterv(trunk)

sysuse auto, clear
hdfe price gear [w=weight], a(turn trunk) clear keepv(make) keepids clusterv(trunk)

cd "D:/Github/reghdfe/test"
exit

0 comments on commit 3ec56c5

Please sign in to comment.