I have posted a StackOverflow example of an error that occurs with method = "random" and random.method = "swar") (but not other random.method arguments):
# data provided at end of post
library(plm)
plm(y ~ x + factor(year), index = "panel", model = "random", random.method = "swar", data = df)
# Error in solve.default(crossprod(ZBeta)) :
# Lapack routine dgesv: system is exactly singular: U[15,15] = 0
The above fails with the data frame copied at the end of this issue. The issue seems to be that a singular matrix is being sent to Lapack for solving, although I do not understand why that is the case.
Changing the random.method to anything but "swar" solves the issue, so the problem seems to be located there.
Trying the same thing in Stata, using the same (Swamy-Arora) estimator, does not return an error.
I have posted a StackOverflow example of an error that occurs with
method = "random"
andrandom.method = "swar")
(but not otherrandom.method
arguments):The above fails with the data frame copied at the end of this issue. The issue seems to be that a singular matrix is being sent to Lapack for solving, although I do not understand why that is the case.
Changing the
random.method
to anything but"swar"
solves the issue, so the problem seems to be located there.Trying the same thing in Stata, using the same (Swamy-Arora) estimator, does not return an error.