I am trying to estimate a system of seemingly unrelated equations using the systemfit
package. There seems to be an issue with building the restriction matrix. Upon running the systemfit
function step-by-step, I obtain an error when executing this command:
R.restr <- car::makeHypothesis(coefNamesModReg, restrict.matrix, restrict.rhs)
! error in constants(lhs, cnames_symb) : The hypothesis "eq1_I(cdf1 * np2)-eq2_I(cdf2 * np1)=0" is not well formed: contains bad coefficient/variable names. In addition: Warning message: In constants(lhs, cnames_symb) : NAs introduced through coercion.
coefNamesModReg
is a vector chr [1:645]; restrict.matrix
is a vector chr [1:210]; restrict.rhs
is set to NULL
.
The error returns the first element of restrict matrix
. I am new to this type of models, so I am at a loss at where a potential error could be. Is it a problem with variable names, dimensions or did I define the restrict.matrix
incorrectly?
Here is a reproducible example:
library(car)
restrict.matrix <- c(
"eq1_I(cdf1 * np2)-eq2_I(cdf2 * np1)=0",
"eq1_I(cdf1 * np3)-eq3_I(cdf3 * np1)=0",
"eq1_I(cdf1 * np4)-eq4_I(cdf4 * np1)=0",
"eq1_I(cdf1 * np5)-eq5_I(cdf5 * np1)=0",
"eq1_I(cdf1 * np6)-eq6_I(cdf6 * np1)=0",
"eq1_I(cdf1 * np7)-eq7_I(cdf7 * np1)=0",
"eq1_I(cdf1 * np8)-eq8_I(cdf8 * np1)=0",
"eq1_I(cdf1 * np9)-eq9_I(cdf9 * np1)=0",
"eq1_I(cdf1 * np10)-eq10_I(cdf10 * np1)=0",
"eq1_I(cdf1 * np11)-eq11_I(cdf11 * np1)=0")
coefNamesModReg <- c(
"cdf1",
"I(cdf1 * y1)",
"I(cdf1 * y2)",
"I(cdf1 * y3)",
"I(cdf1 * y4)",
"I(cdf1 * y5)",
"I(cdf1 * z1)",
"I(cdf1 * z2)",
"I(cdf1 * z3)",
"I(cdf1 * yz1)")
restrict.rhs <- NULL
R.restr <- car::makeHypothesis(coefNamesModReg, restrict.matrix, restrict.rhs)