Package 'DPTM'

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

Help Index


Example Dataset d1

Description

A simulated dataset for demonstrating the package

Usage

d1

Format

## 'd1' A data.frame with 1000 rows and 7 columns:

id

individuals

year

periods

y

dependent variable

y1

the first lag of y

q

threshold variable

x

regressor with threshold effects

z

regressor without threshold effects

Source

Simulated data with two thresholds


Dynamic panel model with fixed effects.

Description

Use a MLE procedure to estimate the dynamic panel model with fixed effects.

Usage

DPML(formula, data, index=NULL, timeFE = FALSE, y1 = NULL,...)

## S6 method for class 'DPTM' 
#print(...)

Arguments

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, seestats::nlm.

Details

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:

yit=ρyit1+β1x1,it+β2x2,it+αi+uity_{it}=\rho y_{it-1}+\beta_1x_{1,it}+\beta_2x_{2,it}+\alpha_i+u_{it}

, can use y~x1+x2.

For a special dynamic panel model with fixed effects having the following form:

Δyit=ρyit1+β1x1,it+β2x2,it+αi+uit\Delta y_{it}=\rho y_{it-1}+\beta_1x_{1,it}+\beta_2x_{2,it}+\alpha_i+u_{it}

, can use dy~x1+x2 with y1=yit1= y_{it-1}.

We assume the exogenous regressor xx is weakly exogenous, and thus the first period after difference is given by

Δyi1=δ0+δ1Δxi1+vi1,\Delta y_{i1}=\delta_0 + {\boldsymbol\delta}'_1 \Delta {\bf x}_{i1}+ v_{i1},

where E(vi1Δxi1)=0E(v_{i1}| \Delta {\bf x}_{i1} )=0. E(vi12)=σv2E(v_{i1}^2)=\sigma^2_v, E(vi1Δui2)=σu2E(v_{i1}\Delta u_{i2})=-\sigma^2_u and E(vi1Δuit)=0E(v_{i1} \Delta u_{it})=0 for t=3,4,...,Tt=3,4,...,T and i=1,...,Ni=1,...,N. 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.

Value

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

Author(s)

Hujie Bai

References

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.

Examples

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)

Dynamic panel multiple threshold model with fixed effects.

Description

Use a MCMC-MLE based on two-step procedure to estimate the dynamic panel multiple threshold model with fixed effects.

Usage

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(...)

Arguments

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)

Details

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

yit=(ρ1yit1+β1xit)I(qitγ)+(ρ2yit1+β2xit)I(qit>γ)+αi+uit,\begin{aligned}y_{i t} &=\left(\rho_1 y_{i t-1}+\beta_1 x_{i t}\right) I\left(q_{i t}\leq \gamma\right)+\left(\rho_2 y_{i t-1}+\beta_2 x_{i t}\right) I\left(q_{i t}> \gamma\right)\\&+\alpha_i+u_{i t},\end{aligned}

, can use DPTS(y~x,data = data, q = q, Th = 1).

For a threshold model who has regressors with threshold effects (xx) and regressors without threshold effects (zz)

yit=(ρ1yit1+β1xit)I(qitγ)+(ρ2yit1+β2xit)I(qit>γ)+θzit+αi+uit,\begin{aligned}y_{i t} &=\left(\rho_1 y_{i t-1}+\beta_1 x_{i t}\right) I\left(q_{i t}\leq \gamma\right)+\left(\rho_2 y_{i t-1}+\beta_2 x_{i t}\right) I\left(q_{i t}> \gamma\right)\\&+\theta z_{i t}+\alpha_i+u_{i t},\end{aligned}

, 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 y1y_1), like

yit=ρyit1+β1xitI(qitγ)+β2xitI(qit>γ)+θzit+αi+uit,\begin{aligned}y_{i t} &= \rho y_{i t-1}+ \beta_1 x_{i t} I\left(q_{i t}\leq \gamma\right)+\beta_2 x_{i t} I\left(q_{i t}> \gamma\right)\\&+\theta z_{i t}+\alpha_i+u_{i t},\end{aligned}

