# Optimization

Loadable Function: [x, obj, info, lambda] = qpsol (x, H, c, lb, ub, lb, A, ub)
Solve quadratic programs using Gill and Murray's QPSOL. Because QPSOL is not freely redistributable, this function is only available if you have obtained your own copy of QPSOL. See section Installing Octave.

When called with two arguments, this function allows you set options parameters for the function `qpsol`. Given one argument, `qpsol_options` returns the value of the corresponding option. If no arguments are supplied, the names of all the available options and their current values are displayed.

## Nonlinear Programming

Loadable Function: [x, obj, info, lambda] = npsol (x, phi, lb, ub, lb, A, ub, lb, g, ub)
Solve nonlinear programs using Gill and Murray's NPSOL. Because NPSOL is not freely redistributable, this function is only available if you have obtained your own copy of NPSOL. See section Installing Octave.

The second argument is a string containing the name of the objective function to call. The objective function must be of the form

```y = phi (x)
```

where x is a vector and y is a scalar.

When called with two arguments, this function allows you set options parameters for the function `npsol`. Given one argument, `npsol_options` returns the value of the corresponding option. If no arguments are supplied, the names of all the available options and their current values are displayed.

## Linear Least Squares

Function File: gls (Y, X, O)
Generalized least squares (GLS) estimation for the multivariate model

```Y = X * B + E,  mean(E) = 0,  cov(vec(E)) = (s^2)*O
```

with

```Y an T x p matrix
X an T x k matrix
B an k x p matrix
E an T x p matrix
O an Tp x Tp matrix
```

Each row of Y and X is an observation and each column a variable.

Returns BETA, v, and, R, where BETA is the GLS estimator for B, v is the GLS estimator for s^2, and R = Y - X*BETA is the matrix of GLS residuals.

Function File: ols (Y, X)
Ordinary Least Squares (OLS) estimation for the multivariate model

```Y = X*B + E,  mean (E) = 0,  cov (vec (E)) = kron (S, I)
```

with

```Y an T x p matrix
X an T x k matrix
B an k x p matrix
E an T x p matrix
```

Each row of Y and X is an observation and each column a variable.

Returns BETA, SIGMA, and R, where BETA is the OLS estimator for B, i.e.

```BETA = pinv(X)*Y,
```

where pinv(X) denotes the pseudoinverse of X, SIGMA is the OLS estimator for the matrix S, i.e.

```SIGMA = (Y - X*BETA)'*(Y - X*BETA) / (T - rank(X))
```

and R = Y - X*BETA is the matrix of OLS residuals.