1705 4

[回归分析求助] 关于全面FGLS运行错误的问题 [推广有奖]

  • 2关注
  • 0粉丝

硕士生

42%

还不是VIP/贵宾

-

威望
0
论坛币
125 个
通用积分
0.0015
学术水平
2 点
热心指数
2 点
信用等级
2 点
经验
1615 点
帖子
65
精华
0
在线时间
223 小时
注册时间
2019-3-12
最后登录
2025-10-27

楼主
库洛洛洛洛洛 学生认证  发表于 2022-4-10 22:44:56 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币

在运行全面FGLS命令时显示错误:

  1. xtgls lntourists policy1,panel(cor) cor(ar1)
复制代码

“time is not regularly spaced or does not have intervals of delta -- use the force option to treat the intervals as though they were regular”

根据提示在命令中添加“force”后,仍然提示错误:

“panels must be balanced”

可是我的(长)面板数据是严格平衡的呀,具体信息如下:

由于我使用的是月度数据,所以我生成一个新的时间变量“time”

  1. encode city,gen(id)

  2. egen time = group(year month)

  3. xtset id time
复制代码

结果如下:

       panel variable:  id (strongly balanced)

        time variable:  time, 1 to 129

                delta:  1 unit

各位大佬,还请指点指点,实在太迷糊了,晕。提前感谢各位了!





二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:FGLS 运行错误 Intervals Interval Balanced

沙发
库洛洛洛洛洛 学生认证  发表于 2022-4-10 22:45:59
. dataex year month city tourists

----------------------- copy starting from the next line -----------------------
  1. * Example generated by -dataex-. To install: ssc install dataex
  2. clear
  3. input int year byte month str9 city str17 tourists
  4. 2010  1 "万宁" "321800"
  5. 2010  2 "万宁" "280600"
  6. 2010  3 "万宁" "316400"
  7. 2010  4 "万宁" "265600"
  8. 2010  5 "万宁" "181800"
  9. 2010  6 "万宁" "143400"
  10. 2010  7 "万宁" "191500"
  11. 2010  8 "万宁" "168900"
  12. 2010  9 "万宁" "132600"
  13. 2010 10 "万宁" "133800"
  14. 2010 11 "万宁" "41600"  
  15. 2010 12 "万宁" "277700"
  16. 2011  1 "万宁" "323200"
  17. 2011  2 "万宁" "309700"
  18. 2011  3 "万宁" "346100"
  19. 2011  4 "万宁" "284800"
  20. 2011  5 "万宁" "233500"
  21. 2011  6 "万宁" "176400"
  22. 2011  7 "万宁" "242000"
  23. 2011  8 "万宁" "206600"
  24. 2011  9 "万宁" "157200"
  25. 2011 10 "万宁" "262000"
  26. 2011 11 "万宁" "366900"
  27. 2011 12 "万宁" "348900"
  28. 2012  1 "万宁" "311000"
  29. 2012  2 "万宁" "328200"
  30. 2012  3 "万宁" "347100"
  31. 2012  4 "万宁" "292000"
  32. 2012  5 "万宁" "218600"
  33. 2012  6 "万宁" "169800"
  34. 2012  7 "万宁" "244800"
  35. 2012  8 "万宁" "195100"
  36. 2012  9 "万宁" "152200"
  37. 2012 10 "万宁" "264900"
  38. 2012 11 "万宁" "348600"
  39. 2012 12 "万宁" "345700"
  40. 2013  1 "万宁" "290800"
  41. 2013  2 "万宁" "266200"
  42. 2013  3 "万宁" "279000"
  43. 2013  4 "万宁" "220500"
  44. 2013  5 "万宁" "160900"
  45. 2013  6 "万宁" "142900"
  46. 2013  7 "万宁" "187500"
  47. 2013  8 "万宁" "201500"
  48. 2013  9 "万宁" "156600"
  49. 2013 10 "万宁" "203400"
  50. 2013 11 "万宁" "336700"
  51. 2013 12 "万宁" "331000"
  52. 2014  1 "万宁" "28.00 "
  53. 2014  2 "万宁" "330800"
  54. 2014  3 "万宁" "319300"
  55. 2014  4 "万宁" "237800"
  56. 2014  5 "万宁" "196800"
  57. 2014  6 "万宁" "165100"
  58. 2014  7 "万宁" "210400"
  59. 2014  8 "万宁" "201600"
  60. 2014  9 "万宁" "171500"
  61. 2014 10 "万宁" "250800"
  62. 2014 11 "万宁" "32.70 "
  63. 2014 12 "万宁" "321200"
  64. 2015  1 "万宁" "31.23 "
  65. 2015  2 "万宁" "316400"
  66. 2015  3 "万宁" "320400"
  67. 2015  4 "万宁" "250600"
  68. 2015  5 "万宁" "213500"
  69. 2015  6 "万宁" "179800"
  70. 2015  7 "万宁" "221600"
  71. 2015  8 "万宁" "215500"
  72. 2015  9 "万宁" "186100"
  73. 2015 10 "万宁" "253100"
  74. 2015 11 "万宁" "338000"
  75. 2015 12 "万宁" "337600"
  76. 2016  1 "万宁" "326000"
  77. 2016  2 "万宁" "334900"
  78. 2016  3 "万宁" "336500"
  79. 2016  4 "万宁" "235400"
  80. 2016  5 "万宁" "187900"
  81. 2016  6 "万宁" "161200"
  82. 2016  7 "万宁" "195000"
  83. 2016  8 "万宁" "202900"
  84. 2016  9 "万宁" "195000"
  85. 2016 10 "万宁" "255800"
  86. 2016 11 "万宁" "342100"
  87. 2016 12 "万宁" "342900"
  88. 2017  1 "万宁" "333100"
  89. 2017  2 "万宁" "181000"
  90. 2017  3 "万宁" "366800"
  91. 2017  4 "万宁" "242900"
  92. 2017  5 "万宁" "198300"
  93. 2017  6 "万宁" "169800"
  94. 2017  7 "万宁" "209800"
  95. 2017  8 "万宁" "220100"
  96. 2017  9 "万宁" "208800"
  97. 2017 10 "万宁" "264900"
  98. 2017 11 "万宁" "363800"
  99. 2017 12 "万宁" "365200"
  100. 2018  1 "万宁" "362500"
  101. 2018  2 "万宁" "378600"
  102. 2018  3 "万宁" "386700"
  103. 2018  4 "万宁" "263900"
  104. end
