2

我正在尝试使用 估计联立方程组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)
4

0 回答 0