Title: | Dynamic Panel Multiple Threshold Model with Fixed Effects |
---|---|
Description: | Compute the fixed effects dynamic panel threshold model suggested by Ramírez-Rondán (2020) <doi:10.1080/07474938.2019.1624401>, and dynamic panel linear model suggested by Hsiao et al. (2002) <doi:10.1016/S0304-4076(01)00143-9>, where maximum likelihood type estimators are used. Multiple thresholds estimation based on Markov Chain Monte Carlo (MCMC) is allowed, and model selection of linear model, threshold model and multiple threshold model is also allowed. |
Authors: | Bai Hujie [aut, cre, cph] |
Maintainer: | Bai Hujie <[email protected]> |
License: | GPL (>= 3) |
Version: | 3.0.2 |
Built: | 2025-03-22 03:32:02 UTC |
Source: | https://github.com/hujiebai/dptm |
A simulated dataset for demonstrating the package
d1
d1
## 'd1' A data.frame with 1000 rows and 7 columns:
individuals
periods
dependent variable
the first lag of y
threshold variable
regressor with threshold effects
regressor without threshold effects
Simulated data with two thresholds
Use a MLE procedure to estimate the dynamic panel model with fixed effects.
DPML(formula, data, index=NULL, timeFE = FALSE, y1 = NULL,...) ## S6 method for class 'DPTM' #print(...)
DPML(formula, data, index=NULL, timeFE = FALSE, y1 = NULL,...) ## S6 method for class 'DPTM' #print(...)
formula |
formula of the covariates with threshold effects. |
data |
data frame of the observed data. |
index |
variable names of individuals and period; If a setting is not provided, defaults (the first variables in data will be as "id", while the second will be "year") will be used. Defaults to 'NULL'. |
timeFE |
logicals. If TRUE the time fixed effects will be allowed. Defaults to 'FALSE'. |
y1 |
lags of dependent variables; If a setting is not provided, defaults (the first-order lag) will be used. Defaults to 'NULL'. |
... |
additional arguments, see |
DPML
can fit the dynamic panel model with fixed effects proposed by Hsiao et al. (2002), which is based on the first difference and the maximum likelihood (MLE) method.
For a classical dynamic panel model with fixed effects having following form:
,
can use y~x1+x2
.
For a special dynamic panel model with fixed effects having the following form:
,
can use dy~x1+x2
with y1
.
We assume the exogenous regressor is weakly exogenous, and
thus the first period after difference is given by
where .
,
and
for
and
.
For more details, see Hsiao et al. (2002).
In addition, we solve the log-likelihood function by stats::nlm
who uses iterlim
to set the maximum number of iterations, and thus iterlim
is allowed by ...
in DPML
.
DPML returns an object of class "DPTM".
The function print
are used to obtain and print a print of the results.
An object of class "DPTM" is a list containing at least the following components:
coefficients |
a named vector of coefficients |
NNLL |
the negative log-likelihood function value |
Zvalues |
a vector of t statistics |
Ses |
a vector of standard errors |
covariance_matrix |
a covariance matrix |
Th |
the number of thresholds |
thresholds |
a named vector of thresholds |
Hujie Bai
Hsiao, C., Pesaran, M. H., & Tahmiscioglu, A. K. (2002). Maximum likelihood estimation of fixed effects dynamic panel data models covering short time periods. Journal of econometrics, 109(1), 107-150.
data(d1) # No time fixed effects model1 <- DPML(y~x+z, data = d1) print(model1) # With time fixed effects model2 <- DPML(y~x+z, data = d1, timeFE = TRUE) print(model2)
data(d1) # No time fixed effects model1 <- DPML(y~x+z, data = d1) print(model1) # With time fixed effects model2 <- DPML(y~x+z, data = d1, timeFE = TRUE) print(model2)
Use a MCMC-MLE based on two-step procedure to estimate the dynamic panel multiple threshold model with fixed effects.
DPTS(formula = NULL, formula_cv = NULL, data, index=NULL, Th = 1, q, timeFE = FALSE, NoY = FALSE, y1 = NULL, iterations = 2000, sro = 0.1, r0x = NULL, r1x = NULL, ...) ## S6 method for class 'DPTM' #print(...)
DPTS(formula = NULL, formula_cv = NULL, data, index=NULL, Th = 1, q, timeFE = FALSE, NoY = FALSE, y1 = NULL, iterations = 2000, sro = 0.1, r0x = NULL, r1x = NULL, ...) ## S6 method for class 'DPTM' #print(...)
formula |
formula of the covariates with threshold effects; If a setting is not provided, defaults (no covariates with threshold effects) will be used. Defaults to 'NULL'. |
formula_cv |
formula of the covariates without threshold effects; If a setting is not provided, defaults (no covariates without threshold effects) will be used. Defaults to 'NULL'. |
data |
data frame of the observed data. |
index |
variable names of individuals and period; If a setting is not provided, defaults (the first variables in data will be as "id", while the second will be "year") will be used.Defaults to 'NULL'. |
Th |
number of thresholds; Defaults to '1'. |
q |
threshold variable. |
timeFE |
logicals. If TRUE the time fixed effects will be allowed. Defaults to 'FALSE'. |
NoY |
logicals. If TRUE the lags of dependent variables will be without threshold effects. Defaults to 'FALSE'. |
y1 |
lags of dependent variables; If a setting is not provided, defaults (the first-order lag) will be used. Defaults to 'NULL'. |
iterations |
MCMC iterations (50% used for burnining). Defaults to '2000'. |
sro |
regime (subsample) proportion; If a setting is not provided, defaults (10%) will be used. Defaults to '0.1'. |
r0x |
lower bound of threshold parameter space; If a setting is not provided, defaults (15% quantile of threshold variable) will be used. |
r1x |
upper bound of threshold parameter space; If a setting is not provided, defaults (85% quantile of threshold variable) will be used. |
... |
additional arguments to be passed to the settings of MCMC (see BayesianTools::applySettingsDefault) |
DPTS
can fit the dynamic panel threshold model with fixed effects proposed
by Ramírez-Rondán (2020), and also allow a multiple threshold model by setting
Th
> 1.
Given the diverse forms and versatile applications of threshold models, we advocate for aligning model selection with specific research objectives, thereby granting users autonomy in specifying the model structure.
Take the model with one threshold (Ramírez-Rondán, 2020) as example.
For a standard threshold model
,
can use DPTS(y~x,data = data, q = q, Th = 1)
.
For a threshold model who has regressors with threshold effects () and regressors without threshold effects (
)
,
can use DPTS(y~x,y~z,data = data, q = q, Th = 1)
.
If user only cares about the regressors with threshold effects (thus hopes there is no threshold effects in the lag of dependent variable ), like
,
can use DPTS(y~x,y~z,data = data, q = q, Th = 1, NoY = TRUE)
.
And, the threshold model with the following form
,
is also allowed by DPTS(NULL,y~x+z,data = data, q = q, Th = 1)
.
In addition, a special threshold model having the following form
,
can use DPTS(dy~x,dy~z,data = data, q = q, Th = 1)
with y1
.
The MCMC we used is based on BayesianTools, and the default method is "DREAMzs" (see Vrugt et al., 2009).
If user wants to use other MCMC, can use ...
(see BayesianTools::applySettingsDefault).
As for the length of iterations, it can be set by iterations
(50% used for burnining) and default length is 2000.
The trace plot and the Gelman and Rubin's convergence diagnostic are supplied by DPTS
(print
) to test the convergence of MCMC sample.
Additionally, we assume the exogenous regressor is weakly exogenous, and
thus the first period after difference is given by
where .
,
and
for
and
.
For more details, see Hsiao et al. (2002).
Finally, we solve the log-likelihood function by stats::nlm
who uses iterlim
to set the maximum number of iterations, and thus iterlim
is allowed by ...
in DPTS
.
DPTS returns an object of class "DPTM".
The function print
are used to obtain and print a print of the results.
An object of class "DPTM" is a list containing at least the following components:
coefficients |
a named vector of coefficients |
NNLL |
the negative log-likelihood function value |
Zvalues |
a vector of t statistics |
Ses |
a vector of standard errors |
covariance_matrix |
a covariance matrix |
Th |
the number of thresholds |
thresholds |
a named vector of thresholds |
Hujie Bai
Ramírez-Rondán, N. R. (2020). Maximum likelihood estimation of dynamic panel threshold models. Econometric Reviews, 39(3), 260-276.
Vrugt, Jasper A., et al. (2009)."Accelerating Markov chain Monte Carlo simulation by differential evolution with self-adaptive randomized subspace sampling." International Journal of Nonlinear Sciences and Numerical Simulation 10.3: 273-290.
Hsiao, C., Pesaran, M. H., & Tahmiscioglu, A. K. (2002). Maximum likelihood estimation of fixed effects dynamic panel data models covering short time periods. Journal of econometrics, 109(1), 107-150.
data(d1) # single threshold ## standard form #Model1_1 <- DPTS(y~x,data = d1, index = c('id','year'), q = d1$q, Th = 1, #iterations = 1000) #print(Model1_1) ### Examples elapsed time > 15s ## with x \& z #Model2_1 <- DPTS(y~x,y~z,data = d1, index = c('id','year'), q = d1$q, Th = 1, #iterations = 1000) #print(Model2_1) ## with x \& z (y1 no threshold effects) #Model3_1 <- DPTS(y~x,y~z,data = d1, index = c('id','year'), q = d1$q, Th = 1, #NoY = TRUE, iterations = 1000) #print(Model3_1) ## only y1 with threshold effects #Model4_1 <- DPTS(NULL,y~x+z,data = d1, index = c('id','year'), q = d1$q, Th = 1, #iterations = 1000) #print(Model4_1) # two thresholds (Th = 2) ## with x \& z #Model2_2 <- DPTS(y~x,y~z,data = d1, index = c('id','year'), q = d1$q, Th = 2, #iterations = 1000) #print(Model2_2) # Adding time fixed effects (timeFE = TRUE) #Model2_2T <- DPTS(y~x,y~z,data = d1, index = c('id','year'), q = d1$q, Th = 2, #timeFE = TRUE, iterations = 1000) #print(Model2_2T)
data(d1) # single threshold ## standard form #Model1_1 <- DPTS(y~x,data = d1, index = c('id','year'), q = d1$q, Th = 1, #iterations = 1000) #print(Model1_1) ### Examples elapsed time > 15s ## with x \& z #Model2_1 <- DPTS(y~x,y~z,data = d1, index = c('id','year'), q = d1$q, Th = 1, #iterations = 1000) #print(Model2_1) ## with x \& z (y1 no threshold effects) #Model3_1 <- DPTS(y~x,y~z,data = d1, index = c('id','year'), q = d1$q, Th = 1, #NoY = TRUE, iterations = 1000) #print(Model3_1) ## only y1 with threshold effects #Model4_1 <- DPTS(NULL,y~x+z,data = d1, index = c('id','year'), q = d1$q, Th = 1, #iterations = 1000) #print(Model4_1) # two thresholds (Th = 2) ## with x \& z #Model2_2 <- DPTS(y~x,y~z,data = d1, index = c('id','year'), q = d1$q, Th = 2, #iterations = 1000) #print(Model2_2) # Adding time fixed effects (timeFE = TRUE) #Model2_2T <- DPTS(y~x,y~z,data = d1, index = c('id','year'), q = d1$q, Th = 2, #timeFE = TRUE, iterations = 1000) #print(Model2_2T)
A dataset for economic growth of 74 countries from 1961 to 2015 (five-year average).
Growth_Inflation
Growth_Inflation
## 'Growth_Inflation' A data.frame with 814 rows and 15 columns:
country id
country name
country code
Period
years
the difference of ln(GDP per capita)
the semi-log of Inflation rate
the lag of ln(GDP per capita)
Human capital
Financial depth
Governance
Public infrastructure
Trade openness
Economic instability
Inflation rate
https://doi.org/10.1080/07474938.2019.1624401
Tests for models with different thresholds, using bootstrap method.
Threshold_Test(formula = NULL, formula_cv = NULL, data, index=NULL, Th = 1, q, timeFE = FALSE, bt = 100,NoY = FALSE, y1 = NULL, iterations = 2000, sro = 0.1, r0x = NULL, r1x = NULL, parallel=TRUE, seed = NULL,...)
Threshold_Test(formula = NULL, formula_cv = NULL, data, index=NULL, Th = 1, q, timeFE = FALSE, bt = 100,NoY = FALSE, y1 = NULL, iterations = 2000, sro = 0.1, r0x = NULL, r1x = NULL, parallel=TRUE, seed = NULL,...)
formula |
formula of the covariates with threshold effects; If a setting is not provided, defaults (no covariates with threshold effects) will be used. Defaults to 'NULL'. |
formula_cv |
formula of the covariates without threshold effects; If a setting is not provided, defaults (no covariates without threshold effects) will be used. Defaults to 'NULL'. |
data |
data frame of the observed data. |
index |
variable names of individuals and period; If a setting is not provided, defaults (the first variables in data will be as "id", while the second will be "year") will be used.Defaults to 'NULL'. |
q |
threshold variable. |
timeFE |
logicals. If TRUE the time fixed effects will be allowed. Defaults to 'FALSE'. |
bt |
the number of bootstrap; If a setting is not provided, defaults (bt = 100) will be used. Defaults to '100'. |
NoY |
logicals. If TRUE the lags of dependent variables will be without threshold effects. Defaults to 'FALSE'. |
y1 |
lags of dependent variables; If a setting is not provided, defaults (the first-order lag) will be used. Defaults to 'NULL'. |
iterations |
MCMC iterations (50% used for burnining). Defaults to '2000'. |
sro |
regime (subsample) proportion; If a setting is not provided, defaults (10%) will be used. Defaults to '0.1'. |
r0x |
lower bound of threshold parameter space; If a setting is not provided, defaults (15% quantile of threshold variable) will be used. |
r1x |
upper bound of threshold parameter space; If a setting is not provided, defaults (85% quantile of threshold variable) will be used. |
parallel |
logicals. If TRUE test will run in parallel for saving time. Defaults to 'TRUE'. |
seed |
set seeds to guarantee the replication the test (see set.seed); |
... |
additional arguments to be passed to the settings of MCMC (see BayesianTools::applySettingsDefault) |
Th |
number of thresholds; Defaults to '1'. |
Threshold_Test
can run the Test for multiple thresholds (Th
is H1).
The statistic is
where is the number of thresholds in H1,
and
.
And the p-value is computed by bootstrap method (see Ramírez-Rondán, 2020).
Take the two threshold model as example.
User must set Th
= 1 firstly to reject the null hypothesis of no threshold effects;
Then he should set Th
= 2 to reject the null hypothesis of only one threshold;
Lastly, set Th
= 3 to accept the null hypothesis of two thresholds.
In other words, p-values of the first test (Th
= 1) and the second test (Th
= 1) should be less than significant level while the third test (Th
= 3) is not.
Threshold_Test
contains all augments in DPTS
, but with three new augments: bt
, parallel
and seed
.
bt
is the number of bootstrap (by default is 100);
parallel
can allow user to run test in parallel to save time;
seed
is used to guarantee the replication of tests.
It is worthy noting that the test shrinks to the so-called threshold existence test when Th
= 1.
A list with class "htest" containing the following components:
statistic |
the value of the F-statistic. |
parameter |
the degrees of freedom for the F-statistic. |
p.value |
the p-value for the test. |
null.value |
the specified hypothesized value of the null hypothesis. |
alternative |
a character string describing the alternative hypothesis. |
method |
a character string indicating what type of test was performed. |
data.name |
a character string giving the name(s) of the data. |
estimate |
the critical value of the statistic (5% significance level). |
LRs |
a vector of statistics from bootstrap. |
Hujie Bai
Ramírez-Rondán, N. R. (2020). Maximum likelihood estimation of dynamic panel threshold models. Econometric Reviews, 39(3), 260-276.
### Examples elapsed time > 15s #data(d1) # H0: no threshold effects (no threshold) #test0 <- Threshold_Test(y~x,y~z,data = d1, index = c('id','year'), q = d1$q, Th = 1, #bt = 50, iterations = 500) #test0 # H0: one threshold #test1 <- Threshold_Test(y~x,y~z,data = d1, index = c('id','year'), q = d1$q, Th = 2, #bt = 50, iterations = 500) #test1 # H0: two threshold #test2 <- Threshold_Test(y~x,y~z,data = d1, index = c('id','year'), q = d1$q, Th = 3, #bt = 50, iterations = 500) #test2
### Examples elapsed time > 15s #data(d1) # H0: no threshold effects (no threshold) #test0 <- Threshold_Test(y~x,y~z,data = d1, index = c('id','year'), q = d1$q, Th = 1, #bt = 50, iterations = 500) #test0 # H0: one threshold #test1 <- Threshold_Test(y~x,y~z,data = d1, index = c('id','year'), q = d1$q, Th = 2, #bt = 50, iterations = 500) #test1 # H0: two threshold #test2 <- Threshold_Test(y~x,y~z,data = d1, index = c('id','year'), q = d1$q, Th = 3, #bt = 50, iterations = 500) #test2