I'm using the plm package to do analysis on a dashboard. To structure the base as a panel, I used the pdata.frame
function of the same package. With this, I had a panel with the following characteristics:
Dai,Iwouldliketorunaregressionusinginstrumentalvariableswiththefollowingformula:
saida<-plm(formula=X4~X1|.~X2+X3+Ano.Mes+id,data=as.matrix(painel),model="within", index = c("id", "Ano.Mes"))
However, I get the following error:
Error in x [! na.check]: (subscript) logical subscript too long
Does anyone have any suggestions for solving this error?
I created this example with the Iris data structure of the base of R and the same error occurs:
data(iris)
tst <- iris[1:120,]
tst$mes <- rep(1:12,times = 10)
tst$ano <- unlist(lapply(2007:2016, function(x) rep(x, times = 12)))
tst$ano.mes <- paste(tst$ano,"m",tst$mes, sep = "")
painel <- pdata.frame(tst, index = c("Species","ano.mes"))
modelo <- plm(formula = Sepal.Length ~ Sepal.Width | . ~ Petal.Length + Petal.Width + Species + ano.mes, data = as.matrix(painel), index = c("Species", "mes.ano"), model = "within")