这是王群勇老师的xthreg命令:
Title
xthreg -- Estimate fixed-effect panel threshold model
Syntax
xthreg depvar [indepvars] [if] [in], rx(varlist) qx(varname) [thnum(#) grid(#) trim(numlist) bs(numlist) thlevel(#) gen(newvarname) noreg nobslog
thgiven options]
where depvar is the dependent variable and indepvars are the regime-independent variables.
Description
xthreg fits fixed-effect panel threshold models based on the method proposed by Hansen (1999). xthreg uses [XT] xtreg to fit the fixed-effect panel
threshold model given the threshold estimator. The fixed-effect panel threshold model requires balanced panel data, which is checked automatically
by xthreg. The estimation and test of the threshold effect are computed in Mata.
Options
rx(varlist) is the regime-dependent variable. Time-series operators are allowed. rx() is required.
qx(varname) is the threshold variable. Time-series operators are allowed. qx() is required.
thnum(#) is the number of thresholds. In the current version (Stata 13), # must be equal to or less than 3. The default is thnum(1).
grid(#) is the number of grid points. grid() is used to avoid consuming too much time when computing large samples. The default is grid(300).
trim(numlist) is the trimming proportion to estimate each threshold. The number of trimming proportions must be equal to the number of thresholds
specified in thnum(). The default is trim(0.01) for all thresholds. For example, to fit a triple-threshold model, you may set trim(0.01 0.01
0.05).
bs(numlist) is the number of bootstrap replications. If bs() is not set, xthreg does not use bootstrap for the threshold-effect test.
thlevel(#) specifies the confidence level, as a percentage, for confidence intervals of the threshold. The default is thlevel(95).
gen(newvarname) generates a new categorical variable with 0, 1, 2, ... for each regime. The default is gen(_cat).
noreg suppresses the display of the regression result.
nobslog suppresses the iteration process of the bootstrap.
thgiven fits the model based on previous results.
options are any options available for [XT] xtreg.
Time-series operators are allowed in depvar, indepvars, rx(), and qx().
Examples
Setup
. use hansen1999
Estimate a single-threshold model
. xthreg i q1 q2 q3 d1 qd1, rx(c1) qx(d1) thnum(1) trim(0.01) grid(400) bs(300)
Estimate a triple-threshold model given the estimated result above
. xthreg i q1 q2 q3 d1 qd1, rx(c1) qx(d1) thnum(3) trim(0.01 0.01 0.05) bs(0 300 300) thgiven
. xthreg i q1 q2 q3 d1 qd1, rx(c1) qx(d1) thnum(3) trim(0.01 0.01 0.05) grid(400) bs(300 300 300)
Estimate a triple-threshold model directly
. xthreg i q1 q2 q3 d1 qd1, rx(c1) qx(d1) thnum(3) trim(0.01 0.01 0.05) bs(300 300 300)
Plot the confidence interval using likelihood-ratio (LR) statistics
. _matplot e(LR21), columns(1 2) yline(7.35, lpattern(dash)) connect(direct) msize(small) mlabp(0) mlabs(zero) ytitle("LR Statistics")
xtitle("First Threshold") recast(line) name(LR21) nodraw
. _matplot e(LR22), columns(1 2) yline(7.35, lpattern(dash)) connect(direct) msize(small) mlabp(0) mlabs(zero) ytitle("LR Statistics")
xtitle("Second Threshold") recast(line) name(LR22) nodraw
. graph combine LR21 LR22, cols(1)
|