r - R中的面板回归问题
问题描述
我正在尝试使用 R 中的 plm 函数(Package 'plm')进行面板回归。但显然我的数据结构有问题。这是我的模型:
fixedeff <- plm(iwyg~edyear*secondos,
data = cohort_long_gesamt_panel,
model = "within",
index = c("idpers","year"))
我收到此错误消息:
Fehler: Can't convert <labelled<double>> to <double>.
Backtrace:
1. plm::plm(...)
2. plm:::plm.fit(...)
4. plm:::pmodel.response.data.frame(...)
5. plm:::ptransform(y, model = model, effect = effect, theta = theta)
7. plm:::Within.pseries(x, effect)
...
18. vctrs::vec_default_cast(...)
19. vctrs::stop_incompatible_cast(...)
20. vctrs::stop_incompatible_type(...)
21. vctrs:::stop_incompatible(...)
22. vctrs:::stop_vctrs(...)
这是结构输出的开始:
Classes ‘pdata.frame’ and 'data.frame': 332 obs. of 18 variables:
$ idpers : Factor w/ 190 levels "102010003","105410003",..: 1 1 1 2 3 3 4 5 5 5 ...
..- attr(*, "names")= chr [1:332] "102010003-14" "102010003-15" "102010003-19" "105410003-18" ...
..- attr(*, "index")=Classes ‘pindex’ and 'data.frame': 332 obs. of 2 variables:
.. ..$ idpers: Factor w/ 190 levels "102010003","105410003",..: 1 1 1 2 3 3 4 5 5 5 ...
.. ..$ year : Factor w/ 5 levels "14","15","17",..: 1 2 5 4 2 5 5 1 2 4 ...
$ secondos : dbl+lbl [1:332] 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0,...
..@ label : chr "respondent's secondos status"
..@ format.stata: chr "%8.0g"
..@ labels : Named num 1 2 3 999
.. ..- attr(*, "names")= chr [1:4] "secondos" "foreign origin" "no foreign origin" "not documented"
..@ index :Classes ‘pindex’ and 'data.frame': 332 obs. of 2 variables:
.. ..$ idpers: Factor w/ 190 levels "102010003","105410003",..: 1 1 1 2 3 3 4 5 5 5 ...
.. ..$ year : Factor w/ 5 levels "14","15","17",..: 1 2 5 4 2 5 5 1 2 4 ...
$ swiss : dbl+lbl [1:332] 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,...
..@ label : chr "swiss citizenship"
..@ format.stata: chr "%8.0g"
..@ labels : Named num 0 1
.. ..- attr(*, "names")= chr [1:2] "no" "yes"
..@ index :Classes ‘pindex’ and 'data.frame': 332 obs. of 2 variables:
.. ..$ idpers: Factor w/ 190 levels "102010003","105410003",..: 1 1 1 2 3 3 4 5 5 5 ...
.. ..$ year : Factor w/ 5 levels "14","15","17",..: 1 2 5 4 2 5 5 1 2 4 ...
也许有人可以帮助我?
解决方案
推荐阅读
- html - 如果位置固定,如何使元素与其父元素一样宽
- javascript - 当移动标记到达某个纬度时触发事件
- ios - 可访问性:画外音不读取无序列表。当被 aria- describeby 定位时
- ios - UITableViewCells 没有正确创建?
- ruby-on-rails - Rails Active_storage ActiveStorage::IntegrityError 测试
- firebase - Cloud Firestore 限制单个文档每天写入 800 万次
- angular - 找不到管道“货币”(AOT)
- c# - AutoMapper 没有从 DataTable 返回数据
- c# - C# VS2017 Community - 如何自动压缩项目的输出文件夹
- youtube - 如何从我的 roku 频道打开我的“Youtube 频道链接”?