# ivar

AR model estimation using instrumental variable method

## Syntax

```sys = ivar(data,na) sys = ivar(data,na,nc) sys = ivar(data,na,nc,max_size) ```

## Description

`sys = ivar(data,na)` estimates an AR polynomial model, `sys`, using the instrumental variable method and the time series data `data`. `na` specifies the order of the A polynomial.

An AR model is represented by the equation:

`$A\left(q\right)y\left(t\right)=e\left(t\right)$`

In the above model, e(t) is an arbitrary process, assumed to be a moving average process of order `nc`, possibly time varying. `nc` is assumed to be equal to `na`. Instruments are chosen as appropriately filtered outputs, delayed `nc` steps.

`sys = ivar(data,na,nc)` specifies the value of the moving average process order, `nc`, separately.

`sys = ivar(data,na,nc,max_size)` specifies the maximum size of matrices formed during estimation.

## Input Arguments

 `data` Estimation time series data. `data` must be an `iddata` object with scalar output data only. `na` Order of the A polynomial `nc` Order of the moving average process representing e(t). `max_size` Maximum matrix size. `max_size` specifies the maximum size of any matrix formed by the algorithm for estimation. Specify `max_size` as a reasonably large positive integer. Default: 250000

## Output Arguments

 `sys` Identified polynomial model. `sys` is an AR `idpoly` model which encapsulates the identified polynomial model.

## Examples

Compare spectra for sinusoids in noise, estimated by the IV method and by the forward-backward least squares method.

```y = iddata(sin([1:500]'*1.2) + sin([1:500]'*1.5) + ... 0.2*randn(500,1),[]); miv = ivar(y,4); mls = ar(y,4); spectrum(miv,mls) ```

## References

[1] Stoica, P., et al. Optimal Instrumental Variable Estimates of the AR-parameters of an ARMA Process, IEEE Trans. Autom. Control, Volume AC-30, 1985, pp. 1066–1074.