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:

\begin{cases}
    x_{k+1} &= A x_k + B u_k + K e_k \\
    y_k &= C x_k + D u_k + e_k
\end{cases}

Data is provided as a dataframe dataframe where every row is a measurement. The output columns are given by output_columns. The input columns are given by input_columns.

The number of block rows to use in the block Hankel matrices is given by num_block_rows. If num_block_rows is chosen to be too big, the computational complexity will increase. If num_block_rows is chosen to be too small, the order of the system might not be possible to determine in the eigenvalue diagram. Moreover, if num_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 R_{32} matrix, so that the order of the state-space model can be determined. Since the R_{32} 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 R_{32} 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 rank rank 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 (A, B, C, D),

  • and an estimate of the covariance matrix of the measurement-noise w and process-noise v. The structure of the covariance matrix corresponds to the parameter noise_covariance of subspace_identification.kalman.Kalman. See its documentation for more information.

self.system_identification needs the QR-decomposition result of subspace identification self.R32, and therefore can only be ran after self.subspace_identification.

[1] Verhaegen, Michel, and Vincent Verdult. Filtering and system identification: a least squares approach. Cambridge university press, 2007.