我正在尝试使用systemfit
来估计联立方程系统,但似乎无法将不等式指定为约束。我使用airquality
数据集重新创建了问题,在向restrict.matrix
参数添加不等式时出现了问题。有没有办法让这个例子起作用?
require(systemfit)
lagAQ <- rbind(NA, airquality[1:nrow(airquality)-1,])
colnames(lagAQ) <- paste("lag", colnames(lagAQ), sep = "")
data <- data.frame(airquality, lagAQ)
eqOzone <- Ozone ~ lagOzone + lagWind + lagTemp
eqWind <- Wind ~ lagOzone + lagWind + lagTemp
eqTemp <- Temp ~ lagOzone + lagWind + lagTemp
airSystem <- list(ozone = eqOzone, wind = eqWind, temp = eqTemp)
constr <- c("ozone_(Intercept) = 0",
"wind_(Intercept) = 0",
"temp_(Intercept) = 0",
"ozone_lagOzone > 0",
"ozone_lagWind > 0",
"ozone_lagTemp > 0",
"ozone_lagOzone + wind_lagOzone + temp_lagOzone = 1",
"ozone_lagWind + wind_lagWind + temp_lagWind = 1",
"ozone_lagTemp + wind_lagTemp + temp_lagTemp = 1"
)
airModel <- systemfit(airSystem, restrict.matrix = constr, data = data)