# How to estimate constrained a constrained VAR(1) with MATLAB?

Suppose I want to estimate the following VAR(1) model: $$Y_t = \mu + \Phi Y_{t-1} + \varepsilon_t$$ where $Y_t=(y_{1t}, y_{2t},…,y_{kt})'$, $\mu=(\mu_1,…,\mu_{k})’$ and $\Phi$ a matrix of coefficients. I’m interested in obtaining the coefficients in $\Phi$ such that the resulting vector of predicted values $\hat{Y}_t = (\hat{y}_{1t}, \hat{y}_{2t},…,\hat{y}_{kt})’$ obeys some constraints. Just to give an unrealistic example I want to estimate the $\Phi$ matrix via least squares such that $3\hat{y}_{1t} + 2\hat{y}_{2t}\geq 0$ and $\hat{y}_{3t}+\hat{y}_{4t}+\hat{y}_{5t}\geq0$.

How can I do it? In particular how can I implement it in MATLAB?

EDIT : so far my approach has been to minimise the sum of squared errors obtained by every equation of the VAR(1). Suppose I have a bivariate VAR(1), my problem has been : $$\min_{\mu,\Phi} e_1’e_1 + e_2’e_2$$ $$\text{s.t. constraint 1,2,3...}$$ which I tried to solve with the fseminf function in MATLAB. Is there some better way?

EDIT 2: Notice that the constrain is on the fitted values, not on the estimated coefficients