Main Content

## Examine Model Residuals

This example shows how you can use residual analysis to evaluate model quality.

### Creating Residual Plots

1. To load the sample System Identification app session that contains estimated models, type the following command in the MATLAB® Command Window:

`systemIdentification('dryer2_linear_models')`
2. To generate a residual analysis plot, select the Model resids check box in the System Identification app.

This opens an empty plot.

3. In the System Identification app window, click each parametric model icon to display it on the Residual Analysis plot. Do not click the nonparametric model `spad`, as residual analysis plots are not available for this model. ### Description of the Residual Plot Axes

The top axes show the autocorrelation of residuals for the output (whiteness test). The horizontal scale is the number of lags, which is the time difference (in samples) between the signals at which the correlation is estimated. The horizontal dashed lines on the plot represent the confidence interval of the corresponding estimates. Any fluctuations within the confidence interval are considered to be insignificant. Six of the models —`arxqs`, `n4s3`, `arx223`, `tf1`,`ss1`, and `amx2222` — produce residuals that enter outside the confidence interval. A good model should have a residual autocorrelation function within the confidence interval, indicating that the residuals are uncorrelated.

The bottom axes show the cross-correlation of the residuals with the input. A good model should have residuals uncorrelated with past inputs (independence test). Evidence of correlation indicates that the model does not describe how the output is formed from the corresponding input. For example, when there is a peak outside the confidence interval for lag k, this means that the contribution to the output y(t) that originates from the input u(t-k) is not properly described by the model. The models `arxqs` and `amx2222` extend beyond the confidence interval and do not perform as well as the other models.

### Validating Models Using Analyzing Residuals

To remove models with poor performance from the Residual Analysis plot, click the model icons `arxqs`, `n4s3`, `arx223`, `tf1`, `ss1`, and `amx2222` in the System Identification app.

The Residual Analysis plot now includes only the two models that pass the residual tests: `arx692` and `amx3322`. The plots for these models fall primarily within the confidence intervals, although the `amx3322` plot shows some excursions slightly outside of the boundaries. If these excursions are acceptable, it is reasonable to pick the `amx3322` model because it is a simpler low-order model. If the excursions are not acceptable, you can use the `arx392` model instead.

## Support Get trial now
{"ft_lang_label":"__label__en","ft_lang_prob":0.820404,"math_prob":0.92221063,"size":2561,"snap":"2021-04-2021-17","text_gpt3_token_len":577,"char_repetition_ratio":0.1474384,"word_repetition_ratio":0.019900497,"special_character_ratio":0.20187427,"punctuation_ratio":0.101123594,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9612703,"pos_list":[0,1,2,3,4,5,6],"im_url_duplicate_count":[null,1,null,1,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-04-12T01:31:46Z\",\"WARC-Record-ID\":\"<urn:uuid:ba69cc57-e304-4361-80be-fb3431059174>\",\"Content-Length\":\"66679\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:705d31c4-c473-4428-8537-e2f8bfdc845a>\",\"WARC-Concurrent-To\":\"<urn:uuid:77b01227-b2c3-41ca-b3e3-26efb371c7f3>\",\"WARC-IP-Address\":\"23.197.108.134\",\"WARC-Target-URI\":\"https://es.mathworks.com/help/ident/ug/examine-model-residuals.html\",\"WARC-Payload-Digest\":\"sha1:CWF3EGEZFORYSS5QTSC6BC45LV4PXGYS\",\"WARC-Block-Digest\":\"sha1:GJH2DXL5AVNI3MMDHVLDQ7RTM45YKWIT\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-17/CC-MAIN-2021-17_segments_1618038065903.7_warc_CC-MAIN-20210411233715-20210412023715-00253.warc.gz\"}"}