Set lags¶
Example created by Wilson Rocha Lacerda Junior
Different ways to set the maximum lag for input and output
In [ ]:
Copied!
pip install sysidentpy
pip install sysidentpy
In [1]:
Copied!
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sysidentpy.model_structure_selection import FROLS
from sysidentpy.basis_function._basis_function import Polynomial
from sysidentpy.metrics import root_relative_squared_error
from sysidentpy.utils.generate_data import get_siso_data
from sysidentpy.utils.display_results import results
from sysidentpy.utils.plotting import plot_residues_correlation, plot_results
from sysidentpy.residues.residues_correlation import compute_residues_autocorrelation, compute_cross_correlation
import numpy as np import pandas as pd import matplotlib.pyplot as plt from sysidentpy.model_structure_selection import FROLS from sysidentpy.basis_function._basis_function import Polynomial from sysidentpy.metrics import root_relative_squared_error from sysidentpy.utils.generate_data import get_siso_data from sysidentpy.utils.display_results import results from sysidentpy.utils.plotting import plot_residues_correlation, plot_results from sysidentpy.residues.residues_correlation import compute_residues_autocorrelation, compute_cross_correlation
Setting lags using a range of values¶
If you pass int values for ylag and xlag, the lags are defined as a range from 1-ylag and 1-xlag.
For example: if ylag=4 then the candidate regressors are $y_{k-1}, y_{k-2}, y_{k-3}, y_{k-4}$
In [3]:
Copied!
basis_function = Polynomial(degree=1)
model = FROLS(
order_selection=True,
extended_least_squares=False,
ylag=4, xlag=4,
info_criteria='aic',
estimator='least_squares',
basis_function=basis_function
)
basis_function = Polynomial(degree=1) model = FROLS( order_selection=True, extended_least_squares=False, ylag=4, xlag=4, info_criteria='aic', estimator='least_squares', basis_function=basis_function )
Setting specific lags using lists¶
If you pass the ylag and xlag as a list, only the lags related to values in the list will be created.
In [4]:
Copied!
model = FROLS(
order_selection=True,
extended_least_squares=False,
ylag=[1, 4], xlag=[1, 4],
info_criteria='aic',
estimator='least_squares',
basis_function=basis_function
)
model = FROLS( order_selection=True, extended_least_squares=False, ylag=[1, 4], xlag=[1, 4], info_criteria='aic', estimator='least_squares', basis_function=basis_function )