复制代码

------------------ copy up to and including the previous line ------------------

Listed 100 out of 2322 observations
Use the count() option to list more

藤椅
库洛洛洛洛洛 学生认证  发表于 2022-4-10 22:47:43
. dataex year month city tourists policy1

----------------------- copy starting from the next line -----------------------
  1. * Example generated by -dataex-. To install: ssc install dataex
  2. clear
  3. input int year byte month str9 city str17 tourists byte policy1
  4. 2010  1 "万宁" "321800"  0
  5. 2010  2 "万宁" "280600"  0
  6. 2010  3 "万宁" "316400"  0
  7. 2010  4 "万宁" "265600"  0
  8. 2010  5 "万宁" "181800"  0
  9. 2010  6 "万宁" "143400"  0
  10. 2010  7 "万宁" "191500"  0
  11. 2010  8 "万宁" "168900"  0
  12. 2010  9 "万宁" "132600"  0
  13. 2010 10 "万宁" "133800"  0
  14. 2010 11 "万宁" "41600"   0
  15. 2010 12 "万宁" "277700"  0
  16. 2011  1 "万宁" "323200"  0
  17. 2011  2 "万宁" "309700"  0
  18. 2011  3 "万宁" "346100"  0
  19. 2011  4 "万宁" "284800"  1
  20. 2011  5 "万宁" "233500"  1
  21. 2011  6 "万宁" "176400"  1
  22. 2011  7 "万宁" "242000"  1
  23. 2011  8 "万宁" "206600"  1
  24. 2011  9 "万宁" "157200"  1
  25. 2011 10 "万宁" "262000"  1
  26. 2011 11 "万宁" "366900"  1
  27. 2011 12 "万宁" "348900"  1
  28. 2012  1 "万宁" "311000"  1
  29. 2012  2 "万宁" "328200"  1
  30. 2012  3 "万宁" "347100"  1
  31. 2012  4 "万宁" "292000"  1
  32. 2012  5 "万宁" "218600"  1
  33. 2012  6 "万宁" "169800"  1
  34. 2012  7 "万宁" "244800"  1
  35. 2012  8 "万宁" "195100"  1
  36. 2012  9 "万宁" "152200"  1
  37. 2012 10 "万宁" "264900"  1
  38. 2012 11 "万宁" "348600"  1
  39. 2012 12 "万宁" "345700"  1
  40. 2013  1 "万宁" "290800"  1
  41. 2013  2 "万宁" "266200"  1
  42. 2013  3 "万宁" "279000"  1
  43. 2013  4 "万宁" "220500"  1
  44. 2013  5 "万宁" "160900"  1
  45. 2013  6 "万宁" "142900"  1
  46. 2013  7 "万宁" "187500"  1
  47. 2013  8 "万宁" "201500"  1
  48. 2013  9 "万宁" "156600"  1
  49. 2013 10 "万宁" "203400"  1
  50. 2013 11 "万宁" "336700"  1
  51. 2013 12 "万宁" "331000"  1
  52. 2014  1 "万宁" "28.00 " 1
  53. 2014  2 "万宁" "330800"  1
  54. 2014  3 "万宁" "319300"  1
  55. 2014  4 "万宁" "237800"  1
  56. 2014  5 "万宁" "196800"  1
  57. 2014  6 "万宁" "165100"  1
  58. 2014  7 "万宁" "210400"  1
  59. 2014  8 "万宁" "201600"  1
  60. 2014  9 "万宁" "171500"  1
  61. 2014 10 "万宁" "250800"  1
  62. 2014 11 "万宁" "32.70 " 1
  63. 2014 12 "万宁" "321200"  1
  64. 2015  1 "万宁" "31.23 " 1
  65. 2015  2 "万宁" "316400"  1
  66. 2015  3 "万宁" "320400"  1
  67. 2015  4 "万宁" "250600"  1
  68. 2015  5 "万宁" "213500"  1
  69. 2015  6 "万宁" "179800"  1
  70. 2015  7 "万宁" "221600"  1
  71. 2015  8 "万宁" "215500"  1
  72. 2015  9 "万宁" "186100"  1
  73. 2015 10 "万宁" "253100"  1
  74. 2015 11 "万宁" "338000"  1
  75. 2015 12 "万宁" "337600"  1
  76. 2016  1 "万宁" "326000"  1
  77. 2016  2 "万宁" "334900"  1
  78. 2016  3 "万宁" "336500"  1
  79. 2016  4 "万宁" "235400"  1
  80. 2016  5 "万宁" "187900"  1
  81. 2016  6 "万宁" "161200"  1
  82. 2016  7 "万宁" "195000"  1
  83. 2016  8 "万宁" "202900"  1
  84. 2016  9 "万宁" "195000"  1
  85. 2016 10 "万宁" "255800"  1
  86. 2016 11 "万宁" "342100"  1
  87. 2016 12 "万宁" "342900"  1
  88. 2017  1 "万宁" "333100"  1
  89. 2017  2 "万宁" "181000"  1
  90. 2017  3 "万宁" "366800"  1
  91. 2017  4 "万宁" "242900"  1
  92. 2017  5 "万宁" "198300"  1
  93. 2017  6 "万宁" "169800"  1
  94. 2017  7 "万宁" "209800"  1
  95. 2017  8 "万宁" "220100"  1
  96. 2017  9 "万宁" "208800"  1
  97. 2017 10 "万宁" "264900"  1
  98. 2017 11 "万宁" "363800"  1
  99. 2017 12 "万宁" "365200"  1
  100. 2018  1 "万宁" "362500"  1
  101. 2018  2 "万宁" "378600"  1
  102. 2018  3 "万宁" "386700"  1
  103. 2018  4 "万宁" "263900"  1
  104. end
