Documentation

## Estimate Polynomial Models at the Command Line

### Using arx and iv4 to Estimate ARX Models

You can estimate single-output and multiple-output ARX models using the `arx` and `iv4` commands. For information about the algorithms, see Polynomial Model Estimation Algorithms.

You can use the following general syntax to both configure and estimate ARX models:

```% Using ARX method m = arx(data,[na nb nk],opt); % Using IV method m = iv4(data,[na nb nk],opt); ```

`data` is the estimation data and `[na nb nk]` specifies the model orders, as discussed in What Are Polynomial Models?.

The third input argument `opt` contains the options for configuring the estimation of the ARX model, such as handling of initial conditions and input offsets. You can create and configure the option set `opt` using the `arxOptions` and `iv4Options` commands. The three input arguments can also be followed by name and value pairs to specify optional model structure attributes such as `InputDelay`, `IODelay`, and `IntegrateNoise`.

To get discrete-time models, use the time-domain data (`iddata` object).

### Note

Continuous-time polynomials of ARX structure are not supported.

For more information about validating you model, see Validating Models After Estimation.

You can use `pem` or `polyest` to refine parameter estimates of an existing polynomial model, as described in Refine Linear Parametric Models.

For detailed information about these commands, see the corresponding reference page.

### Tip

You can use the estimated ARX model for initializing a nonlinear estimation at the command line, which improves the fit of the model. See Initialize Nonlinear ARX Estimation Using Linear Model.

### Using `polyest` to Estimate Polynomial Models

You can estimate any polynomial model using the iterative prediction-error estimation method `polyest`. For Gaussian disturbances of unknown variance, this method gives the maximum likelihood estimate. The resulting models are stored as `idpoly` model objects.

Use the following general syntax to both configure and estimate polynomial models:

`m = polyest(data,[na nb nc nd nf nk],opt,Name,Value);`

where `data` is the estimation data. `na`, `nb`, `nc`, `nd`, `nf` are integers that specify the model orders, and `nk` specifies the input delays for each input.For more information about model orders, see What Are Polynomial Models?.

### Tip

You do not need to construct the model object using `idpoly` before estimation.

If you want to estimate the coefficients of all five polynomials, A, B, C, D, and F, you must specify an integer order for each polynomial. However, if you want to specify an ARMAX model for example, which includes only the A, B, and C polynomials, you must set `nd` and `nf` to zero matrices of the appropriate size. For some simpler configurations, there are dedicated estimation commands such as `arx`, `armax`, `bj`, and `oe`, which deliver the required model by using just the required orders. For example, `oe(data,[nb nf nk],opt)` estimates an output-error structure polynomial model.

### Note

To get faster estimation of ARX models, use `arx` or `iv4` instead of `polyest`.

In addition to the polynomial models listed in What Are Polynomial Models?, you can use `polyest` to model the ARARX structure—called the generalized least-squares model—by setting `nc=nf=0`. You can also model the ARARMAX structure—called the extended matrix model—by setting `nf=0`.

The third input argument, `opt`, contains the options for configuring the estimation of the polynomial model, such as handling of initial conditions, input offsets and search algorithm. You can create and configure the option set `opt` using the `polyestOptions` command. The three input arguments can also be followed by name and value pairs to specify optional model structure attributes such as `InputDelay`, `IODelay`, and `IntegrateNoise`.

For ARMAX, Box-Jenkins, and Output-Error models—which can only be estimated using the iterative prediction-error method—use the `armax`, `bj`, and `oe` estimation commands, respectively. These commands are versions of `polyest` with simplified syntax for these specific model structures, as follows:

```m = armax(Data,[na nb nc nk]); m = oe(Data,[nb nf nk]); m = bj(Data,[nb nc nd nf nk]); ```

Similar to `polyest`, you can specify as input arguments the option set configured using commands `armaxOptions`, `oeOptions`, and `bjOptions` for the estimators `armax`, `oe`, and `bj` respectively. You can also use name and value pairs to configure additional model structure attributes.

### Tip

If your data is sampled fast, it might help to apply a lowpass filter to the data before estimating the model, or specify a frequency range for the `WeightingFilter` property during estimation. For example, to model only data in the frequency range 0-10 rad/s, use the `WeightingFilter` property, as follows:

```opt = oeOptions('`WeightingFilter`',[0 10]); m = oe(Data, [nb nf nk], opt);```

You can use `pem` or `polyest` to refine parameter estimates of an existing polynomial model (of any configuration), as described in Refine Linear Parametric Models.

For more information, see `polyest`, `pem` and `idpoly`.

## Related Examples
{"ft_lang_label":"__label__en","ft_lang_prob":0.7143177,"math_prob":0.94174117,"size":4863,"snap":"2019-35-2019-39","text_gpt3_token_len":1114,"char_repetition_ratio":0.14756122,"word_repetition_ratio":0.17169069,"special_character_ratio":0.20111042,"punctuation_ratio":0.13827434,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9861265,"pos_list":[0,1,2],"im_url_duplicate_count":[null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-09-18T03:48:06Z\",\"WARC-Record-ID\":\"<urn:uuid:47e82d40-c7b8-4ccc-9637-fd4329c28937>\",\"Content-Length\":\"72313\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:a9199b2e-d2ed-4dcc-b90d-45bfc9212299>\",\"WARC-Concurrent-To\":\"<urn:uuid:bd3346fd-fe52-470f-b2cb-2f3b3fdc143a>\",\"WARC-IP-Address\":\"23.50.112.17\",\"WARC-Target-URI\":\"https://ch.mathworks.com/help/ident/ug/estimate-polynomial-models-at-the-command-line.html\",\"WARC-Payload-Digest\":\"sha1:VIE7FMXFV2WPYFWVDTDYLUJJZKME3EYD\",\"WARC-Block-Digest\":\"sha1:T6PRPDRR5XHZHSNF6LYLYUS5GPPPBVQF\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-39/CC-MAIN-2019-39_segments_1568514573176.51_warc_CC-MAIN-20190918024332-20190918050332-00273.warc.gz\"}"}