I guess your syntax was incorrect. You don't show it, so
extra comment is difficult.
Out of curiosity, I looked at the code in question
from http://www.bus.umich.edu/Academics/Departments/Accounting/nhafzall/
The maintainer of that web page has passed away. The program -fmJ-
has no help file but it is attributed to
Mitchell Petersen, Northwestern, 2005, who claims "Copywrite",
presumably extending to all errors,
and to
Judson A. Caskey, University of Michigan, 13-Dec-2005
but it seems that neither of these is active on Statalist,
or they might have commented.
-fmJ- should work with a -regress-like syntax as documented
inside the code.
The code does contain some weird and/or roundabout and/or
old-fashioned ways of doing things, and it does some things
repeatedly or with unnecessary extra storage, but otherwise
it looks legal and runs OK.
This version is about half the length, but partly because
it is sparse on comments. It may be of use or interest
but will not otherwise be developed or documented by me.
* Fama-MacBeth estimation of coefficients and standard errors
* Mitchell Petersen, 2005
* Judson A. Caskey, 13-Dec-2005
* NJC 5 Oct 2006
program fmj2
version 8
syntax varlist(numeric) [if] [in] [, siglev(real 0.05) ]
preserve
qui tsset
local tvar "`r(timevar)'"
qui statsby "reg `varlist' `in' `if'" _b _se _obs=e(N), ///
by(`tvar') clear
local nvar : word count `varlist'
sum _obs, meanonly
local nobs = r(sum)
tokenize `varlist'
local y "`1'"
mac shift
local rhs "`*'"
local d10 "{hline 10}"
local d11 "{hline 11}"
di _n as txt _col(14) " Beta" _col(28) " Std Error" ///
_col(42) " t-stat" _col(56) " p-value"
di _col(14) " `d10'" _col(28) " `d11'" ///
_col(42) " `d10'" _col(56) " `d10'"
qui foreach v of local rhs {
su b_`v'
local b`v' = r(mean)
local V = abbrev("`v'", 12)
noi di as txt "`V'" as res _col(14) %9.4f r(mean) ///
_col(28) %9.4f r(sd) / sqrt(r(N)) ///
_col(42) %9.3f r(mean) * sqrt(r(N)) / r(sd) ///
_col(56) %9.3f 2*ttail(r(N)-1,abs(r(mean)*sqrt(r(N))/r(sd)))
}
qui su b_cons
local bcons = r(mean)
di as txt "constant" as res _col(14) %9.4f r(mean) ///
_col(28) %9.4f r(sd) / sqrt(r(N)) ///
_col(42) %9.3f r(mean) * sqrt(r(N)) / r(sd) ///
_col(56) %9.3f 2*ttail(r(N)-1, abs(r(mean)*sqrt(r(N))/r(sd)))
local ntimes = r(N)
di _n as txt _col(14) " Pos" _col(28) " Pos/Sig*" ///
_col(42) " Neg" _col(56) " Neg/Sig*"
di _col(14) " `d10'" _col(28) " `d11'" _col(42) " `d10'" ///
_col(56) " `d10'"
qui foreach v of local rhs {
local issig ///
"2 * ttail(_obs - `nvar', abs(b_`v'/se_`v')) <= `siglev'"
local V = abbrev("`v'", 12)
count if (`issig') & !missing(b_`v')
local sig = r(N)
count if b_`v' > 0 & !missing(b_`v')
local pos = r(N)
count if b_`v' < 0 & !missing(b_`v')
local neg = r(N)
count if b_`v' > 0 & (`issig') & !missing(b_`v')
local possig = r(N)
count if b_`v' < 0 & (`issig') & !missing(b_`v')
noi di as txt "`V'" _col(14) as res %9.0f `pos' ///
_col(28) %9.0f `possig' _col(42) %9.0f `neg' _col(56) %9.0f r(N)
}
di _n as txt " * Significant at `siglev'"
restore
// Calculate R-sq based on the FM coefficient estimates
tempvar yhat
qui {
gen double `yhat' = `bcons'
foreach v of local rhs {
replace `yhat' = `yhat' + `v' * `b`v''
}
reg `y' `yhat' `if' `in'
}
di _n " R-squared = " as res %7.4f e(r2) ///
_n as txt " # of obs = " as res %7.0f `nobs' ///
_n as txt " # of times = " as res %7.0f `ntimes'
end
Nick
[email protected]
Jeronimo Perez Aleman
> I'm trying to run the Fama-Macbeth regression(F-M style, see
> fmJ.ado in
> http://www.bus.umich.edu/Academics/Departments/Accounting/nhaf
> zall/default.htm).
> I use stata 8.2 (updated). The message is:
> time-series operators not allowed.
> I do understand anything.
> Could anybody help me?
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/