根据Kuo等人的工作(Kuo,H.I.,Chen,C.C.,曾,W.C.,Ju,L.F.,Huang,B.W. (2007) )。评估非典和禽流感对亚洲国际旅游需求的影响。旅游管理。检索自:https://www.sciencedirect.com/science/article/abs/pii/S0261517707002191?via%3Dihub),我正在测量新冠肺炎对旅游需求的影响。
我的面板数据可以在这里找到:https://www.dropbox.com/s/t0pkwrj59zn22gg/tourism_covid_data-total.csv?dl=0
我想使用第一差分转换模型(GMMDIFF),并将因变量(旅游需求)的滞后作为滞后因变量的工具。旅游需求模型的动态和第一个差异版本:Δyit =η2Δyit-1 +η3ΔSit +Δuit
其中,y是旅游需求,我指的是新冠肺炎感染的国家,t是时间,S是SARS病例的数量,u是固定效应分解的误差项。
到目前为止,使用python,我成功地使用Panel获得了一些结果:
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中广泛使用,而且堆栈上也没有其他类似的问题。对我怎么在这里工作有什么想法吗?
发布于 2022-03-23 17:48:36
我刚查了你的资料。我不认为您的数据适合不同的GMM或系统GMM,因为它是一个T(=48) >>N(=4)长面板。无论如何,pydynpd仍然会产生结果。在这两种情况下,我不得不崩溃仪器矩阵,以减少问题与太多的工具。
模型1: diff 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发布于 2022-03-14 14:23:49
有一个python包支持系统和动态面板模型上的差异GMM。
https://github.com/dazhwu/pydynpd
其特点包括:(1)差分和系统GMM;(2)一步和两步估计;(3)稳健的标准误差,包括Windmeijer (2005)提出的标准误差;(4) Hansen过辨识测试;(5)用于自相关的Arellano-Bond测试;(6)时间假人;(7)允许用户折叠仪器以减少仪器扩散问题;(8)模型规范的简单语法。
https://stackoverflow.com/questions/70664199
复制相似问题