Title: | System Identification in R |
---|---|
Description: | Provides functions for constructing mathematical models of dynamical systems from measured input-output data. |
Authors: | Suraj Yerramilli, Arun Tangirala |
Maintainer: | Suraj Yerramilli <[email protected]> |
License: | GPL-3 |
Version: | 1.0.4 |
Built: | 2025-02-13 04:12:29 UTC |
Source: | https://github.com/cran/sysid |
Assign multiple variables from a list or function return object
l %=% r
l %=% r
l |
the variables to be assigned |
r |
the list or function-return object |
Fit an ARMAX model of the specified order given the input-output data
armax(x, order = c(0, 1, 1, 0), init_sys = NULL, intNoise = FALSE, options = optimOptions())
armax(x, order = c(0, 1, 1, 0), init_sys = NULL, intNoise = FALSE, options = optimOptions())
x |
an object of class |
order |
Specification of the orders: the four integer components (na,nb,nc,nk) are the order of polynolnomial A, order of polynomial B + 1, order of the polynomial C,and the input-output delay respectively |
init_sys |
Linear polynomial model that configures the initial parameterization.
Must be an ARMAX model. Overrules the |
intNoise |
Logical variable indicating whether to add integrators in
the noise channel (Default= |
options |
Estimation Options, setup using |
SISO ARMAX models are of the form
The function estimates the coefficients using non-linear least squares
(Levenberg-Marquardt Algorithm)
The data is expected to have no offsets or trends. They can be removed
using the detrend
function.
An object of class estpoly
containing the following elements:
sys |
an |
fitted.values |
the predicted response |
residuals |
the residuals |
input |
the input data used |
call |
the matched call |
stats |
A list containing the following fields: |
options |
Option set used for estimation. If no custom options were configured, this is a set of default options |
termination |
Termination conditions for the iterative
search used for prediction error minimization:
|
Arun K. Tangirala (2015), Principles of System Identification: Theory and Practice, CRC Press, Boca Raton. Sections 14.4.1, 21.6.2
data(armaxsim) z <- dataSlice(armaxsim,end=1533) # training set mod_armax <- armax(z,c(1,2,1,2)) mod_armax
data(armaxsim) z <- dataSlice(armaxsim,end=1533) # training set mod_armax <- armax(z,c(1,2,1,2)) mod_armax
This dataset contains 2555 samples simulated from the following ARMAX model:
armaxsim
armaxsim
an idframe
object with 2555 samples, one input and one
output
The model is simulated with a 2555 samples long full-band PRBS input. The noise variance is set to 0.1
Fit an ARX model of the specified order given the input-output data
arx(x, order = c(1, 1, 1), lambda = 0.1, intNoise = FALSE, fixed = NULL)
arx(x, order = c(1, 1, 1), lambda = 0.1, intNoise = FALSE, fixed = NULL)
x |
an object of class |
order |
Specification of the orders: the three integer components (na,nb,nk) are the order of polynolnomial A, (order of polynomial B + 1) and the input-output delay |
lambda |
Regularization parameter(Default= |
intNoise |
Logical variable indicating whether to add integrators in
the noise channel (Default= |
fixed |
list containing fixed parameters. If supplied, only |
SISO ARX models are of the form
The function estimates the coefficients using linear least squares (with
regularization).
The data is expected to have no offsets or trends. They can be removed
using the detrend
function.
To estimate finite impulse response(FIR
) models, specify the first
order to be zero.
An object of class estpoly
containing the following elements:
sys |
an |
fitted.values |
the predicted response |
residuals |
the residuals |
input |
the input data used |
call |
the matched call |
stats |
A list containing the following fields: |
Arun K. Tangirala (2015), Principles of System Identification: Theory and Practice, CRC Press, Boca Raton. Section 21.6.1
Lennart Ljung (1999), System Identification: Theory for the User, 2nd Edition, Prentice Hall, New York. Section 10.1
data(arxsim) mod_arx <- arx(arxsim,c(1,2,2)) mod_arx plot(mod_arx) # plot the predicted and actual responses
data(arxsim) mod_arx <- arx(arxsim,c(1,2,2)) mod_arx plot(mod_arx) # plot the predicted and actual responses
This dataset contains 2555 samples simulated from the following ARX model:
arxsim
arxsim
an idframe
object with 2555 samples, one input and one
output
The model is simulated with a 2555 samples long full-band PRBS input. The noise variance is set to 0.1
Fit a box-jenkins model of the specified order from input-output data
bj(z, order = c(1, 1, 1, 1, 0), init_sys = NULL, options = optimOptions())
bj(z, order = c(1, 1, 1, 1, 0), init_sys = NULL, options = optimOptions())
z |
an |
order |
Specification of the orders: the five integer components (nb,nc,nd,nf,nk) are order of polynomial B + 1, order of the polynomial C, order of the polynomial D, order of the polynomial F, and the input-output delay respectively |
init_sys |
Linear polynomial model that configures the initial parameterization.
Must be a BJ model. Overrules the |
options |
Estimation Options, setup using
|
SISO BJ models are of the form
The orders of Box-Jenkins model are defined as follows:
The function estimates the coefficients using non-linear least squares
(Levenberg-Marquardt Algorithm)
The data is expected to have no offsets or trends. They can be removed
using the detrend
function.
An object of class estpoly
containing the following elements:
sys |
an |
fitted.values |
the predicted response |
residuals |
the residuals |
input |
the input data used |
call |
the matched call |
stats |
A list containing the following fields: |
options |
Option set used for estimation. If no custom options were configured, this is a set of default options |
termination |
Termination conditions for the iterative
search used for prediction error minimization:
|
Arun K. Tangirala (2015), Principles of System Identification: Theory and Practice, CRC Press, Boca Raton. Sections 14.4.1, 17.5.2, 21.6.3
data(bjsim) z <- dataSlice(bjsim,end=1500) # training set mod_bj <- bj(z,c(2,1,1,1,2)) mod_bj residplot(mod_bj) # residual plots
data(bjsim) z <- dataSlice(bjsim,end=1500) # training set mod_bj <- bj(z,c(2,1,1,1,2)) mod_bj residplot(mod_bj) # residual plots
This dataset contains 2046 samples simulated from the following BJ model:
bjsim
bjsim
an idframe
object with 2046 samples, one input and one
output
The model is simulated with a 2046 samples long full-band PRBS input. The noise variance is set to 0.1
Plots the output predictions of model(s) superimposed over validation data, data, for comparison.
compare(data, nahead = 1, ...)
compare(data, nahead = 1, ...)
data |
validation data in the form of an |
nahead |
number of steps ahead at which to predict (Default:1). For infinite-
step ahead predictions, supply |
... |
models whose predictions are to be compared |
predict.estpoly
for obtaining model predictions
data(arxsim) mod1 <- arx(arxsim,c(1,2,2)) mod2 <- oe(arxsim,c(2,1,1)) compare(arxsim,nahead=Inf,mod1,mod2)
data(arxsim) mod1 <- arx(arxsim,c(1,2,2)) mod2 <- oe(arxsim,c(2,1,1)) compare(arxsim,nahead=Inf,mod1,mod2)
The Process is a model of a Continuous Stirring Tank Reactor,
where the reaction is exothermic and the concentration is
controlled by regulating the coolant flow.
cstr
cstr
an idframe
object with 7500 samples, one input and two
outputs
Inputs: q, Coolant Flow l/min Outputs:
Concentration mol/l
Temperature Kelvin
This dataset is derived from the cstr
dataset with few samples
containing missing values, in one or all variables. It is used to
demonstrate the capabilities of the misdata
routine.
cstr_mis
cstr_mis
an idframe
object with 7500 samples, one input and two
outputs
The Process is a model of a Continuous Stirring Tank Reactor,
where the reaction is exothermic and the concentration is
controlled by regulating the coolant flow.
cstrData
cstrData
an data.frame
object with 7500 rows and three columns:
q, Ca and T
Inputs: q, Coolant Flow l/min Outputs:
Concentration mol/l
Temperature Kelvin
ftp://ftp.esat.kuleuven.be/pub/SISTA/data/process_industry/cstr.dat.gz
dataSlice
is a subsetting method for objects of class idframe
. It
extracts the subset of the object data
observed between indices start
and end
. If a frequency is specified, the series is then re-sampled at the
new frequency.
dataSlice(data, start = NULL, end = NULL, freq = NULL)
dataSlice(data, start = NULL, end = NULL, freq = NULL)
data |
an object of class |
start |
the start index |
end |
the end index |
freq |
fraction of the original frequency at which the series to be sampled. |
The dataSlice function extends the window
function for idframe objects
an idframe object
data(cstr) cstrsub <- dataSlice(cstr,start=200,end=400) # extract between indices 200 and 400 cstrTrain <- dataSlice(cstr,end=4500) # extract upto index 4500 cstrTest <- dataSlice(cstr,start=6501) # extract from index 6501 till the end cstr_new <- dataSlice(cstr,freq=0.5) # resample data at half the original frequency
data(cstr) cstrsub <- dataSlice(cstr,start=200,end=400) # extract between indices 200 and 400 cstrTrain <- dataSlice(cstr,end=4500) # extract upto index 4500 cstrTest <- dataSlice(cstr,start=6501) # extract from index 6501 till the end cstr_new <- dataSlice(cstr,freq=0.5) # resample data at half the original frequency
Removes offsets or trends from data
detrend(x, type = 0)
detrend(x, type = 0)
x |
an object of class |
type |
argument indicating the type of trend to be removed (Default=
|
R
by default doesn't allow return of multiple objects. The %=%
operator and g
function in this package facillitate this behaviour. See
the examples section for more information.
A list containing two objects: the detrended data and the trend information
data(cstr) datatrain <- dataSlice(cstr,end=4500) datatest <- dataSlice(cstr,4501) g(Ztrain,tr) %=% detrend(datatrain) # Remove means g(Ztest) %=% detrend(datatest,tr)
data(cstr) datatrain <- dataSlice(cstr,end=4500) datatest <- dataSlice(cstr,4501) g(Ztrain,tr) %=% detrend(datatrain) # Remove means g(Ztest) %=% detrend(datatest,tr)
Estimated discrete-time polynomial model returned from an estimation routine.
estpoly(sys, fitted.values, residuals, options = NULL, call, stats, termination = NULL, input)
estpoly(sys, fitted.values, residuals, options = NULL, call, stats, termination = NULL, input)
sys |
an |
fitted.values |
1-step ahead predictions on the training dataset |
residuals |
1-step ahead prediction errors |
options |
optimization specification ser used (applicable for non-linear least squares) |
call |
the matched call |
stats |
a list containing estimation statistics |
termination |
termination criteria for optimization |
input |
input signal of the training data-set |
Do not use estpoly
for directly specifing an input-output polynomial model.
idpoly
is to be used instead
Estimates the emperical transfer function from the data by taking the ratio of the fourier transforms of the output and the input variables
etfe(data, n = 128)
etfe(data, n = 128)
data |
an object of class |
n |
frequency spacing (Default: |
an idfrd
object containing the estimated frequency response
Arun K. Tangirala (2015), Principles of System Identification: Theory and Practice, CRC Press, Boca Raton. Sections 5.3 and 20.4.2
data(arxsim) frf <- etfe(arxsim)
data(arxsim) frf <- etfe(arxsim)
Returns quantitative assessment of the estimated model as a list
fitch(x)
fitch(x)
x |
the estimated model |
A list containing the following elements
MSE |
Mean Square Error measure of how well the response of the model fits the estimation data |
FPE |
Final Prediction Error |
FitPer |
Normalized root mean squared error (NRMSE) measure of how well the response of the model fits the estimation data, expressed as a percentage. |
AIC |
Raw Akaike Information Citeria (AIC) measure of model quality |
AICc |
Small sample-size corrected AIC |
nAIC |
Normalized AIC |
BIC |
Bayesian Information Criteria (BIC) |
This dataset contains frequency response data of an unknown SISO system.
frd
frd
an idfrd
object with response at 128 frequency points
Obtain the parameter covariance matrix of the linear, identified parametric model
getcov(sys)
getcov(sys)
sys |
a linear, identified parametric model |
idframe
is an S3 class for storing and manipulating input-ouput data. It supports discrete time and frequency domain data.
idframe(output, input = NULL, Ts = 1, start = 0, end = NULL, unit = c("seconds", "minutes", "hours", "days")[1])
idframe(output, input = NULL, Ts = 1, start = 0, end = NULL, unit = c("seconds", "minutes", "hours", "days")[1])
output |
dataframe/matrix/vector containing the outputs |
input |
dataframe/matrix/vector containing the inputs |
Ts |
sampling interval (Default: 1) |
start |
Time of the first observation |
end |
Time of the last observation Optional Argument |
unit |
Time unit (Default: "seconds") |
an idframe object
plot.idframe
, the plot method for idframe objects
dataMatrix <- matrix(rnorm(1000),ncol=5) data <- idframe(output=dataMatrix[,3:5],input=dataMatrix[,1:2],Ts=1)
dataMatrix <- matrix(rnorm(1000),ncol=5) data <- idframe(output=dataMatrix[,3:5],input=dataMatrix[,1:2],Ts=1)
S3 class constructor for storing frequency response data
idfrd(respData, freq, Ts, spec = NULL, covData = NULL, noiseCov = NULL)
idfrd(respData, freq, Ts, spec = NULL, covData = NULL, noiseCov = NULL)
respData |
frequency response data. For SISO systems, supply a vector of frequency response values. For MIMO systems with Ny outputs and Nu inputs, supply an array of size c(Ny,Nu,Nw). |
freq |
frequency points of the response |
Ts |
sampling time of data |
spec |
power spectra and cross spectra of the system output disturbances (noise). Supply an array of size (Ny,Ny,Nw) |
covData |
response data covariance matrices. Supply an array of size (Ny,Nu,Nw,2,2). covData[ky,ku,kw,,] is the covariance matrix of respData[ky,ku,kw] |
noiseCov |
power spectra variance. Supply an array of size (Ny,Ny,Nw) |
an idfrd object
plot.idfrd
for generating bode plots,
spa
and etfe
for estimating the
frequency response given input/output data
idinput
is a function for generating input signals (rgs/rbs/prbs/sine) for identification purposes
idinput(n, type = "rgs", band = c(0, 1), levels = c(-1, 1))
idinput(n, type = "rgs", band = c(0, 1), levels = c(-1, 1))
n |
integer length of the input singal to be generated |
type |
the type of input signal to be generated. 'rgs' - generates random gaussian signal 'rbs' - generates random binary signal 'prbs' - generates pseudorandom binary signal 'sine' - generates a signal that is a sum of sinusoids Default value is type='rgs' |
band |
determines the frequency content of the signal. For type='rbs'/'sine'/, band = [wlow,whigh] which specifies the lower and the upper bound of the passband frequencies(expressed as fractions of Nyquist frequency). Default is c(0,1) For type='prbs', band=[0,B] where B is such that the singal is constant over 1/B (clock period). Default is c(0,1) |
levels |
row vector defining the input level. It is of the form levels=c(minu, maxu) For 'rbs','prbs', 'sine', the generated signal always between minu and maxu. For 'rgs', minu=mean value of signal minus one standard deviation and maxu=mean value of signal plus one standard deviation Default value is levels=c(-1,1) |
Creates a polynomial model with identifiable coefficients
idpoly(A = 1, B = 1, C = 1, D = 1, F1 = 1, ioDelay = 0, Ts = 1, noiseVar = 1, intNoise = F, unit = c("seconds", "minutes", "hours", "days")[1])
idpoly(A = 1, B = 1, C = 1, D = 1, F1 = 1, ioDelay = 0, Ts = 1, noiseVar = 1, intNoise = F, unit = c("seconds", "minutes", "hours", "days")[1])
A |
autoregressive coefficients |
B , F1
|
coefficients of the numerator and denominator respectively of the deterministic model between the input and output |
C , D
|
coefficients of the numerator and denominator respectively of the stochastic model |
ioDelay |
the delay in the input-output channel |
Ts |
sampling interval |
noiseVar |
variance of the white noise source (Default= |
intNoise |
Logical variable indicating presence or absence of integrator
in the noise channel (Default= |
unit |
time unit (Default= |
Discrete-time polynomials are of the form
# define output-error model mod_oe <- idpoly(B=c(0.6,-0.2),F1=c(1,-0.5),ioDelay = 2,Ts=0.1, noiseVar = 0.1) # define box-jenkins model with unit variance B <- c(0.6,-0.2) C <- c(1,-0.3) D <- c(1,1.5,0.7) F1 <- c(1,-0.5) mod_bj <- idpoly(1,B,C,D,F1,ioDelay=1)
# define output-error model mod_oe <- idpoly(B=c(0.6,-0.2),F1=c(1,-0.5),ioDelay = 2,Ts=0.1, noiseVar = 0.1) # define box-jenkins model with unit variance B <- c(0.6,-0.2) C <- c(1,-0.3) D <- c(1,1.5,0.7) F1 <- c(1,-0.5) mod_bj <- idpoly(1,B,C,D,F1,ioDelay=1)
impulseest
is used to estimate impulse response coefficients from
the data
impulseest(x, M = 30, K = NULL, regul = F, lambda = 1)
impulseest(x, M = 30, K = NULL, regul = F, lambda = 1)
x |
an object of class |
M |
Order of the FIR Model (Default: |
K |
Transport delay in the estimated impulse response (Default:NULL) |
regul |
Parameter indicating whether regularization should be
used. (Default: |
lambda |
The value of the regularization parameter. Valid only if
|
The IR Coefficients are estimated using linear least squares. Future Versions will provide support for multivariate data.
Arun K. Tangirala (2015), Principles of System Identification: Theory and Practice, CRC Press, Boca Raton. Sections 17.4.11 and 20.2
uk <- rnorm(1000,1) yk <- filter (uk,c(0.9,-0.4),method="recursive") + rnorm(1000,1) data <- idframe(output=data.frame(yk),input=data.frame(uk)) fit <- impulseest(data) impulseplot(fit)
uk <- rnorm(1000,1) yk <- filter (uk,c(0.9,-0.4),method="recursive") + rnorm(1000,1) data <- idframe(output=data.frame(yk),input=data.frame(uk)) fit <- impulseest(data) impulseplot(fit)
Plots the estimated IR coefficients along with the significance limits at each lag.
impulseplot(model, sd = 2)
impulseplot(model, sd = 2)
model |
an object of class |
sd |
standard deviation of the confidence region (Default: |
Extract output-data or input-data in idframe objects
inputData(x, series)
inputData(x, series)
x |
|
series |
the indices to extract |
Extract or set names of series in input or output
inputNames(x) <- value
inputNames(x) <- value
x |
|
value |
vector of strings |
Estimates an ARX model of the specified order from input-output data using the instrument variable method. If arbitrary instruments are not supplied by the user, the instruments are generated using the arx routine
iv(z, order = c(0, 1, 0), x = NULL)
iv(z, order = c(0, 1, 0), x = NULL)
z |
an idframe object containing the data |
order |
Specification of the orders: the three integer components (na,nb,nk) are the order of polynolnomial A, (order of polynomial B + 1) and the input-output delay |
x |
instrument variable matrix. x must be of the same size as the output
data. (Default: |
An object of class estpoly
containing the following elements:
sys |
an |
fitted.values |
the predicted response |
residuals |
the residuals |
input |
the input data used |
call |
the matched call |
stats |
A list containing the following fields: |
Arun K. Tangirala (2015), Principles of System Identification: Theory and Practice, CRC Press, Boca Raton. Sections 21.7.1, 21.7.2
Lennart Ljung (1999), System Identification: Theory for the User, 2nd Edition, Prentice Hall, New York. Section 7.6
data(arxsim) mod_iv <- iv(arxsim,c(2,1,1))
data(arxsim) mod_iv <- iv(arxsim,c(2,1,1))
Estimates an ARX model of the specified order from input-output data using the instrument variable method. The estimation algorithm is insensitive to the color of the noise term.
iv4(z, order = c(0, 1, 0))
iv4(z, order = c(0, 1, 0))
z |
an idframe object containing the data |
order |
Specification of the orders: the three integer components (na,nb,nk) are the order of polynolnomial A, (order of polynomial B + 1) and the input-output delay |
Estimation is performed in 4 stages. The first stage uses the arx function. The resulting model generates the instruments for a second-stage IV estimate. The residuals obtained from this model are modeled using a sufficently high-order AR model. At the fourth stage, the input-output data is filtered through this AR model and then subjected to the IV function with the same instrument filters as in the second stage.
An object of class estpoly
containing the following elements:
sys |
an |
fitted.values |
the predicted response |
residuals |
the residuals |
input |
the input data used |
call |
the matched call |
stats |
A list containing the following fields: |
Lennart Ljung (1999), System Identification: Theory for the User, 2nd Edition, Prentice Hall, New York. Section 15.3
mod_dgp <- idpoly(A=c(1,-0.5),B=c(0.6,-.2),C=c(1,0.6),ioDelay = 2,noiseVar = 0.1) u <- idinput(400,"prbs") y <- sim(mod_dgp,u,addNoise=TRUE) z <- idframe(y,u) mod_iv4 <- iv4(z,c(1,2,2))
mod_dgp <- idpoly(A=c(1,-0.5),B=c(0.6,-.2),C=c(1,0.6),ioDelay = 2,noiseVar = 0.1) u <- idinput(400,"prbs") y <- sim(mod_dgp,u,addNoise=TRUE) z <- idframe(y,u) mod_iv4 <- iv4(z,c(1,2,2))
Function for replacing missing values with interpolated ones. This is an
extension of the na.approx
function from the zoo
package.
The missing data is indicated using the value NA.
misdata(data)
misdata(data)
data |
an object of class |
data (an idframe object) with missing data replaced.
data(cstr_mis) summary(cstr_mis) # finding out the number of NAs cstr <- misdata(cstr_mis)
data(cstr_mis) summary(cstr_mis) # finding out the number of NAs cstr <- misdata(cstr_mis)
Number of series in input or output in a idframe object
nInputSeries(data)
nInputSeries(data)
data |
|
Fit an output-error model of the specified order given the input-output data
oe(x, order = c(1, 1, 0), init_sys = NULL, options = optimOptions())
oe(x, order = c(1, 1, 0), init_sys = NULL, options = optimOptions())
x |
an object of class |
order |
Specification of the orders: the four integer components (nb,nf,nk) are order of polynomial B + 1, order of the polynomial F, and the input-output delay respectively |
init_sys |
Linear polynomial model that configures the initial parameterization.
Must be an OE model. Overrules the |
options |
Estimation Options, setup using
|
SISO OE models are of the form
The function estimates the coefficients using non-linear least squares
(Levenberg-Marquardt Algorithm)
The data is expected to have no offsets or trends. They can be removed
using the detrend
function.
An object of class estpoly
containing the following elements:
sys |
an |
fitted.values |
the predicted response |
residuals |
the residuals |
input |
the input data used |
call |
the matched call |
stats |
A list containing the following fields: |
options |
Option set used for estimation. If no custom options were configured, this is a set of default options |
termination |
Termination conditions for the iterative
search used for prediction error minimization:
|
Arun K. Tangirala (2015), Principles of System Identification: Theory and Practice, CRC Press, Boca Raton. Sections 14.4.1, 17.5.2, 21.6.3
data(oesim) z <- dataSlice(oesim,end=1533) # training set mod_oe <- oe(z,c(2,1,2)) mod_oe plot(mod_oe) # plot the predicted and actual responses
data(oesim) z <- dataSlice(oesim,end=1533) # training set mod_oe <- oe(z,c(2,1,2)) mod_oe plot(mod_oe) # plot the predicted and actual responses
This dataset contains 2555 samples simulated from the following OE model:
oesim
oesim
an idframe
object with 2555 samples, one input and one
output
The model is simulated with a 2555 samples long full-band PRBS input. The noise variance is set to 0.1
Specify optimization options that are to be passed to the numerical estimation routines
optimOptions(tol = 0.01, maxIter = 20, LMinit = 0.01, LMstep = 2, display = c("off", "on")[1])
optimOptions(tol = 0.01, maxIter = 20, LMinit = 0.01, LMstep = 2, display = c("off", "on")[1])
tol |
Minimum 2-norm of the gradient (Default: |
maxIter |
Maximum number of iterations to be performed |
LMinit |
Starting value of search-direction length
in the Levenberg-Marquardt method (Default: |
LMstep |
Size of the Levenberg-Marquardt step (Default: |
display |
Argument whether to display iteration details or not
(Default: |
Plotting method for objects inherting from class idframe
## S3 method for class 'idframe' plot(x, col = "steelblue", lwd = 1, main = NULL, size = 12, ...)
## S3 method for class 'idframe' plot(x, col = "steelblue", lwd = 1, main = NULL, size = 12, ...)
x |
an |
col |
line color, to be passed to plot.(Default= |
lwd |
line width, in millimeters(Default= |
main |
the plot title. (Default = |
size |
text size (Default = |
... |
additional arguments |
data(cstr) plot(cstr,col="blue")
data(cstr) plot(cstr,col="blue")
Generates the bode plot of the given frequency response data. It uses the ggplot2 plotting engine
## S3 method for class 'idfrd' plot(x, col = "steelblue", lwd = 1, ...)
## S3 method for class 'idfrd' plot(x, col = "steelblue", lwd = 1, ...)
x |
An object of class |
col |
a specification for the line colour (Default : |
lwd |
the line width, a positive number, defaulting to 1 |
... |
additional arguments |
data(frd) plot(frd)
data(frd) plot(frd)
Predicts the output of an identified model (estpoly
) object K steps ahead.
## S3 method for class 'estpoly' predict(object, newdata = NULL, nahead = 1, ...)
## S3 method for class 'estpoly' predict(object, newdata = NULL, nahead = 1, ...)
object |
|
newdata |
optional dataset to be used for predictions. If not supplied, predictions are made on the training set. |
nahead |
number of steps ahead at which to predict (Default:1). For infinite-
step ahead predictions or pure simulation, supply |
... |
other arguments |
Time-series containing the predictions
Arun K. Tangirala (2015), Principles of System Identification: Theory and Practice, CRC Press, Boca Raton. Chapter 18
data(arxsim) mod1 <- oe(arxsim,c(2,1,1)) Yhat <- predict(mod1,arxsim) # 1-step ahead predictions Yhat_2 <- predict(mod1,arxsim,nahead=2) # 2-step ahead predictions Yhat_inf <- predict(mod1,arxsim,nahead=Inf) # Infinite-step ahead predictions
data(arxsim) mod1 <- oe(arxsim,c(2,1,1)) Yhat <- predict(mod1,arxsim) # 1-step ahead predictions Yhat_2 <- predict(mod1,arxsim,nahead=2) # 2-step ahead predictions Yhat_inf <- predict(mod1,arxsim,nahead=Inf) # Infinite-step ahead predictions
Estimates the parameters of a single-output ARX model of the specified order from data using the recursive weighted least-squares algorithm.
rarx(x, order = c(1, 1, 1), lambda = 0.95)
rarx(x, order = c(1, 1, 1), lambda = 0.95)
x |
an object of class |
order |
Specification of the orders: the three integer components (na,nb,nk) are the order of polynolnomial A, (order of polynomial B + 1) and the input-output delay |
lambda |
Forgetting factor(Default= |
A list containing the following objects
Estimated parameters of the model. The
row contains the parameters associated with the
sample. Each row in
theta
has the following format:
theta[i,:]=[a1,a2,...,ana,b1,...bnb]
Predicted value of the output, according to the current model - parameters based on all past data
Arun K. Tangirala (2015), Principles of System Identification: Theory and Practice, CRC Press, Boca Raton. Section 25.1.3
Lennart Ljung (1999), System Identification: Theory for the User, 2nd Edition, Prentice Hall, New York. Section 11.2
Gp1 <- idpoly(c(1,-0.9,0.2),2,ioDelay=2,noiseVar = 0.1) Gp2 <- idpoly(c(1,-1.2,0.35),2.5,ioDelay=2,noiseVar = 0.1) uk = idinput(2044,'prbs',c(0,1/4)); N = length(uk); N1 = round(0.35*N); N2 = round(0.4*N); N3 = N-N1-N2; yk1 <- sim(Gp1,uk[1:N1],addNoise = TRUE) yk2 <- sim(Gp2,uk[N1+1:N2],addNoise = TRUE) yk3 <- sim(Gp1,uk[N1+N2+1:N3],addNoise = TRUE) yk <- c(yk1,yk2,yk3) z <- idframe(yk,uk,1) g(theta,yhat) %=% rarx(z,c(2,1,2))
Gp1 <- idpoly(c(1,-0.9,0.2),2,ioDelay=2,noiseVar = 0.1) Gp2 <- idpoly(c(1,-1.2,0.35),2.5,ioDelay=2,noiseVar = 0.1) uk = idinput(2044,'prbs',c(0,1/4)); N = length(uk); N1 = round(0.35*N); N2 = round(0.4*N); N3 = N-N1-N2; yk1 <- sim(Gp1,uk[1:N1],addNoise = TRUE) yk2 <- sim(Gp2,uk[N1+1:N2],addNoise = TRUE) yk3 <- sim(Gp1,uk[N1+N2+1:N3],addNoise = TRUE) yk <- c(yk1,yk2,yk3) z <- idframe(yk,uk,1) g(theta,yhat) %=% rarx(z,c(2,1,2))
Read the contents of a data.frame/matrix into a idframe
object.
read.idframe(data, ninputs = NULL, Ts = 1, unit = c("seconds", "minutes", "hours", "days")[1])
read.idframe(data, ninputs = NULL, Ts = 1, unit = c("seconds", "minutes", "hours", "days")[1])
data |
a |
ninputs |
the number of input columns. (Default: 0) |
Ts |
sampling interval (Default: 1) |
unit |
Time Unit (Default: "seconds") |
an idframe object
data(cstrData) data <- read.idframe(cstrData,ninputs=1,Ts= 1,unit="minutes")
data(cstrData) data <- read.idframe(cstrData,ninputs=1,Ts= 1,unit="minutes")
Read the contents of an file in table format into a idframe
object.
read.table.idframe(file, header = TRUE, sep = ",", ninputs = 0, Ts = 1, unit = c("seconds", "minutes", "hours", "days")[1], ...)
read.table.idframe(file, header = TRUE, sep = ",", ninputs = 0, Ts = 1, unit = c("seconds", "minutes", "hours", "days")[1], ...)
file |
the path to the file to read |
header |
a logical value indicating whether the first row corresponding to
the first element of the rowIndex vector contains the names of the variables.
(Default: |
sep |
the field separator character. Values on each line of the file are
separated by this character. (Default: |
ninputs |
the number of input columns. (Default: 0) |
Ts |
sampling interval (Default: 1) |
unit |
Time Unit (Default: "seconds") |
... |
additional arguments to be passed to the |
The read.table.idframe
function uses the read.table
function,
provided by the utils package, to read data from a table-formatted file and then calls the
read.idframe
function to read the data into a idframe object
an idframe object
dataMatrix <- data.frame(matrix(rnorm(1000),ncol=5)) colnames(dataMatrix) <- c("u1","u2","y1","y2","y3") write.csv(dataMatrix,file="test.csv",row.names=FALSE) data <- read.table.idframe("test.csv",ninputs=2,unit="minutes")
dataMatrix <- data.frame(matrix(rnorm(1000),ncol=5)) colnames(dataMatrix) <- c("u1","u2","y1","y2","y3") write.csv(dataMatrix,file="test.csv",row.names=FALSE) data <- read.table.idframe("test.csv",ninputs=2,unit="minutes")
Computes the 1-step ahead prediction errors (residuals) for an estimated polynomial model, and plots auto-correlation of the residuals and the cross-correlation of the residuals with the input signals.
residplot(model, newdata = NULL)
residplot(model, newdata = NULL)
model |
estimated polynomial model |
newdata |
an optional dataset on which predictions are to be computed. If not supplied, predictions are computed on the training dataset. |
Simulate the response of a system to a given input
sim(model, input, addNoise = F, innov = NULL, seed = NULL)
sim(model, input, addNoise = F, innov = NULL, seed = NULL)
model |
the linear system to simulate |
input |
a vector/matrix containing the input |
addNoise |
logical variable indicating whether to add noise to the
response model. (Default: |
innov |
an optional times series of innovations. If not supplied (specified
as |
seed |
integer indicating the seed value of the random number generator. Useful for reproducibility purposes. |
The routine is currently built only for SISO systems. Future versions will include support for MIMO systems.
a vector containing the simulated output
# ARX Model u <- idinput(300,"rgs") model <- idpoly(A=c(1,-1.5,0.7),B=c(0.8,-0.25),ioDelay=1, noiseVar=0.1) y <- sim(model,u,addNoise=TRUE)
# ARX Model u <- idinput(300,"rgs") model <- idpoly(A=c(1,-1.5,0.7),B=c(0.8,-0.25),ioDelay=1, noiseVar=0.1) y <- sim(model,u,addNoise=TRUE)
Estimates frequency response and noise spectrum from data with fixed resolution using spectral analysis
spa(x, winsize = NULL, freq = NULL)
spa(x, winsize = NULL, freq = NULL)
x |
an |
winsize |
lag size of the Hanning window (Default: |
freq |
frequency points at which the response is evaluated
(Default: |
an idfrd
object containing the estimated frequency response
and the noise spectrum
Arun K. Tangirala (2015), Principles of System Identification: Theory and Practice, CRC Press, Boca Raton. Sections 16.5 and 20.4
data(arxsim) frf <- spa(arxsim)
data(arxsim) frf <- spa(arxsim)
Plots the step response of a system, given the IR model
step(model)
step(model)
model |
an object of class |
uk <- rnorm(1000,1) yk <- filter (uk,c(0.9,-0.4),method="recursive") + rnorm(1000,1) data <- idframe(output=data.frame(yk),input=data.frame(uk)) fit <- impulseest(data) step(fit)
uk <- rnorm(1000,1) yk <- filter (uk,c(0.9,-0.4),method="recursive") + rnorm(1000,1) data <- idframe(output=data.frame(yk),input=data.frame(uk)) fit <- impulseest(data) step(fit)
time
creates the vector of times at which data was sampled. frequency
returns the number of damples per unit time and deltat
the time-interval
between observationsSampling times of IO data
time
creates the vector of times at which data was sampled. frequency
returns the number of damples per unit time and deltat
the time-interval
between observations
time(x)
time(x)
x |
a idframe object, or a univariate or multivariate time-series, or a vector or matrix |