R中面板数据的单位根检验

机器算法验证 r 面板数据 单位根
2022-03-12 13:23:18

我有这个plm包,想对一些变量运行单位根测试。我收到以下错误:

> purtest(data$tot.emp)
Error in data.frame(baldwin = c(59870, 61259, 60397, 58919, 57856, 57227,  : 
  arguments imply differing number of rows: 14, 19, 11, 12, 1, 20, 18, 10, 13

我认为我收到此错误是因为我的面板不平衡。两个问题:

  • 您可以对不平衡面板使用面板单位根检验(Levin、Lin 和 Chu (2002)、Im、Pesaran 和 Shin (2003) 或其他人)吗?
  • 如果是这样,它是否在 R 中实现?
3个回答

目前(版本 1.2-10,2012-05-05)似乎不支持不平衡的情况。编辑:不平衡面板数据的问题在 CRAN 上的 plm 版本 2.2-2 中得到解决(2020-02-21)。

其余的答案是假设版本 1.2-10:

我查看了代码,最终的数据准备行(无论您的初始参数是什么)如下:

 object <- as.data.frame(split(object, id))

如果您通过不平衡面板,这条线将通过重复相同的值使其平衡。如果您的不平衡面板的时间序列长度相互分开,那么甚至不会产生错误消息。这是来自最纯页面的示例:

 > data(Grunfeld)
 > purtest(inv ~ 1, data = Grunfeld, index = "firm", pmax = 4, test = "madwu")

Maddala-Wu Unit-Root Test (ex. var. : Individual Intercepts )

  data:  inv ~ 1 
  chisq = 47.5818, df = 20, p-value = 0.0004868
  alternative hypothesis: stationarity 

这个面板是平衡的:

 > unique(table(Grunfeld$firm))
  [1] 20

使其失衡:

 > gr <- subset(Grunfeld, !(firm %in% c(3,4,5) & year <1945))

面板中两个不同的时间序列长度:

 > unique(table(gr$firm))
  [1] 20 10

没有错误信息:

> purtest(inv ~ 1, data = gr, index = "firm", pmax = 4, test = "madwu")
 
    Maddala-Wu Unit-Root Test (ex. var. : Individual Intercepts )

data:  inv ~ 1 
chisq = 86.2132, df = 20, p-value = 3.379e-10
alternative hypothesis: stationarity 

另一个不平衡的面板:

  > gr <- subset(Grunfeld, !(firm %in% c(3,4,5) & year <1940))
  > unique(table(gr$firm))
  [1] 20 15

和错误信息:

 > purtest(inv ~ 1, data = gr, index = "firm", pmax = 4, test = "madwu")
  Erreur dans data.frame(`1` = c(317.6, 391.8, 410.6, 257.7, 330.8, 461.2,  : 
  arguments imply differing number of rows: 20, 15

您是否尝试将数据转换为pdata.frame? 我也有一个不平衡的面板,但purtest如果数据是pdata.frame. 但我也可能错了:)

然而,?purtest作者写道:

"object, x  

Either a 'data.frame' or a matrix containing the time series, 
a 'pseries' object, a formula, or the name of a column of a 'data.frame',
or a **'pdata.frame'**
on which the test has to be computed; a'purtest' object for the print 
and summary methods,"

所以我猜如果有人使用pdata.framepurtest理解”该面板是unbalanced.

我错了吗???

Eviews 5允许您测试不可能panel unit roots的数据例如,即使测试可以应用于 中的不平衡面板,但如果我们有一些观察结果是不可能的,有差距,即我们有国家 i 2002 年和 2004 年但没有 2003 年的数据(假设滞后更大不止一个)。我认为在执行测试时放弃所有此类观察,对于我们的示例,这是国家 i。但是,如果您手动删除所有此类观察,您仍然可以使用unbalancedRStataIm–Pesaran–ShinFisher-typeStataEviewsRStata.