# selstruc

Select model order for single-output ARX models

## Syntax

```nn = selstruc(v)
[nn,vmod] = selstruc(v,c)
```

## Description

Note

Use `selstruc` for single-output systems only. `selstruc` supports both single-input and multiple-input systems.

`selstruc` is a function to help choose a model structure (order) from the information contained in the matrix `v` obtained as the output from `arxstruc` or `ivstruc`.

The default value of `c` is `'plot'`. The plot shows the percentage of the output variance that is not explained by the model as a function of the number of parameters used. Each value shows the best fit for that number of parameters. By clicking in the plot you can examine which orders are of interest. When you click , the variable `nn` is exported to the workspace as the optimal model structure for your choice of number of parameters. Several choices can be made.

`c = 'aic'` gives no plots, but returns in `nn` the structure that minimizes

`$\begin{array}{c}{V}_{\mathrm{mod}}=\mathrm{log}\left(V\left(1+\frac{2d}{N}\right)\right)\\ =\mathrm{log}\left(V\right)+\frac{2d}{N},N\gg d\end{array}$`

where V is the loss function, d is the total number of parameters in the structure in question, and N is the number of data points used for the estimation. $\mathrm{log}\left(V\right)+\frac{2d}{N}$ is the Akaike's Information Criterion (AIC). See `aic` for more details.

`c = 'mdl'` returns in `nn` the structure that minimizes Rissanen's Minimum Description Length (MDL) criterion.

`${V}_{\text{mod}}=V\left(1+\frac{d\mathrm{log}\left(N\right)}{N}\right)$`

When `c` equals a numerical value, the structure that minimizes ${V}_{\mathrm{mod}}=V\left(1+\frac{cd}{N}\right)$

is selected.

The output argument `vmod` has the same format as `v`, but it contains the logarithms of the accordingly modified criteria.

## Examples

collapse all

Create estimation and validation data sets

```load iddata1; ze = z1(1:150); zv = z1(151:300);```

Generate model-order combinations for estimation, specifying ranges for model orders and delays.

`NN = struc(1:3,1:2,2:4);`

Estimate ARX models using the instrumental variable method, and compute the loss function for each model order combination.

`V = ivstruc(ze,zv,NN);`

Select the model order with the best fit to the validation data.

`order = selstruc(V,0);`

Estimate an ARX model of selected order.

`M = iv4(ze,order);`

Create estimation and validation data sets.

```load co2data; Ts = 0.5; % Sample time is 0.5 min ze = iddata(Output_exp1,Input_exp1,Ts); zv = iddata(Output_exp2,Input_exp2,Ts);```

Generate model-order combinations for:

• `na` = `2:4`

• `nb` = `2:5` for the first input, and `1` or `4` for the second input.

• `nk` = `1:4` for the first input, and `0` for the second input.

`NN = struc(2:4,2:5,[1 4],1:4,0);`

Estimate an ARX model for each model order combination.

`V = arxstruc(ze,zv,NN);`

Select the model order with the best fit to the validation data.

`order = selstruc(V,0);`

Estimate an ARX model of selected order.

`M = arx(ze,order);`

## Version History

Introduced before R2006a