复制代码

------------------ copy up to and including the previous line ------------------

Listed 100 out of 2322 observations
Use the count() option to list more

.

板凳
a大大大大大娇 发表于 2024-7-15 13:48:04
请问解决了吗

报纸
赵安豆 发表于 2024-12-22 15:08:13
遇到`panels must be balanced`的错误,即使你确信数据已经是平衡面板(balanced panel),这通常意味着Stata在处理你的数据时遇到了一些问题。尽管你说数据是严格平衡的,这里有几个可能的原因和解决步骤:

1. **检查缺失值**:确保没有遗漏或不一致的数据点。即使是微小的差异也可能导致Stata认为面板不平衡。使用`list id time if missing(lntourists)`, clean 或 `bysort id: assert _N == <你的面板长度>` 检查每个id的时间序列是否完整。

2. **时间变量**:你已经创建了一个基于年份和月份的`time`变量,确保这个变量对所有个体来说都是连续的。即使在“force”选项下,Stata也要求时间间隔一致且没有跳过任何点。检查`time`的最小值是否为1(假设你的序列开始于某月),最大值是否为总观察数。

3. **平衡性声明**:尽管Stata告诉你面板是平衡的,“strongly balanced”,这并不一定意味着在尝试运行特定命令时数据不会出现问题,特别是当涉及到时间序列分析时。有时错误可能是由数据的编码方式引起的,即使理论上它们看起来是平衡的。

4. **重新设置面板**:尝试释放旧的xtset设置并重新设置,确保没有遗留的信息影响到新的命令执行:
   ```
   xtclear
   xtset id time, force
   ```

5. **检查命令参数**:你使用了`cor(ar1)`参数,这表明你希望模型包含自回归项。确保你的数据确实适合此类分析,并且没有违反AR(1)过程的基本假设。

6. **数据类型和格式**:确认`id`和`time`变量的数据类型正确(通常`int`或`long`对于id;`int`或特定的时间序列格式对于时间)。错误的类型可能导致Stata无法正确识别面板结构。

如果上述步骤都无法解决问题,可能需要更详细的日志信息或数据检查来定位具体问题。考虑在Stata论坛或相关社区发布详细的问题描述和部分数据(去敏感化后),通常会有专家能提供更具体的指导。
   
希望这些建议能帮助你解决问题!

此文本由CAIE学术大模型生成,添加下方二维码,优先体验功能试用



您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2026-1-6 08:47