Package edu.cmu.tetrad.data
Class CovarianceMatrixOnTheFly
java.lang.Object
edu.cmu.tetrad.data.CovarianceMatrixOnTheFly
- All Implemented Interfaces:
DataModel,ICovarianceMatrix,KnowledgeTransferable,VariableSource,TetradSerializable,Serializable
Stores a covariance matrix together with variable names and sample size, intended as a representation of a data set.
When constructed from a continuous data set, the matrix is not checked for positive definiteness; however, when a
covariance matrix is supplied, its positive definiteness is always checked. If the sample size is less than the
number of variables, the positive definiteness is "spot-checked"--that is, checked for various submatrices.
- Author:
- josephramsey
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCovarianceMatrixOnTheFly(DataSet dataSet) Constructs a new covariance matrix from the given data set.CovarianceMatrixOnTheFly(DataSet dataSet, boolean verbose) -
Method Summary
Modifier and TypeMethodDescriptionfinal voidcopy()static voidfinal intfinal Knowledgefinal Matrixfinal MatrixgetMatrix(int[] rows) final StringgetName()Gets the name of the covariance matrix.final intThe size of the sample used to calculated this covariance matrix.getSelection(int[] rows, int[] cols) getSelection(int[] rows, int[] cols, int[] dataRows) final intgetSize()final ICovarianceMatrixgetSubmatrix(int[] indices) final ICovarianceMatrixgetSubmatrix(int[] indices, int[] dataRows) final CovarianceMatrixOnTheFlygetSubmatrix(String[] submatrixVarNames) final ICovarianceMatrixgetSubmatrix(List<String> submatrixVarNames) final doublegetValue(int i, int j) final doublegetValue(int i, int j, int[] rows) getVariable(String name) final StringgetVariableName(int index) Returns the variable names associated with this getVariableNames.Returns the list of variables associated with this object.booleanbooleanbooleanisMixed()final booleanisSelected(Node variable) booleanvoidremoveVariables(List<String> remaining) final voidstatic ICovarianceMatrixGenerates a simple exemplar of this class to test serialization.final voidsetKnowledge(Knowledge knowledge) Associates knowledge with this data.voidfinal voidSets the name of the covariance matrix.final voidsetSampleSize(int sampleSize) voidsetValue(int i, int j, double v) voidsetVariables(List<Node> variables) voidsetVerbose(boolean verbose) final StringtoString()Prints out the matrix
-
Constructor Details
-
CovarianceMatrixOnTheFly
Constructs a new covariance matrix from the given data set. If dataSet is a BoxDataSet with a VerticalDoubleDataBox, the data will be mean-centered by the constructor; is non-mean-centered version of the data is needed, the data should be copied before being send into the constructor.- Throws:
IllegalArgumentException- if this is not a continuous data set.
-
CovarianceMatrixOnTheFly
-
-
Method Details
-
demean
-
serializableInstance
Generates a simple exemplar of this class to test serialization. -
getVariables
Description copied from interface:VariableSourceReturns the list of variables associated with this object.- Specified by:
getVariablesin interfaceICovarianceMatrix- Specified by:
getVariablesin interfaceVariableSource- Returns:
- the list of variables (unmodifiable).
-
setVariables
- Specified by:
setVariablesin interfaceICovarianceMatrix
-
getVariableNames
Description copied from interface:VariableSourceReturns the variable names associated with this getVariableNames.- Specified by:
getVariableNamesin interfaceICovarianceMatrix- Specified by:
getVariableNamesin interfaceVariableSource- Returns:
- the variable names, in order.
-
getVariableName
- Specified by:
getVariableNamein interfaceICovarianceMatrix- Returns:
- the variable name at the given index.
-
getDimension
public final int getDimension()- Specified by:
getDimensionin interfaceICovarianceMatrix- Returns:
- the dimension of the covariance matrix.
-
getSampleSize
public final int getSampleSize()The size of the sample used to calculated this covariance matrix.- Specified by:
getSampleSizein interfaceICovarianceMatrix- Returns:
- The sample size (> 0).
-
setSampleSize
public final void setSampleSize(int sampleSize) - Specified by:
setSampleSizein interfaceICovarianceMatrix
-
getName
Gets the name of the covariance matrix.- Specified by:
getNamein interfaceDataModel- Specified by:
getNamein interfaceICovarianceMatrix- Returns:
- the name of the data model (may be null).
-
setName
Sets the name of the covariance matrix.- Specified by:
setNamein interfaceDataModel- Specified by:
setNamein interfaceICovarianceMatrix
-
getKnowledge
- Specified by:
getKnowledgein interfaceICovarianceMatrix- Specified by:
getKnowledgein interfaceKnowledgeTransferable- Returns:
- the knowledge associated with this data.
-
setKnowledge
Associates knowledge with this data.- Specified by:
setKnowledgein interfaceICovarianceMatrix- Specified by:
setKnowledgein interfaceKnowledgeTransferable
-
getSubmatrix
- Specified by:
getSubmatrixin interfaceICovarianceMatrix- Returns:
- a submatrix of the covariance matrix with variables in the given order.
-
getSubmatrix
-
getSubmatrix
- Specified by:
getSubmatrixin interfaceICovarianceMatrix
-
getSubmatrix
- Specified by:
getSubmatrixin interfaceICovarianceMatrix- Returns:
- a submatrix of this matrix, with variables in the given order.
-
getValue
public final double getValue(int i, int j) - Specified by:
getValuein interfaceICovarianceMatrix- Returns:
- the value of element (i,j) in the matrix
-
getValue
public final double getValue(int i, int j, int[] rows) -
getSize
public final int getSize()- Specified by:
getSizein interfaceICovarianceMatrix- Returns:
- the size of the square matrix.
-
getMatrix
- Specified by:
getMatrixin interfaceICovarianceMatrix- Returns:
- a copy of the covariance matrix.
-
setMatrix
- Specified by:
setMatrixin interfaceICovarianceMatrix
-
getMatrix
-
select
- Specified by:
selectin interfaceICovarianceMatrix
-
clearSelection
public final void clearSelection()- Specified by:
clearSelectionin interfaceICovarianceMatrix
-
isSelected
- Specified by:
isSelectedin interfaceICovarianceMatrix
-
getSelectedVariableNames
- Specified by:
getSelectedVariableNamesin interfaceICovarianceMatrix
-
toString
Prints out the matrix -
isContinuous
public boolean isContinuous()- Specified by:
isContinuousin interfaceDataModel
-
isDiscrete
public boolean isDiscrete()- Specified by:
isDiscretein interfaceDataModel
-
isMixed
public boolean isMixed() -
isVerbose
public boolean isVerbose() -
setVerbose
public void setVerbose(boolean verbose) -
getSelection
- Specified by:
getSelectionin interfaceICovarianceMatrix
-
getSelection
-
getVariable
- Specified by:
getVariablein interfaceDataModel- Specified by:
getVariablein interfaceICovarianceMatrix
-
copy
-
setValue
public void setValue(int i, int j, double v) - Specified by:
setValuein interfaceICovarianceMatrix
-
removeVariables
- Specified by:
removeVariablesin interfaceICovarianceMatrix
-