{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Setting specific lags\n", "\n", "Example created by Wilson Rocha Lacerda Junior" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Different ways to set the maximum lag for input and output" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "pip install sysidentpy" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import pandas as pd\n", "import matplotlib.pyplot as plt\n", "from sysidentpy.model_structure_selection import FROLS\n", "from sysidentpy.basis_function._basis_function import Polynomial\n", "from sysidentpy.metrics import root_relative_squared_error\n", "from sysidentpy.utils.generate_data import get_siso_data\n", "from sysidentpy.utils.display_results import results\n", "from sysidentpy.utils.plotting import plot_residues_correlation, plot_results\n", "from sysidentpy.residues.residues_correlation import compute_residues_autocorrelation, compute_cross_correlation\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Setting lags using a range of values\n", "\n", "If you pass int values for *ylag* and *xlag*, the lags are defined as a range from 1-*ylag* and 1-*xlag*. \n", "\n", "For example: if *ylag=4* then the candidate regressors are $y_{k-1}, y_{k-2}, y_{k-3}, y_{k-4}$" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "scrolled": false }, "outputs": [], "source": [ "basis_function = Polynomial(degree=1)\n", "\n", "model = FROLS(\n", " order_selection=True,\n", " extended_least_squares=False,\n", " ylag=4, xlag=4,\n", " info_criteria='aic',\n", " estimator='least_squares',\n", " basis_function=basis_function\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Setting specific lags using lists\n", "\n", "If you pass the *ylag* and *xlag* as a list, only the lags related to values in the list will be created." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "model = FROLS(\n", " order_selection=True,\n", " extended_least_squares=False,\n", " ylag=[1, 4], xlag=[1, 4],\n", " info_criteria='aic',\n", " estimator='least_squares',\n", " basis_function=basis_function\n", ")" ] } ], "metadata": { "interpreter": { "hash": "0e65fe37feb8ff9f7778552a28949e943d61f86c936833305e2c18cda5b438ac" }, "kernelspec": { "display_name": "Python 3.8.11 64-bit ('rd': conda)", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.11" } }, "nbformat": 4, "nbformat_minor": 4 }