简体   繁体   English

plm 固定效应错误 - R 中的空模型 - 不平衡数据

[英]plm fixed effects error - empty model in R - unbalanced data

I'm trying to conduct a fixed-effect model using R我正在尝试使用 R 进行固定效应模型

fixed1<-plm(ITEMS_STARPU ~ TREAT_SUM, data=dataHyp1.i, index=c("PRACTICE"), model = "within")

and I keep getting the following error:我不断收到以下错误:

Error in plm.fit(formula, data, model, effect, random.method, random.models,  : empty model

The outcome variable is the number of antibiotics dispensed per GP Practice (ie clinic), and so the index is on a practice level (as opposed to a patient)结果变量是每次全科医生诊所(即诊所)配发的抗生素数量,因此该指数是在实践水平上(与患者相反)

The data works when I use "pooling"当我使用“池化”时数据有效

I read previous threads that stated that the problem could be the time period, but the data already contains a date element (data is collected and displayed monthly)我读过之前的帖子,指出问题可能出在时间段上,但数据已经包含一个日期元素(数据是每月收集和显示的)

Hyp1.i <- read.csv("Hypothesis 1.i.csv",  header = TRUE, na.strings = c("NA"), stringsAsFactors = FALSE)

myvarsHyp1.i<- c("PERIOD_NO", "PRACTICE", "REGIONAL_TEAM", "ITEMS_STARPU", "TREAT_SUM")
dataHyp1.i <- Hyp1.i[,myvarsHyp1.i]

table(dataHyp1.i$PERIOD_NO)
class(dataHyp1.i$PERIOD_NO)
dataHyp1.i$PERIOD_NO<-factor(dataHyp1.i$PERIOD_NO)

table(dataHyp1.i$TREAT_SUM)
class(dataHyp1.i$TREAT_SUM)

dataHyp1.i$TREAT_SUM <- factor(dataHyp1.i$TREAT_SUM, levels=c(0:2), labels=c("No Letter", "Single Letter", "Repeat Letter"))

table(dataHyp1.i$TREAT_SUM)

fixed1<-plm(ITEMS_STARPU ~ TREAT_SUM, data=dataHyp1.i, index=c("PRACTICE"), model = "within")
summary(fixed)

you are using a panel data, so you should have a cross-sectional data and time series together.您使用的是面板数据,因此您应该同时拥有横截面数据和时间序列。 so i think the problem is in that part of index=c("PRACTICE") should be the header of your cross-sectional id and time id ,which in your case it is PERIOD_NO.所以我认为问题在于index=c("PRACTICE")那部分应该是您的横截面 ID 和时间 ID 的标题,在您的情况下它是 PERIOD_NO。 so i think you should write index=c("PRACTICE","PERIOD_NO") first of all and probably your panel data is not empty anymore所以我认为你应该首先写index=c("PRACTICE","PERIOD_NO")并且你的面板数据可能不再是空的了

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM