systemfit中的不等式约束

时间:2013-01-14 16:23:38

标签: r

我正在尝试使用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)

0 个答案:

没有答案