NFoursID is a Python library that implements the N4SID algorithm for subspace identification, along with Kalman filtering and state-space models. State-space models are versatile tools for representing multi-dimensional time series, encompassing models like ARMAX. The current version is 1.0.2. The project appears active, with its latest release (1.0.2) showing an unusual future publication date of July 24, 2025, on PyPI.
pip install nfoursidVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates the core workflow of `nfoursid`: defining a true state-space model, simulating data, using the `NFourSID` class for system identification to recover a model from data, and then applying a `Kalman` filter for state estimation.
Experiment with `num_block_rows` values, typically starting with values related to expected system order and data length. Refer to subspace identification literature (e.g., the cited references [1] for guidance). The `plot_eigenvalues` method can help in assessing the choice.
Always perform `subspace_identification()` first, then analyze `nfoursid_estimator.plot_eigenvalues()` to visually confirm the appropriate `rank` before calling `system_identification(rank=...)`.
Familiarize yourself with the theoretical background of N4SID and Kalman filters (e.g., through the references provided in the documentation [1, 2]). Carefully review the example notebooks and documentation to understand how to correctly define models and interpret outputs.
pip install nfoursid
Ensure that the `A`, `B`, `C`, and `D` matrices adhere to the expected dimensions: `A` (dx, dx), `B` (dx, du), `C` (dy, dx), `D` (dy, du), where dx is the internal state dimension, du is the input dimension, and dy is the output dimension. For example, if `A` is `(dx, dx)`, then `B` must have `dx` rows, and `C` must have `dx` columns.
Call the `subspace_identification()` method on your `NFourSID` object before attempting to access its results or dependent methods. Example: `nfoursid_instance.subspace_identification()` then `nfoursid_instance.plot_eigenvalues(ax)`.