Random error in plm package

Hi everyone,
I have an issue while running command "random" in the package plm.
library(plm)
library(pwt9)
data("pwt9.1")
#creating log of variables
lnrgdpo<- log(pwt9.1$rgdpo)
lnrkna<-log(pwt9.1$rkna)
lnhc<-log(pwt9.1$hc)
lnlabsh<-log(pwt9.1$labsh)
lnemp<-log(pwt9.1$emp)
ap<-(pwt9.1$rgdpo/pwt9.1$emp)
lnap<-log(ap)
pwtdata<-cbind(pwt9.1, lnrgdpo, lnrkna, lnhc, lnlabsh, lnemp, lnap)

penndata <- pdata.frame(pwtdata, index=c("country","year"))
Y <- cbind(lnrgdpo)
X <- cbind(lnrkna, lnhc, lnemp, lnemp, lnlabsh)

Random effects estimator

random <- plm(Y ~ X, data=penndata, model= "random")
swar <- plm(Y ~ X,
data = penndata, model="random", effect = "twoways")

while I run the command I receive the following error.
Error in solve.default(crossprod(ZBeta)) :
Lapack routine dgesv: system is exactly singular: U[5,5] = 0

Can someone help me to solve this issue?

I can't really approach your issue as your code seems either incomplete or doesn't represent what you did. Your model formula of Y ~ X doesn't match any variables in your data, so the code as written would be expected to error, even before it might be possible to complain about singularity

this use of cbind to make new Y and X objects (matrices) that are independent of penndata is simply a mistake.
go directly from

penndata <- pdata.frame(pwtdata, index=c("country","year"))

to

random <- plm(lnrgdpo ~ lnrkna + lnhc +lnemp+ lnemp+ lnlabsh, data=penndata, model= "random")
1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

Thank you for your response. Here i have attached how the variables X and Y are formed. Please check whether this code is fine

Set data as panel data

penndata <- pdata.frame(pwtdata, index=c("country","year"))

Y <- cbind(lnrgdpo)
X <- cbind(lnrkna, lnhc, lnemp, lnemp, lnlabsh)

Thank you for your support. It works now. I got the results for the model.