Zeina Al Khaznachi
Zeina Al Khaznachi

Reputation: 21

plm fixed effects error - empty model in R - unbalanced data

I'm trying to conduct a fixed-effect model using 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 (i.e. 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)

Upvotes: 2

Views: 1526

Answers (1)

Soma
Soma

Reputation: 329

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. so i think you should write index=c("PRACTICE","PERIOD_NO") first of all and probably your panel data is not empty anymore

Upvotes: 1

Related Questions