I am trying to use the effects package to extract predicted values for a PLM Model. Unfortunately, as soon as I include a factor variable, the effects package breaks down with the error message
Error in Summary.factor(c(2L, 1L, 1L, 2L, 1L, 2L, 1L, 1L, 1L, 1L, 1L,
‘range’ not meaningful for factors
Has anyone found a way to work around this problem?
Here is a minimum working example that replicates the issue
data("Produc", package = "plm")
Produc$dummy1<-(rbinom(nrow(Produc), 1 , 0.4)) #Generate Random Dummy
Produc$dummy2<-as.factor(Produc$dummy1)
mod1 <- plm(gsp ~ pcap * dummy1,data = Produc, index = c("state","year"), model="fd")
mod2 <- plm(gsp ~ pcap * dummy2,data = Produc, index = c("state","year"), model="fd")
Effect(c("pcap","dummy1"),mod1) #This works
Effect(c("pcap","dummy2"),mod2) #This does not
This might be related to this question, but the error is different.