Main Content

arxstruc

Compute loss functions for single-output ARX models

Description

example

V = arxstruc(dataest,dataval,NN) estimates the loss function V for the estimation and validation data in dataest and dataval, respectively. dataest and dataval can be in the form of a timetable, a comma-separated pair of numeric matrices, or an iddata object. It can also be an idfrd object defining frequency-response data.

If dataest and dataval are timetables, you can select specific input and output channels to use for estimation by specifying the channel names in the InputName and OutputName name-value arguments. Otherwise, the software assumes that the last timetable variable channel is the single output channel and the remaining variables are all input channels.

V contains both the loss functions and the corresponding orders and delays. You can analyze V with selstruc, which evaluates V and allows you to select a suitable model structure.

Use arxstruc only for single-output ARX models. arxstruc supports both single-input and multiple-input systems.

V = arxstruc(___,Name,Value) uses additional options specified by one or more name-value arguments.

Examples

collapse all

Create an ARX model for generating data.

A = [1 -1.5 0.7];
B = [0 1 0.5];
m0 = idpoly(A,B);

Generate random input and additive noise signals.

u = idinput(400,'rbs');
e = 0.1*randn(400,1);

Simulate the model output using the defined input and error signals.

y = sim(m0,[u e]);

Generate model-order combinations for estimation. Specify a delay of 1 for all models, and a model order range between 1 and 5 for na and nb.

NN = struc(1:5,1:5,1);

Estimate ARX models and compute the loss function for each model order combination. The input data is split into estimation and validation data sets.

V = arxstruc(u(1:200),y(1:200),u(201:400),y(201:400),NN);

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

order = selstruc(V,0)
order = 1×3

     2     2     1

Estimate an ARX model of selected order.

M = arx(u,y,order)
M =
Discrete-time ARX model: A(z)y(t) = B(z)u(t) + e(t)
  A(z) = 1 - 1.498 z^-1 + 0.6971 z^-2              
                                                   
  B(z) = 1.004 z^-1 + 0.5028 z^-2                  
                                                   
Sample time: 1 seconds
  
Parameterization:
   Polynomial orders:   na=2   nb=2   nk=1
   Number of free coefficients: 4
   Use "polydata", "getpvec", "getcov" for parameters and their uncertainties.

Status:                                          
Estimated using ARX on time domain data "u".     
Fit to estimation data: 97.75% (prediction focus)
FPE: 0.009874, MSE: 0.009582                     
 

Load estimation and validation data sets and view the variable names.

load co2datatt tte ttv
head(tte,3)
     Time      u1     u2      y1   
    _______    ___    __    _______

    0.5 sec    170    50    -44.302
    1 sec      170    50    -44.675
    1.5 sec    170    50     -45.29

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(tte,ttv,NN);

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

order = selstruc(V,0)
order = 1×5

     2     4     4     2     0

Estimate an ARX model of selected order.

M = arx(tte,order)
M =
Discrete-time ARX model: A(z)y(t) = B(z)u(t) + e(t)               
  A(z) = 1 - 1.252 z^-1 + 0.302 z^-2                              
                                                                  
  B1(z) = -0.3182 z^-2 - 0.1292 z^-3 + 0.2883 z^-4 + 0.001051 z^-5
                                                                  
  B2(z) = -0.02705 + 0.01948 z^-1 + 0.1695 z^-2 + 0.3278 z^-3     
                                                                  
Sample time: 0.5 seconds
  
Parameterization:
   Polynomial orders:   na=2   nb=[4 4]   nk=[2 0]
   Number of free coefficients: 10
   Use "polydata", "getpvec", "getcov" for parameters and their uncertainties.

Status:                                          
Estimated using ARX on time domain data "tte".   
Fit to estimation data: 88.59% (prediction focus)
FPE: 3.993, MSE: 3.938                           
 

Input Arguments

collapse all

Estimation data, specified as a timetable, a comma-separated pair of numeric matrices, an iddata object, or an idfrd object .

The specification for dataest depends on the data type.

Timetable

Specify dataest as a timetable that uses a regularly spaced time vector containing variables that represent input and output channels. Use the InputName and OutputName name-value arguments to select specific channels for estimation.

Comma-Separated Matrix Pair

Specify dataest as a comma-separated pair of matrices that contain the input and output time-domain signal values u,y.

Data Object

Specify dataest as an iddata object or an idfrd that contains the input and output data.

For more information about working with estimation data types, see Data Domains and Data Types in System Identification Toolbox.

Estimation data, specified in the same format and input/output channel order as dataest. dataval can be the same data as dataest.

Number of ARX model structures to evaluate, specified as an Nn-by-3 matrix, where Nn is the number of model structures.

Each row of NN has the form nn = [na nb nk].

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: V = arxstruc(dataest,dataval,NN,'InputName',"u2") selects the timetable variable u2 as the single input channel.

Input channel names, specified as a string, character vector, string array, or cell array of character vectors.

If you are using a timetable for the data source, the names in InputName must be a subset of the timetable variables.

Example: V = arxstruc(tt,__,'InputName',["u1" "u2"]) selects the variables u1 and u2 as the input channels from the timetable tt to use for the estimation.

Output channel name, specified as a string or character vector.

If you are using a timetable for the data source, the name in OutputName must be a subset of the timetable variables.

Example: V = arxstruc(___,'OutputName',"y3") selects the variable y3 as the output channel from the timetable tt to use for the estimation.

Output Arguments

collapse all

Loss function, specified as an 4-by-(Nn+1) matrix.

The first row of V contains the loss functions. The remaining rows of V contain the transpose of NN, so that the orders and delays are given just below the corresponding loss functions. The last column of V contains the number of data points in dataest.

Version History

Introduced before R2006a

expand all

See Also

| | | |