# polyreg

Powers and products of standard regressors

## Syntax

R = polyreg(model)
R = polyreg(model,'MaxPower',n)
R = polyreg(model,'MaxPower',n,'CrossTerm',CrossTermVal)

## Description

R = polyreg(model) creates an array R of polynomial regressors up to the power 2. If a model order has input u and output y, na=nb=2, and delay nk=1, polynomial regressors are y(t−1)2, u(t−1)2, y(t−2)2, u(t−2)2. model is an idnlarx object. You must add these regressors to the model by assigning the CustomRegressors model property or by using addreg.

R = polyreg(model,'MaxPower',n) creates an array R of polynomial regressors up to the power n. Excludes terms of power 1 and cross terms, such as y(t−1)*u(t−1).

R = polyreg(model,'MaxPower',n,'CrossTerm',CrossTermVal) creates an array R of polynomial regressors up to the power n and includes cross terms (products of standards regressors) when CrossTermVal is 'on'. By default, CrossTermVal is 'off'.

## Examples

collapse all

Estimate a nonlinear ARX model with $na=2$, $nb=2$, and $nk=1$, and nonlinearity estimator wavenet.

m = nlarx(z1,[2 2 1]);

Create polynomial regressors.

R = polyreg(m);

Estimate the model.

m = nlarx(z1,[2 2 1],'wavenet','CustomReg',R);

View all model regressors (standard and custom).

getreg(m)
Regressors:
y1(t-1)
y1(t-2)
u1(t-1)
u1(t-2)
y1(t-1).^2
y1(t-2).^2
u1(t-1).^2
u1(t-2).^2

Estimate a nonlinear ARX model with $na=2$, $nb=1$, and $nk=1$, and nonlinearity estimator wavenet.

m = nlarx(z1,[2 1 1]);

Create polynomial regressors.

R = polyreg(m,'MaxPower',3,'CrossTerm','on')
16x1 array of Custom Regressors with fields: Function, Arguments, Delays, Vectorized

If the model m has three standard regressors a, b and c, then R includes the terms ${a}^{2}$, ${b}^{2}$, ${c}^{2}$, $ab$, $ac$, $bc$, ${a}^{2}b$, ${a}^{2}c$, $a{b}^{2}$, $abc$, $a{c}^{2}$, ${b}^{2}c$, $b{c}^{2}$, ${a}^{3}$, ${b}^{3}$, and ${c}^{3}$.

Estimate the model.

m = nlarx(z1,[2 1 1],'wavenet','CustomReg',R);