rarx
(To be removed) Estimate parameters of ARX or AR models recursively
Note
rarx
will be removed in a future release. Use recursiveAR
or recursiveARX
instead.
Syntax
thm = rarx(z,nn,adm,adg)
[thm,yhat,P,phi] = rarx(z,nn,adm,adg,th0,P0,phi0)
Description
thm = rarx(z,nn,adm,adg)
estimates the parameters
thm
of single-output ARX model from input-output data
z
and model orders nn
using the algorithm
specified by adm
and adg
. If z
is a time series y
and nn = na
,
rarx
estimates the parameters of a single-output AR model.
[thm,yhat,P,phi] = rarx(z,nn,adm,adg,th0,P0,phi0)
estimates the
parameters thm
, the predicted output yhat
, final
values of the scaled covariance matrix of the parameters P
, and final
values of the data vector phi
of single-output ARX model from
input-output data z
and model orders nn
using the
algorithm specified by adm
and adg
. If
z
is a time series y
and nn =
na
, rarx
estimates the parameters of a single-output AR
model.
Input Arguments
z
Name of the matrix
iddata
object that represents the input-output data or a matrixz = [y u]
, wherey
andu
are column vectors.For multiple-input models, the
u
matrix contains each input as a column vector:u = [u1 ... unu]
nn
For input-output models, specifies the structure of the ARX model as:
nn = [na nb nk]
where
na
andnb
are the orders of the ARX model, andnk
is the delay.For multiple-input models,
nb
andnk
are row vectors that define orders and delays for each input.For time-series models,
nn = na
, wherena
is the order of the AR model.Note
The delay
nk
must be larger than0
. If you wantnk = 0
, shift the input sequence appropriately and usenk = 1
(seenkshift
).adm
andadg
adm = 'ff'
andadg
=lam
specify the forgetting factor algorithm with the forgetting factor λ=lam
. This algorithm is also known as recursive least squares (RLS). In this case, the matrixP
has the following interpretation: R2/2
*P
is approximately equal to the covariance matrix of the estimated parameters.R2 is the variance of the innovations (the true prediction errors e(t)).adm ='ug'
andadg = gam
specify the unnormalized gradient algorithm with gain gamma =gam
. This algorithm is also known as the normalized least mean squares (LMS).adm ='ng'
andadg
=gam
specify the normalized gradient or normalized least mean squares (NLMS) algorithm. In these cases,P
is not applicable.adm ='kf'
andadg =R1
specify the Kalman filter based algorithm with R2=1
and R1 =R1
. If the variance of the innovations e(t) is not unity but R2; then R2*P
is the covariance matrix of the parameter estimates, while R1 =R1
/R2 is the covariance matrix of the parameter changes.th0
Initial value of the parameters in a row vector, consistent with the rows of
thm
.Default: All zeros.
P0
Initial values of the scaled covariance matrix of the parameters.
Default: 104 times the identity matrix.
phi0
The argument
phi0
contains the initial values of the data vector:φ(t) = [y(t–1),...,y(t–na),u(t–1),...,u(t–nb–nk+1)]
If
z = [y(1),u(1); ... ;y(N),u(N)]
, phi0 = φ(1) and phi = φ(N). For online use ofrarx
, usephi0
,th0
, andP0
as the previous outputsphi
,thm
(last row), andP
.Default: All zeros.
Output Arguments
thm
Estimated parameters of the model. The
k
th row ofthm
contains the parameters associated with timek
; that is, the estimate parameters are based on the data in rows up to and including rowk
inz
. Each row ofthm
contains the estimated parameters in the following order:thm(k,:) = [a1,a2,...,ana,b1,...,bnb]
For a multiple-input model, the b are grouped by input. For example, the b parameters associated with the first input are listed first, and the b parameters associated with the second input are listed next.
yhat
Predicted value of the output, according to the current model; that is, row
k
ofyhat
contains the predicted value ofy(k)
based on all past data.
P
Final values of the scaled covariance matrix of the parameters.
phi
phi
contains the final values of the data vector:φ(t) = [y(t–1),...,y(t–na),u(t–1),...,u(t–nb–nk+1)]
Examples
Adaptive noise canceling: The signal y contains a component that originates from a known signal r. Remove this component by recursively estimating the system that relates r to y using a sixth-order FIR model and the NLMS algorithm.
z = [y r]; [thm,noise] = rarx(z,[0 6 1],'ng',0.1); % noise is the adaptive estimate of the noise % component of y plot(y-noise)
If this is an online application, you can plot the best estimate of the signal
y - noise
at the same time as the data y
and u become available, use the following code:
phi = zeros(6,1); P=1000*eye(6); th = zeros(1,6); axis([0 100 -2 2]); plot(0,0,'*'), hold on % Use a while loop while ~abort [y,r,abort] = readAD(time); [th,ns,P,phi] = rarx([y r],'ff',0.98,th,P,phi); plot(time,y-ns,'*') time = time + Dt end
This example uses a forgetting factor algorithm with a forgetting factor of 0.98.
readAD
is a function that reads the value of an A/D converter at
the indicated time instant.
More About
Version History
Introduced before R2006a
See Also
nkshift
| recursiveAR
| recursiveARX
| rpem
| rplr