# Documentation

### This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English version of the page.

To view all translated materials including this page, select Japan from the country navigator on the bottom of this page.

## Estimate Conditional Mean and Variance Models

This example shows how to estimate a composite conditional mean and variance model using `estimate`.

### Load the Data and Specify the Model.

Load the NASDAQ data included with the toolbox. Convert the daily close composite index series to a return series. For numerical stability, convert the returns to percentage returns. Specify an AR(1) and GARCH(1,1) composite model. This is a model of the form

where ,

and is an independent and identically distributed standardized Gaussian process.

```load Data_EquityIdx nasdaq = DataTable.NASDAQ; r = 100*price2ret(nasdaq); T = length(r); Mdl = arima('ARLags',1,'Variance',garch(1,1))```
```Mdl = ARIMA(1,0,0) Model: -------------------- Distribution: Name = 'Gaussian' P: 1 D: 0 Q: 0 Constant: NaN AR: {NaN} at Lags [1] SAR: {} MA: {} SMA: {} Variance: [GARCH(1,1) Model] ```

### Estimate the Model Parameters Without Using Presample Data.

Fit the model, `Mdl`, to the return series, `r`, using `estimate`. Use the presample observations that `estimate` automatically generates.

`EstMdl = estimate(Mdl,r);`
``` ARIMA(1,0,0) Model: -------------------- Conditional Probability Distribution: Gaussian Standard t Parameter Value Error Statistic ----------- ----------- ------------ ----------- Constant 0.072632 0.0180473 4.02454 AR{1} 0.138157 0.0198931 6.945 GARCH(1,1) Conditional Variance Model: ---------------------------------------- Conditional Probability Distribution: Gaussian Standard t Parameter Value Error Statistic ----------- ----------- ------------ ----------- Constant 0.0223769 0.00332008 6.73988 GARCH{1} 0.873119 0.00910187 95.9275 ARCH{1} 0.118649 0.00871698 13.6112 ```

The estimation display shows the five estimated parameters and their corresponding standard errors (the AR(1) conditional mean model has two parameters, and the GARCH(1,1) conditional variance model has three parameters).

The fitted model (`EstMdl`) is

where and

All t statistics are greater than two, suggesting all parameters are statistically significant.

### Infer the Conditional Variances and Residuals.

Infer and plot the conditional variances and standardized residuals. Also output the loglikelihood objective function value.

```[res,v,logL] = infer(EstMdl,r); figure subplot(2,1,1) plot(v) xlim([0,T]) title('Conditional Variance') subplot(2,1,2) plot(res./sqrt(v)) xlim([0,T]) title('Standardized Residuals')```

The conditional variances increase after observation 2000. This corresponds to the increased volatility seen in the original return series.

The standardized residuals have more large values (larger than 2 or 3 in absolute value) than expected under a standard normal distribution. This suggests a Student's t distribution might be more appropriate for the innovation distribution.

### Fit a Model With a t-Innovation Distribution.

Modify the model so that it has a Student's t-innovation distribution. Fit the modified model to the NASDAQ return series. Specify an initial value for the variance model constant term.

```MdlT = Mdl; MdlT.Distribution = 't'; EstMdlT = estimate(MdlT,r,'Variance0',{'Constant0',0.001});```
``` ARIMA(1,0,0) Model: -------------------- Conditional Probability Distribution: t Standard t Parameter Value Error Statistic ----------- ----------- ------------ ----------- Constant 0.0934881 0.0166938 5.60018 AR{1} 0.139107 0.0188565 7.37715 DoF 7.47746 0.882611 8.47198 GARCH(1,1) Conditional Variance Model: ---------------------------------------- Conditional Probability Distribution: t Standard t Parameter Value Error Statistic ----------- ----------- ------------ ----------- Constant 0.0112458 0.0036305 3.09759 GARCH{1} 0.907661 0.0105157 86.315 ARCH{1} 0.0898975 0.0108355 8.29661 DoF 7.47746 0.882611 8.47198 ```

The coefficient estimates change slightly when the t distribution is used for the innovations. The second model fit (`EstMdlT`) has one additional parameter estimate, the t distribution degrees of freedom. The estimated degrees of freedom are relatively small (about 8), indicating significant departure from normality.

### Compare the Model Fits.

Compare the two model fits (Gaussian and t-innovation distribution) using the Akaike information criterion (AIC) and Bayesian information criterion (BIC). First, obtain the loglikelihood objective function value for the second fit.

```[resT,vT,logLT] = infer(EstMdlT,r); [aic,bic] = aicbic([logL,logLT],[5,6],T)```
```aic = 1.0e+03 * 9.4929 9.3807 ```
```bic = 1.0e+03 * 9.5230 9.4168 ```

The second model has six parameters compared to five in the first model (because of the t distribution degrees of freedom). Despite this, both information criteria favor the model with the Student's t distribution. The AIC and BIC values are smaller for the t innovation distribution.