2

I'm trying to estimate a simultaneous equations system using systemfit, but cannot seem to specify inequalities as constraints. I've recreated the problem using the airquality dataset, the issue arises when adding inequalities to the restrict.matrix argument. Is there any workaround to get this example to work?

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)
MrT
  • 704
  • 1
  • 8
  • 21
  • you can the answer here , it uses `lpSolveAPI` package http://stackoverflow.com/questions/13976326/constrained-optimization-in-r-setting-up-constraints/13977187#13977187 – agstudy Jan 14 '13 at 17:46
  • If a package doesn't do what you were seeking, then search for another package. In this case I would imagined the CRAN Task View on Optimization would be helpful. I know I have answered question on SO regarding inequality constraints so a search here might pull up something. I use MarkMail for searching rhelp "archives". – IRTFM Jan 14 '13 at 17:46
  • The recommendations you made would be fine if this were a straight optimization problem, however I'm trying to _estimate_ a simultaneous system of equations by OLS on data, and to my knowledge `systemfit` is the only package that allows this (http://cran.r-project.org/web/packages/systemfit/vignettes/systemfit.pdf). – MrT Jan 14 '13 at 18:37
  • Your clarification would be fine if you were posting a linear problem, but you are not. You may be able to recast it as a linear problem but that is beyond my pay grade. – IRTFM Jan 14 '13 at 19:01

0 Answers0