Error in is.pbalanced.default(x) : argument “y” is missing, with no default, due to stata imported labels

生来就可爱ヽ(ⅴ<●) 提交于 2020-05-16 03:12:00

问题


For the following panel data set:

panel <- structure(list(uurwerk = structure(c(40, 40, 40, 40, 36, 1, 32, 
36, 32, 32, 36, 36, 40, 40, 40, 40, 40, 38, 38, 38, 38, 60, 55, 
40, 42, 42, 42), label = "hours/week work in fact (on average)", class = c("labelled", 
"numeric")), loon_c = structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = "pay/salary [gross] mean int", class = c("labelled", 
"numeric")), mtr_loon = structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0.4195, 0.42, 0, 0.404, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0), label = "pay/salary [gross] mean int", class = c("labelled", 
"numeric")), ntot = structure(c(33084.2085, 31810.0215, 21653.7235, 
21961.9788, 21535.29225, 24139.039, 22988.2945, 22183.3175, 84427.88258, 
21729.72304, 24248.3388, 23044.16914, 24783.0759660205, 24955.49, 
26060.0875, 29328.0404, 30407.6135, 39047.7663137553, 24467.7521372549, 
37826.93, 25963.83683, 24516.76866, 24941.179175, 27549.5975, 
32690.0255, 25200.10125, 23777.335), label = "total net income", class = c("labelled", 
"numeric")), INC = structure(c(6L, 6L, 3L, 3L, 5L, 4L, 5L, 5L, 
6L, 5L, 4L, 4L, 3L, 3L, 3L, 3L, 4L, 4L, 6L, 5L, 1L, 4L, 4L, 6L, 
5L, 5L, 5L), .Label = c("[    0,   3010)", "[ 3010,  20300)", 
"[20300,  27189)", "[27189,  34020)", "[34020,  40767)", "[40767,  50961)", 
"[50961,1165420]"), class = c("labelled", "factor"), label = "total netto income household 2013"), 
    year = structure(c(1L, 2L, 5L, 6L, 1L, 2L, 3L, 4L, 5L, 6L, 
    7L, 8L, 1L, 4L, 5L, 6L, 7L, 1L, 3L, 4L, 6L, 5L, 8L, 1L, 2L, 
    3L, 4L), .Label = c("2011", "2012", "2013", "2014", "2015", 
    "2016", "2017", "2018"), class = "factor"), nohhold = structure(c(1L, 
    1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 
    4L, 5L, 5L, 5L, 5L, 6L, 6L, 7L, 7L, 7L, 7L), .Label = c("6", 
    "21", "38", "106", "116", "175", "262"), class = "factor")), row.names = c("6-2011", 
"6-2012", "6-2015", "6-2016", "38-2011", "38-2012", "38-2013", 
"38-2014", "38-2015", "38-2016", "38-2017", "38-2018", "106-2011", 
"106-2014", "106-2015", "106-2016", "106-2017", "116-2011", "116-2013", 
"116-2014", "116-2016", "175-2015", "175-2018", "262-2011", "262-2012", 
"262-2013", "262-2014"), class = c("pdata.frame", "data.frame"
), index = structure(list(nohhold = structure(c(1L, 1L, 1L, 1L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 
4L, 5L, 5L, 6L, 6L, 6L, 6L), .Label = c("6", "38", "106", "116", 
"175", "262"), class = "factor"), year = structure(c(1L, 2L, 
5L, 6L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 4L, 5L, 6L, 7L, 1L, 
3L, 4L, 6L, 5L, 8L, 1L, 2L, 3L, 4L), .Label = c("2011", "2012", 
"2013", "2014", "2015", "2016", "2017", "2018"), class = "factor")), row.names = c(1L, 
2L, 5L, 6L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 28L, 
29L, 30L, 31L, 33L, 35L, 36L, 38L, 43L, 46L, 47L, 48L, 49L, 50L
), class = c("pindex", "data.frame")))

I would like to run a(ny) random effects model:

library(plm)
summary(plm(uurwerk ~ loon_c + ntot, model="random", data=panel))

But I get the error:

Error in is.pbalanced.default(x) : argument "y" is missing, with no default

I cannot for the life of me figure out how this can be the case.

Any suggestions?


回答1:


The problem is coming from your dependent variable:

class(panel$uurwerk)
[1] "pseries"  "labelled" "numeric" 

From your formula I guess you are treating it as continuous, so you can do:

plm(as.numeric(uurwerk) ~ loon_c + ntot, model="random",data=panel)

Model Formula: as.numeric(uurwerk) ~ loon_c + ntot

Coefficients:
(Intercept)      loon_c        ntot 
 4.0427e+01 -9.8477e-02 -9.2704e-06 


来源:https://stackoverflow.com/questions/60847460/error-in-is-pbalanced-defaultx-argument-y-is-missing-with-no-default-due

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!