I want run regression in panel data. There is NA in my index (ID,time). I do not want to delete NA in index.
Result<-plm(TBL~Tang+Prof+LnSALES+MB,data=Panel,model="within",index=c("Firms","Time"))
When I the above code, it returns:
at least one couple (id-time) has NA in at least one index dimension in
resulting pdata.frame
to find out which, use e.g. table(index(your_pdataframe), useNA = "ifany")
Error in model.matrix.pFormula(formula, data, rhs = 1, model = model, :
NA in the individual index variable
Without delete NA, how can I run panel regression with NA in index? Thanks
Since you are just looking to omit observations where your index is NA
, you can do this:
Result <- plm(TBL ~ Tang + Prof + LnSALES + MB,
data=Panel[which(!is.na(Panel$Firms)), ],
model="within", index=c("Firms", "Time"))
data=Panel[which(!is.na(Panel$Firms)), ]
tells plm()
to use as data a subset of Panel
where Panel$Firms
is not NA
. Then you cannot have the issue where
at least one couple (id-time) has NA in at least one index dimension in
resulting pdata.frame