MATLAB Answers

## Undefined function 'filter' for input arguments of type 'arima'

Asked by Pedro

### Pedro (view profile)

on 12 Nov 2012

Hey,

Can someone help me with the error I'm getting with the following code:

```load Data_GlobalIdx1 % Import daily index closings
nIndices = size(Data, 2); % Number of Indices
weights = repmat(1/nIndices, nIndices, 1); % Equally Weighted Portfolio
returns = price2ret(Data, [], 'Periodic')*weights; % Arithmetic Portfolio Returns
returns = log(1 + returns); % Logarithmic Portfolio Returns
T = size(returns, 1); % Historical Returns
model = arima('AR', NaN, 'Distribution', 't', 'Variance', egarch(1,1)); % egarch(1,1) model
options = optimset('fmincon');
options = optimset(options, 'Display', 'off', 'Diagnostics', 'off', 'Algorithm', 'sqp', 'TolCon', 1e-7);
fit = estimate(model, returns, 'options', options); % Fit the model
[residuals, variances] = infer(fit, returns); %infer residuals and variances
standardizedResiduals = residuals./sqrt(variances);
s = RandStream.getGlobalStream(); % reset (s)
nTrials = 20000; % # of independent random trials
horizon = 22; % VaR forecast horizon
bootstrappedResiduals = standardizedResiduals(unidrnd(T, horizon, nTrials));
Y0 = returns(end); % Presample Returns
Z0 = residuals(end)./sqrt(variances(end)); % Presample Model Standardized Residuals
V0 = variances(end); % Presample Variances
portfolioReturns = filter(fit, bootstrappedResiduals, 'Y0', Y0, 'Z0', Z0, 'V0', V0);
```

The error I get is the following:

Undefined function 'filter' for input arguments of type 'arima'. Error in bootstrap_VaR (line 24) portfolioReturns = filter(fit, bootstrappedResiduals, 'Y0', Y0, 'Z0', Z0, 'V0', V0);

The code I used comes straight from mathworks:

http://www.mathworks.it/it/help/econ/examples/using-bootstrapping-and-filtered-historical-simulation-to-evaluate-market-risk.html

Thank you very much for your help.

Pedro

## 2 Answers

### Jan Simon (view profile)

Answer by Jan Simon

### Jan Simon (view profile)

on 13 Nov 2012
Edited by Jan Simon

### Jan Simon (view profile)

on 12 Jan 2013

Do you have an installed and licenced Econometrics Toolbox? Then filter should be found: http://www.mathworks.com/help/econ/arima.filter.html. But if you do not have this toolbox, the "arime()" call should fail already. Strange.

Pedro

### Pedro (view profile)

on 13 Nov 2012

Hi Jan,

Thank you for your answer. I do have the econometrics toolbox, and the arima() works fine. It is only when I try the filter that I get this problem.

Thanks,

Pedro

Jan Simon

### Jan Simon (view profile)

on 13 Nov 2012

What is replied for

```which filter -all
```

? Is the one of the Econometrics Toolbox found? Can you find the local help text of this filter function?

### Shashank Prasanna (view profile)

Answer by Shashank Prasanna

### Shashank Prasanna (view profile)

on 12 Jan 2013

The filter method for the arima class (along with garch egarch and gjr) was introduced in MATLAB 2012b econometric toolbox release. Here is the release notes that has details about this addition: http://www.mathworks.com/help/econ/release-notes.html

Could you confirm that you have this release of MATLAB and are still facing this issue? If you have a professional license and a valid SMS feel free to login to your MathWorks account and upgrade to the latest release.

#### 0 Comments

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi test

### Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

New to MATLAB?