, can use DPTS(y~x,y~z,data = data, q = q, Th = 1, NoY = TRUE).

And, the threshold model with the following form

yit=ρ1yit1I(qitγ)+ρ2yit1I(qit>γ)+βxit+θzit+αi+uit,\begin{aligned}y_{i t} &=\rho_1 y_{i t-1}I\left(q_{i t}\leq \gamma\right)+\rho_2 y_{i t-1}I\left(q_{i t}> \gamma\right)+\beta x_{i t}\\&+\theta z_{i t}+\alpha_i+u_{i t},\end{aligned}

, 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

Δyit=(ρ1yit1+β1xit)I(qitγ)+(ρ2yit1+β2xit)I(qit>γ)+θzit+αi+uit,\begin{aligned}\Delta y_{i t} &=\left(\rho_1 y_{i t-1}+\beta_1 x_{i t}\right) I\left(q_{i t}\leq \gamma\right)+\left(\rho_2 y_{i t-1}+\beta_2 x_{i t}\right) I\left(q_{i t}> \gamma\right)\\&+\theta z_{i t}+\alpha_i+u_{i t},\end{aligned}

, can use DPTS(dy~x,dy~z,data = data, q = q, Th = 1) with y1=yit1= y_{it-1}.

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 xx is weakly exogenous, and thus the first period after difference is given by

Δyi1=δ0+δ1Δxi1+vi1,\Delta y_{i1}=\delta_0 + {\boldsymbol\delta}'_1 \Delta {\bf x}_{i1}+ v_{i1},

where E(vi1Δxi1)=0E(v_{i1}| \Delta {\bf x}_{i1} )=0. E(vi12)=σv2E(v_{i1}^2)=\sigma^2_v, E(vi1Δui2)=σu2E(v_{i1}\Delta u_{i2})=-\sigma^2_u and E(vi1Δuit)=0E(v_{i1} \Delta u_{it})=0 for t=3,4,...,Tt=3,4,...,T and i=1,...,Ni=1,...,N. 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.

Value

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

Author(s)

Hujie Bai

References

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.

Examples

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)

Example Dataset Growth_Inflation

Description

A dataset for economic growth of 74 countries from 1961 to 2015 (five-year average).

Usage

Growth_Inflation

Format

## 'Growth_Inflation' A data.frame with 814 rows and 15 columns:

ncountry

country id

countryname

country name

code

country code

Period

Period

years

years

GDP per capita growth

the difference of ln(GDP per capita)

Inflation rate-semilog

the semi-log of Inflation rate

Transitional convergence

the lag of ln(GDP per capita)

Human capital

Human capital

Financial depth

Financial depth

Governance

Governance

Public infrastructure

Public infrastructure

Trade openness

Trade openness

Economic instability

Economic instability

Inflation rate

Inflation rate

Source

https://doi.org/10.1080/07474938.2019.1624401


Tests for multiple thresholds.

Description

Tests for models with different thresholds, using bootstrap method.

Usage

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,...)

Arguments

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'.

Details

Threshold_Test can run the Test for multiple thresholds (Th is H1). The statistic is

Fs=S(γ^s1)S(γ^s)S(γ^s)/N(T1),F_s=\frac{S\left(\hat{\gamma}_{s-1}\right)-S\left(\hat{\gamma}_s\right)}{S\left(\hat{\gamma}_s\right) / N(T-1)},

where ss is the number of thresholds in H1, S(γ^s1)=lnL(γ^s1)S\left(\hat{\gamma}_{s-1}\right)=-\ln L\left(\hat{\gamma}_{s-1}\right) and S(γ^s)=lnL((γ^s1,γ^s))S\left(\hat{\gamma}_s\right)=-\ln L\left(\left(\hat{\gamma}_{s-1}^{\prime}, \hat{\gamma}_s\right)^{\prime}\right). 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.

Value

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.

Author(s)

Hujie Bai

References

Ramírez-Rondán, N. R. (2020). Maximum likelihood estimation of dynamic panel threshold models. Econometric Reviews, 39(3), 260-276.

Examples

### 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