使用 Arellano 和 Bond 的广义矩 (GMM) 估计的动态面板模型

Dynamic panel model using the generalized method of moments (GMM) estimation of Arellano and Bond

基于 Kuo 等人的工作(Kuo, H.-I., Chen, C.-C., Tseng, W.-C., Ju, L.-F., Huang, B. -W. (2007). Assessing impacts of SARS and Avian Flu on international tourism demand to Asia. Tourism Management. Retrieved from: https://www.sciencedirect.com/science/article/abs/pii/S0261517707002191?via%3Dihub), I am measureing the effect of COVID-19 on tourism demand.[=14 ] =]

我的面板数据可以在这里找到:https://www.dropbox.com/s/t0pkwrj59zn22gg/tourism_covid_data-total.csv?dl=0

我想使用一阶差分变换模型 (GMMDIFF) 并将因变量(旅游需求)的滞后作为滞后因变量的工具。旅游需求模型的动态和一阶差分版本: Δyit = η2Δ yit-1 + η3 ΔSit + Δuit

其中,y为旅游需求,i为COVID-19感染国家,t为时间,S为SARS病例数,u为误差项的固定效应分解。

到目前为止,使用 python 我设法使用面板 OLS 获得了一些结果:

import pandas as pd
import numpy as np
from linearmodels import PanelOLS
import statsmodels.api as sm

tourism_covid_data=pd.read_csv('../Data/Data - Dec2021/tourism_covid_data-total.csv, header=0, parse_dates=['month_year']

tourism_covid_data['l.tourism_demand']=tourism_covid_data['tourism_demand'].shift(1)
tourism_covid_data=tourism_covid_data.dropna()
exog = sm.add_constant(tourism_covid_data[['l.tourism_demand','monthly cases']])
mod = PanelOLS(tourism_covid_data['tourism_demand'], exog, entity_effects=True)
fe_res = mod.fit()
fe_res

我正在尝试找到解决方案并将 GMM 用于我的数据,但是,GMM 似乎并未广泛用于 python 而不是其他类似问题在堆栈上可用。关于我如何在这里工作有什么想法吗?

有一个 python 包支持动态面板模型上的系统和差异 GMM

https://github.com/dazhwu/pydynpd

特征包括:(1) 差异和系统 GMM,(2) one-step 和 two-step 估计量,(3) 稳健的标准误差,包括 Windmeijer (2005) 建议的标准误差,(4 ) Hansen over-identification 检验,(5) Arellano-Bond 自相关检验,(6) 时间虚拟机,(7) 允许用户折叠仪器以减少仪器扩散问题,以及 (8) 模型的简单语法规范.

我刚试过你的数据。我认为您的数据不适合 diff GMM 或系统 GMM,因为它是 T(=48) >>N(=4) 长面板。无论如何,pydynpd 仍然会产生结果。在这两种情况下,我都不得不折叠仪器矩阵以减少仪器过多的问题。

模型 1:差异 GMM;将“每月案例”视为预定变量

import pandas as pd
from  pydynpd import regression

df = pd.read_csv("tourism_covid_data-total.csv")  #, index_col=False)
df['monthly_cases']=df['monthly cases']
command_str='tourism_demand L1.tourism_demand monthly_cases  | gmm(tourism_demand, 2 6) gmm(monthly_cases, 1 2)| nolevel collapse '
mydpd = regression.abond(command_str, df, ['Country', 'month_year'])

输出:

Python 3.9.7 (default, Sep 10 2021, 14:59:43) 
[GCC 11.2.0] on linux
Warning: system and difference GMMs do not work well on long (T>=N) panel data
Dynamic panel-data estimation, two-step difference GMM
 Group variable: Country       Number of obs = 184  
 Time variable: month_year     Number of groups = 4 
 Number of instruments = 7                          
+-------------------+-----------------+---------------------+------------+-----------+
|   tourism_demand  |      coef.      | Corrected Std. Err. |     z      |   P>|z|   |
+-------------------+-----------------+---------------------+------------+-----------+
| L1.tourism_demand |    0.7657082    |      0.0266379      | 28.7450196 | 0.0000000 |
|   monthly_cases   | -182173.5644815 |    171518.4068348   | -1.0621225 | 0.2881801 |
+-------------------+-----------------+---------------------+------------+-----------+
Hansen test of overid. restrictions: chi(5) = 3.940 Prob > Chi2 = 0.558
Arellano-Bond test for AR(1) in first differences: z = -1.04 Pr > z =0.299
Arellano-Bond test for AR(2) in first differences: z = 1.00 Pr > z =0.319

模型 2:差异 GMM;将“月度病例”的滞后视为外生变量

command_str='tourism_demand L1.tourism_demand L1.monthly_cases  | gmm(tourism_demand, 2 6) iv(L1.monthly_cases)| nolevel collapse '
mydpd = regression.abond(command_str, df, ['Country', 'month_year'])

输出:

Warning: system and difference GMMs do not work well on long (T>=N) panel data
Dynamic panel-data estimation, two-step difference GMM
 Group variable: Country       Number of obs = 184  
 Time variable: month_year     Number of groups = 4 
 Number of instruments = 6                          
+-------------------+-----------------+---------------------+------------+-----------+
|   tourism_demand  |      coef.      | Corrected Std. Err. |     z      |   P>|z|   |
+-------------------+-----------------+---------------------+------------+-----------+
| L1.tourism_demand |    0.7413765    |      0.0236962      | 31.2866594 | 0.0000000 |
|  L1.monthly_cases | -190277.2987977 |    164169.7711072   | -1.1590276 | 0.2464449 |
+-------------------+-----------------+---------------------+------------+-----------+
Hansen test of overid. restrictions: chi(4) = 1.837 Prob > Chi2 = 0.766
Arellano-Bond test for AR(1) in first differences: z = -1.05 Pr > z =0.294
Arellano-Bond test for AR(2) in first differences: z = 1.00 Pr > z =0.318

模型 3:与模型 2 类似,但是是系统 GMM。

command_str='tourism_demand L1.tourism_demand L1.monthly_cases  | gmm(tourism_demand, 2 6) iv(L1.monthly_cases)| collapse '
mydpd = regression.abond(command_str, df, ['Country', 'month_year'])

输出:

Warning: system and difference GMMs do not work well on long (T>=N) panel data
Dynamic panel-data estimation, two-step system GMM
 Group variable: Country       Number of obs = 188  
 Time variable: month_year     Number of groups = 4 
 Number of instruments = 8                          
+-------------------+-----------------+---------------------+------------+-----------+
|   tourism_demand  |      coef.      | Corrected Std. Err. |     z      |   P>|z|   |
+-------------------+-----------------+---------------------+------------+-----------+
| L1.tourism_demand |    0.5364657    |      0.0267678      | 20.0414904 | 0.0000000 |
|  L1.monthly_cases | -216615.8306112 |    177416.0961037   | -1.2209480 | 0.2221057 |
|        _con       |  -10168.9640333 |     8328.7444649    | -1.2209480 | 0.2221057 |
+-------------------+-----------------+---------------------+------------+-----------+
Hansen test of overid. restrictions: chi(5) = 1.876 Prob > Chi2 = 0.866
Arellano-Bond test for AR(1) in first differences: z = -1.06 Pr > z =0.288
Arellano-Bond test for AR(2) in first differences: z = 0.99 Pr > z =0.322