Class IcaLingD
Lacerda, G., Spirtes, P. L., Ramsey, J., & Hoyer, P. O. (2012). Discovering cyclic causal models by independent components analysis. arXiv preprint arXiv:1206.3273.
ICA-LING-D is a method for estimating a possible cyclic linear models graph from a dataset. It is based on the assumption that the data are generated by a linear model with non-Gaussian noise. The method is based on the following assumptions: (1) The data are generated by a linear model with non-Gaussian noise. (2) The noise is independent across variables. (3) The noises for all but possibly one variable are non-Gaussian. (4) There is no unobserved confounding.
Under these assumptions, the method estimates matrices W such that WX = e, where X is the data matrix, e is a matrix of noise, and W is a matrix of coefficients. The matrix W is then used to estimate a matrix B Hat, where B Hat is the matrix of coefficients in the linear model that generated the data. The graph is then estimated by finding edges in B Hat.
We use the N Rooks algorithm to find alternative diagonals for permutations of the W matrix. The parameter that N Rooks requires is a threshold for entries in W to be sent to zero; the implied permutations is the permutations that permutes rows so that these combinations lie along their respective diagonals in W, which are then scaled, and the separate satisfactory B Hat matrices reported. These B Hat matrices are then thresholded as well, using a separate threshold for B matrices. Unlike ICA-LiNGAM, an acyclic model is not assumed.
If the verbose flag is set to true ('Yes'), all stable and unstable models are printed to the console with both their B Hat matrices and graphs. If a stable model is found, it is returned; otherwise, an empty graph is returned.
This class does not use knowledge of forbidden and required edges.
- Version:
- $Id: $Id
- Author:
- peterspirtes, gustavolacerda, patrickhoyer, josephramsey
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Matrix
Estimates the W matrix using FastICA.static Matrix
estimateW
(DataSet data, int fastIcaMaxIter, double fastIcaTolerance, double fastIcaA, boolean verbose) Estimates the W matrix using FastICA.Fits a LiNG-D model to the given dataset using a default method for estimating W.static Matrix
Returns the BHat matrix, permuted to the variable order of the original data and scaled so that the diagonal consists only of 1's.Performs the LiNG-D algorithm given a W matrix, which needs to be discovered elsewhere.static boolean
Whether the BHat matrix represents a stable model.static @NotNull Graph
Returns a graph given a coefficient matrix and a list of variables.static PermutationMatrixPair
Finds a column permutation of the W matrix that maximizes the sum of 1 / |Wii| for diagonal elements Wii in W.static Matrix
Scales the given matrix M by diving each entry (i, j) by M(j, j)void
setBThreshold
(double bThreshold) Sets the threshold value for the B matrix.void
setWThreshold
(double wThreshold) Sets the threshold value for the W matrix.static Matrix
Thresholds the given matrix, sending any small entries in absolute value to zero.
-
Constructor Details
-
IcaLingD
public IcaLingD()Constructor.
-
-
Method Details
-
estimateW
public static Matrix estimateW(DataSet data, int fastIcaMaxIter, double fastIcaTolerance, double fastIcaA) Estimates the W matrix using FastICA. Assumes the "parallel" option, using the "exp" function.- Parameters:
data
- The dataset to estimate W for.fastIcaMaxIter
- Maximum number of iterations of ICA.fastIcaTolerance
- Tolerance for ICA.fastIcaA
- Alpha for ICA.- Returns:
- The estimated W matrix.
-
estimateW
public static Matrix estimateW(DataSet data, int fastIcaMaxIter, double fastIcaTolerance, double fastIcaA, boolean verbose) Estimates the W matrix using FastICA. Assumes the "parallel" option, using the "exp" function.- Parameters:
data
- The dataset to estimate W for.fastIcaMaxIter
- Maximum number of iterations of ICA.fastIcaTolerance
- Tolerance for ICA.fastIcaA
- Alpha for ICA.verbose
- Whether to print the Anderson-Darling test results.- Returns:
- The estimated W matrix.
-
makeGraph
Returns a graph given a coefficient matrix and a list of variables. It is assumed that any non-zero entry in B corresponds to a directed edges, so that Bij != 0 implies that j->i in the graph.- Parameters:
B
- The coefficient matrix.variables
- The list of variables.- Returns:
- The built graph.
-
maximizeDiagonal
Finds a column permutation of the W matrix that maximizes the sum of 1 / |Wii| for diagonal elements Wii in W.- Parameters:
W
- The W matrix, WX = e.- Returns:
- The model with the strongest diagonal, as a permutation matrix pair.
- See Also:
-
isStable
Whether the BHat matrix represents a stable model. The eigenvalues are checked to make sure they are all less than 1 in modulus.- Parameters:
bHat
- The bHat matrix.- Returns:
- True iff the model is stable.
-
scale
-
threshold
Thresholds the given matrix, sending any small entries in absolute value to zero.- Parameters:
M
- The matrix to threshold.threshold
- The value such that M(i, j) is set to zero if |M(i, j)| < threshold. Should be non-negative.- Returns:
- The thresholded matrix.
-
getScaledBHat
Returns the BHat matrix, permuted to the variable order of the original data and scaled so that the diagonal consists only of 1's.- Parameters:
pair
- The (column permutation, thresholded, column permuted W matrix) pair.- Returns:
- The estimated B Hat matrix for this pair.
- See Also:
-
fit
-
getScaledBHats
Performs the LiNG-D algorithm given a W matrix, which needs to be discovered elsewhere. The 'local algorithm' is assumed--in fact, the W matrix is simply thresholded without bootstrapping.- Parameters:
W
- The W matrix to be used.- Returns:
- A list of estimated B Hat matrices generated by LiNG-D.
-
setBThreshold
public void setBThreshold(double bThreshold) Sets the threshold value for the B matrix.- Parameters:
bThreshold
- The threshold value for the bThreshold field. Must be non-negative.- Throws:
IllegalArgumentException
- If bThreshold is a negative number.
-
setWThreshold
public void setWThreshold(double wThreshold) Sets the threshold value for the W matrix.- Parameters:
wThreshold
- The threshold value for the wThreshold field. Must be non-negative.- Throws:
IllegalArgumentException
- If wThreshold is a negative number.
-