MultispatiPCA
- class multispaeti.MultispatiPCA(n_components=None, *, connectivity)
MULTISPATI-PCA
In contrast to Principal component analysis (PCA), MULTISPATI-PCA does not optimize the variance explained of each component but rather the product of the variance and Moran’s I. This can lead to negative eigenvalues i.e. in the case of negative auto-correlation.
The problem is solved by diagonalizing the symmetric matrix \(H=1/(2n)*X^t(W+W^t)X\) where X is matrix of n observations \(\times\) d features, and W is a matrix of the connectivity between observations.
- Parameters:
n_components (int or tuple[int, int], optional) – Number of components to keep. If None, will keep all components (only supported for non-sparse X). If an int, it will keep the top n_components. If a tuple, it will keep the top and bottom n_components respectively.
connectivity (sparray or spmatrix) – Matrix of row-wise neighbor definitions i.e. cij is the connectivity of i \(\to\) j. The matrix does not have to be symmetric. It can be a binary adjacency matrix or a matrix of connectivities in which case cij should be larger if i and j are close. A distance matrix should be transformed to connectivities by e.g. calculating \(1-d/d_{max}\) beforehand.
- Raises:
ValueError – If connectivity is not a square matrix.
ZeroDivisionError – If one of the observations has no neighbors.
- variance_
The estimated variance part of the eigenvalues. Array of shape (n_components,).
- Type:
- moransI_
The estimated Moran’s I part of the eigenvalues. Array of shape (n_components,).
- Type:
- eigenvalues_
The eigenvalues corresponding to each of the selected components. Array of shape (n_components,).
- Type:
References
Methods
Fit MULTISPATI-PCA projection.
Fit the MULTISPATI-PCA projection and transform the data.
Calculate the minimum and maximum bound for Moran's I given the connectivity and the expected value given the #observations.
Transform the data using fitted MULTISPATI-PCA projection.
Transform the data using fitted MULTISPATI-PCA projection and calculate the spatial lag.