Processing math: 100%

ARX Time-Series Model

ARX models are a powerful tool for modeling and analyzing the behavior of dynamic systems. They are widely used in a variety of fields, including control engineering, signal processing, and electrical engineering. ARX models are often used in control engineering, where they are used to design controllers for systems such as robots or manufacturing processes. ARX models are based on the concept of linear time-invariant (LTI) systems, which are systems that can be described by linear differential equations. In an ARX model, the input and output of a system are related by a linear equation.

An ARX model is a combination of an autoregressive model (AR) and an exogenous input model (X). It is used to represent the dynamics of a system and is commonly used in control engineering to model and analyze dynamic systems.

Autoregressive Model

An autoregressive model is a type of statistical model that represents a time series as a linear combination of its past values and a stochastic process. It is represented by the following equation:

y(t)=c+a1y(t1)+a2y(t2)+...+apy(tp)+e(t)

where y(t) is the value of the time series at time t, c is a constant term, a1, a2, ..., ap are the autoregressive coefficients, y(t-1), y(t-2), ..., y(t-p) are the past values of the time series, and e(t) is a random error term.

Exogenous Input

An exogenous input model represents a time series as a linear combination of its past values and a set of exogenous (i.e., external) input variables. It is represented by the following equation:

y(t)=c+b1u(t1)+b2u(t2)+...+bqu(tq)+e(t)

where y(t) is the value of the time series at time t, c is a constant term, u(t-1), u(t-2), ..., u(t-q) are the exogenous input variables, and b1, b2, ..., bq are the coefficients that capture the relationship between the input variables and the output. The value of u(t-2) has a zero-order hold from t-2 to t-1 where the new value u(t-1) is measured or actuated.

ARX Model

An autoregressive exogenous input (ARX) model is a combination of an AR model and an X model, and it is represented by the following equation:

y(t)=c+a1y(t1)+a2y(t2)++apy(tp)+b1u(t1)+b2u(t2)++bqu(tq)+e(t)

ARX time series models are a linear representation of a dynamic system in discrete time. Putting a model into ARX form is the basis for many methods in process dynamics and control analysis. Below is the time series model with a single input and single output with k as an index that refers to the time step.

yk+1=nai=1aiyki+1+nbi=1biuki+1

With na=3, nb=2, nu=1, and ny=1 the time series model is:

yk+1=a1yk+a2yk1+a3yk2+b1uk+b2uk1

The time-delay between in the input and output allows the model to take into account the fact that the input and output of a system may not be perfectly synchronized in time. There may also be multiple inputs and multiple outputs such as when na=1, nb=1, nu=2, and ny=2.

y1k+1=a1,1y1k+b1,1u1k+b1,2u2k

y2k+1=a1,2y2k+b2,1u1k+b2,2u2k

Time series models are used for identification and advanced control. It has been in use in the process industries such as chemical plants and oil refineries since the 1980s. Model predictive controllers rely on dynamic models of the process, most often linear empirical models obtained by system identification.

Below is an overview of how to simulate and identify with ARX models using Python Gekko. There is also a Graphical User Interface (GUI) to identify models with the BYU PRISM Seeq SysID Open-Source Package.


Simulate ARX Model

 Inputs: Input (u)
 Outputs: Output (y)
 Description: ARX Time Series Model
 GEKKO Usage: y,u = m.arx(p,y=[],u=[])


Identify ARX Model

 Inputs:
   t = time data
   u = input data for the regression
   y = output data for the regression
   na = number of output coefficients (default=1)
   nb = number of input coefficients (default=1)
   nk = input delay steps (default=0)
   shift (optional) with 'none' (no shift)
                         'init' (initial pt)
                         'mean' (mean center)
                         'calc' (calculate c)
   scale (optional)
   pred (option) 'model' or 'meas'
   objf = Objective scaling factor
   diaglevel = diagnostic level (0-6)
 Outputs:
   y = predicted values
   p = ARX coefficients for m.arx()
   K = gain matrix
 Description: System Identification
 GEKKO Usage: y,p,K = sysid(t,u,y,na,nb,shift=0,pred='model',objf=1)


Step Test ARX Model


Activity

Collect data from a TCLab device

  with tclab.TCLab() as lab:

or from the digital twin simulator.

  with tclab.TCLabModel() as lab:

Repeat the system identification with data from the simulated or physical device. Review Pandas Time-Series for help with collecting data into a Pandas DataFrame and exporting to a data file. Add step changes for Q2 that are offset from the Q1 steps.

import tclab
import time
import pandas as pd
import matplotlib.pyplot as plt

x = {'Time':[],'Q1':[],'Q2':[],'T1':[],'T2':[]}
df = pd.DataFrame(x)

Q1 = 0; Q2 = 0
with tclab.TCLabModel() as lab:
    for i in range(361):
        Q1 = 70 if i==5 else Q1
        Q1 = 25 if i==105 else Q1
        Q1 = 100 if i==205 else Q1
        Q1 = 0 if i>=255 else Q1
        lab.Q1(Q1); lab.Q2(Q2);
        df.loc[i] = [i,Q1,Q2,lab.T1,lab.T2]
        if i%10==0:
            print(f'Q1:{Q1:5.2f} Q2:{Q2:5.2f} T1:{lab.T1:5.2f} T2:{lab.T2:5.2f}')
        time.sleep(1)

df.set_index('Time',inplace=True)

print(df.describe())
df.to_csv('tclab.csv')

df.plot(subplots=True)
plt.show()


✅ Knowledge Check

1. Which of the following statements accurately describes the ARX model?

A. The ARX model is an advanced type of autoregressive model that only depends on the past values of the time series and does not take into account any external inputs.
B. The ARX model represents a time series using a linear combination of its past values, external input variables, and a random error term.
C. ARX models are non-linear and represent a dynamic system in continuous time.
D. An ARX model only accounts for the past values of external input variables and does not consider past values of the time series.

2. In the ARX model, what does the 'X' in ARX stand for?

A. Exponential.
B. Exclusion.
C. Exogenous Input.
D. External Regression.
Streaming Chatbot
💬