I am trying to do a panel regression with the plm-function (Package ‘plm’) in R. But apparently there's something wrong with my data structure. This is my model:
fixedeff <- plm(iwyg~edyear*secondos,
data = cohort_long_gesamt_panel,
model = "within",
index = c("idpers","year"))
I get this error message:
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(...)
That's the beginning of the structure-output:
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 ...
Maybe someone can help me?