Package edu.cmu.tetrad.search
Class Lofs
java.lang.Object
edu.cmu.tetrad.search.Lofs
Implements a number of methods which take a fixed graph as input and use linear, non-Gaussian methods to orient the
edges in the graph. where the acronym stands for linear, non-Gaussian Orientation with a Fixed graph Structure
(LOFS). The options for different types of scores are given in the enum Lofs.Score. The options for rules to use to
do the orientations are given in the enum, Lofs.Rule. Most of these are taken from the literature and can be googled,
though we should certainly give this reference for several of them, to which we are indebted:
Hyvärinen, A., & Smith, S. M. (2013). Pairwise likelihood ratios for estimation of non-Gaussian structural equation models. The Journal of Machine Learning Research, 14(1), 111-152.
This class is configured to respect knowledge of forbidden and required edges, including knowledge of temporal tiers.
- Version:
- $Id: $Id
- Author:
- josephramsey
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Give a list of options for rules for doing the non-Gaussian orientations.static enum
Gives a list of options for non-Gaussian transformations that can be used for some scores. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondouble
getPValue
(double fisherZ) Calculates the p-value using Fisher's exact test.double
kernel
(double z) Calculates the kernel value for a given input.double
kernel1
(double z) Computes the value of the kernel function 1 for a given input.double
kernel2
(double z) Calculates the value of the kernel2 function for the given input.double
kernel3
(double z) This method calculates the value of the kernel function, kernel3, for a given input.double
kernel4
(double z) Calculates the result of kernel4 function.double
kernel5
(double z) Calculates the value of the kernel function, kernel5, for the given input.double
kernel6
(double z) Calculates the value of the kernel function 6 given a parameter z.double
kernel7
(double z) Computes the value of the kernel7 function for the given value.double
kernel8
(double z) Calculates the value of the kernel8 function for the given input.orient()
Orients the graph and returns the oriented graph.double
Calculates the score for a given row in a matrix using the specified parameters.void
setAlpha
(double alpha) Sets the alpha to use, where applicable.void
setEpsilon
(double epsilon) Sets the epsilon value.void
setKnowledge
(Knowledge knowledge) Sets the knowledge for the object.void
setOrientStrongerDirection
(boolean orientStrongerDirection) Sets whether orientation should be done in the stronger direction, where applicable.void
setR2Orient2Cycles
(boolean r2Orient2Cycles) Sets for R2 whether cycles should be oriented.void
Sets the rule to use to do the orientation.void
setScore
(Lofs.Score score) Sets the (LoFS) score to use.void
setSelfLoopStrength
(double selfLoopStrength) Sets the self-loop strength, if applicable.
-
Constructor Details
-
Lofs
Constructor.- Parameters:
graph
- The graph to be oriented. Orientations for the graph will be overwritten.dataSets
- A list of datasets to use to do the orientation. This may be just one dataset. If more than one dataset are given, the data will be concatenated (pooled).- Throws:
IllegalArgumentException
- if any.
-
-
Method Details
-
orient
Orients the graph and returns the oriented graph.- Returns:
- The oriented graph.
-
setRule
Sets the rule to use to do the orientation.- Parameters:
rule
- This rule.- See Also:
-
setScore
Sets the (LoFS) score to use.- Parameters:
score
- This score.- See Also:
-
setSelfLoopStrength
public void setSelfLoopStrength(double selfLoopStrength) Sets the self-loop strength, if applicable.- Parameters:
selfLoopStrength
- This strength.
-
setAlpha
public void setAlpha(double alpha) Sets the alpha to use, where applicable.- Parameters:
alpha
- This alpha.
-
setOrientStrongerDirection
public void setOrientStrongerDirection(boolean orientStrongerDirection) Sets whether orientation should be done in the stronger direction, where applicable.- Parameters:
orientStrongerDirection
- True, if so.
-
setR2Orient2Cycles
public void setR2Orient2Cycles(boolean r2Orient2Cycles) Sets for R2 whether cycles should be oriented.- Parameters:
r2Orient2Cycles
- True, if so.
-
scoreRow
public double scoreRow(int rowIndex, Matrix data, List<List<Integer>> rows, List<List<Double>> parameters) Calculates the score for a given row in a matrix using the specified parameters.- Parameters:
rowIndex
- the index of the row to scoredata
- the matrix containing the datarows
- the list of rows containing the column indices to scoreparameters
- the list of parameters for each column index in the rows- Returns:
- the score of the row
-
setEpsilon
public void setEpsilon(double epsilon) Sets the epsilon value.- Parameters:
epsilon
- the new value of epsilon
-
setKnowledge
Sets the knowledge for the object.- Parameters:
knowledge
- the knowledge to set.- Throws:
NullPointerException
- if the knowledge is null.
-
getPValue
public double getPValue(double fisherZ) Calculates the p-value using Fisher's exact test. The p-value is the probability of observing a test statistic as extreme as the observed value under the null hypothesis. It is used to determine the statistical significance of the observed value.- Parameters:
fisherZ
- the Fisher's Z value- Returns:
- the p-value
-
kernel
public double kernel(double z) Calculates the kernel value for a given input.- Parameters:
z
- the input value to calculate the kernel value for.- Returns:
- the calculated kernel value for the given input.
-
kernel1
public double kernel1(double z) Computes the value of the kernel function 1 for a given input. (Gaussian.)- Parameters:
z
- the input value for which the kernel function is computed- Returns:
- the value of the kernel function computed for the given input value
-
kernel2
public double kernel2(double z) Calculates the value of the kernel2 function for the given input. (Uniform.)- Parameters:
z
- the input value to calculate the kernel2 for- Returns:
- the calculated value of kernel2
-
kernel3
public double kernel3(double z) This method calculates the value of the kernel function, kernel3, for a given input. (Triangular.)- Parameters:
z
- the input value for which the kernel function is to be calculated- Returns:
- the calculated value of the kernel function
-
kernel4
public double kernel4(double z) Calculates the result of kernel4 function. (Epanechnikov)- Parameters:
z
- a double value representing the input parameter- Returns:
- the result of kernel4 function
-
kernel5
public double kernel5(double z) Calculates the value of the kernel function, kernel5, for the given input. (Quartic)The kernel function calculates the value based on the input value z. If the absolute value of z is greater than 1, the function returns 0. Otherwise, it returns the result of the calculation: (15 / 16)
- Parameters:
z
- the input parameter- Returns:
- the result of kernel5 function
-
kernel6
public double kernel6(double z) Calculates the value of the kernel function 6 given a parameter z. (Triweight)- Parameters:
z
- the input parameter- Returns:
- the calculated value of the kernel function 6
-
kernel7
public double kernel7(double z) Computes the value of the kernel7 function for the given value. (Tricube)- Parameters:
z
- the input value- Returns:
- the computed value of the kernel7 function
-
kernel8
public double kernel8(double z) Calculates the value of the kernel8 function for the given input. (Cosine)- Parameters:
z
- the input value for the kernel8 function- Returns:
- the calculated value of the kernel8 function
-