nfoursid¶
- class nfoursid.nfoursid.NFourSID(dataframe: pandas.core.frame.DataFrame, output_columns: List[str], input_columns: Optional[List[str]] = None, num_block_rows: int = 2)¶
Bases:
object
Perform subspace identification using N4SID [1]. The state-space model under consideration, is:
Data is provided as a dataframe
dataframe
where every row is a measurement. The output columns are given byoutput_columns
. The input columns are given byinput_columns
.The number of block rows to use in the block Hankel matrices is given by
num_block_rows
. Ifnum_block_rows
is chosen to be too big, the computational complexity will increase. Ifnum_block_rows
is chosen to be too small, the order of the system might not be possible to determine in the eigenvalue diagram. Moreover, ifnum_block_rows
is chosen to be too small, the assumptions of [2] might not hold.[1] Van Overschee, Peter, and Bart De Moor. “N4SID: Subspace algorithms for the identification of combined deterministic-stochastic systems.” Automatica 30.1 (1994): 75-93.
- plot_eigenvalues(ax: matplotlib.pyplot.axes)¶
Plot the eigenvalues of the matrix, so that the order of the state-space model can be determined. Since the matrix should have been calculated, this function can only be used after performing
self.subspace_identification
.
- subspace_identification()¶
Perform subspace identification based on the PO-MOESP method. The instrumental variable contains past outputs and past inputs. The implementation uses a QR-decomposition for numerical efficiency and is based on page 329 of [1].
A key result of this function is the eigenvalue decomposition of the matrix
self.R32_decomposition
, based on which the order of the system should be determined.[1] Verhaegen, Michel, and Vincent Verdult. Filtering and system identification: a least squares approach. Cambridge university press, 2007.
- system_identification(rank: Optional[int] = None) Tuple[nfoursid.state_space.StateSpace, numpy.ndarray] ¶
Identify the system matrices of the state-space model given in the description of
NFourSID
. Moreover, the covariance of the measurement-noise and process-noise will be estimated. The order of the returned state-space model has rankrank
by reducing the eigenvalue decomposition. The implementation is based on page 333 of [1].The return value consists of a tuple containing
The identified state-space model containing the estimated matrices ,
and an estimate of the covariance matrix of the measurement-noise and process-noise . The structure of the covariance matrix corresponds to the parameter
noise_covariance
ofsubspace_identification.kalman.Kalman
. See its documentation for more information.
self.system_identification
needs the QR-decomposition result of subspace identificationself.R32
, and therefore can only be ran afterself.subspace_identification
.[1] Verhaegen, Michel, and Vincent Verdult. Filtering and system identification: a least squares approach. Cambridge university press, 2007.