Libraries.Compute.Statistics.Tests.CorrelateGroups Documentation
This class implements a Pearson Correlation Coefficient. For more information, see the wikipedia page: https://en.wikipedia.org/wiki/Pearson_correlation_coefficient There are two ways to use this class. First, if we want to correlate two groups, the class will automatically detect this case and we can call actions like GetCorrelation, which will return that case. If we want to compare more than two groups, these actions will throw errors and we will be requested to either iterate through the results or two call the corresponding GetCorrelation(leftIndex, rightIndex) actions.
Example Code
use Libraries.Compute.Statistics.DataFrame
use Libraries.Compute.Statistics.Tests.CorrelateGroups
DataFrame frame
frame:Load("Data/Data.csv")
CorrelateGroups correlate
correlate:Add(0)
correlate:Add(1)
frame:Calculate(correlate)
output correlate:GetCorrelation()
Inherits from: Libraries.Compute.Statistics.DataFrameCalculation, Libraries.Compute.Statistics.Tests.StatisticalTest, Libraries.Compute.Statistics.Inputs.ColumnInput, Libraries.Language.Object
Summary
Actions Summary Table
Actions | Description |
---|---|
AddColumn(integer column) | This action adds a value to the end of the input. |
Calculate(Libraries.Compute.Statistics.DataFrame frame) | This calculates a hash value for the results table. |
Compare(Libraries.Language.Object object) | This action compares two object hash codes and returns an integer. |
EmptyColumns() | This action empty's the list, clearing out all of the items contained within it. |
Equals(Libraries.Language.Object object) | This action determines if two objects are equal based on their hash code values. |
GetColumn(integer index) | This action gets the item at a given location in an array. |
GetColumnIterator() | This action gets an iterator for the object and returns that iterator. |
GetColumnSize() | This action gets the size of the array. |
GetCorrelateGroupsResult(integer leftIndex, integer rightIndex) | This returns a correlation between two particular columns. |
GetCorrelation() | Obtains the raw correlation, typically named "r" in statistics. |
GetCorrelation(integer leftIndex, integer rightIndex) | Obtains the raw correlation, typically named "r" in statistics. |
GetDegreesOfFreedom() | Obtains the degrees of freedom calculated by the test. |
GetDegreesOfFreedom(integer leftIndex, integer rightIndex) | Obtains the raw degrees of freedom. |
GetFormalSummary() | Obtains the raw probability value (p in statistics). |
GetHashCode() | This action gets the hash code for an object. |
GetProbabilityValue(integer leftIndex, integer rightIndex) | Obtains the raw probability value (p in statistics). |
GetProbabilityValue() | Obtains the probability value (p in statistics) calculated by the test. |
GetResultIterator() | This returns an Iterator object of all results calculated. |
GetStatisticalFormatting() | |
IsEmptyColumns() | This action returns a boolean value, true if the container is empty and false if it contains any items. |
RemoveColumn(integer column) | This action removes the first occurrence of an item that is found in the Addable object. |
RemoveColumnAt(integer index) | This action removes an item from an indexed object and returns that item. |
SetStatisticalFormatting(Libraries.Compute.Statistics.Reporting.StatisticsFormatting formatting) |
Actions Documentation
AddColumn(integer column)
This action adds a value to the end of the input.
Parameters
Calculate(Libraries.Compute.Statistics.DataFrame frame)
This calculates a hash value for the results table.
Parameters
Compare(Libraries.Language.Object object)
This action compares two object hash codes and returns an integer. The result is larger if this hash code is larger than the object passed as a parameter, smaller, or equal. In this case, -1 means smaller, 0 means equal, and 1 means larger. This action was changed in Quorum 7 to return an integer, instead of a CompareResult object, because the previous implementation was causing efficiency issues.
Example Code
Object o
Object t
integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)
Parameters
- Libraries.Language.Object: The object to compare to.
Return
integer: The Compare result, Smaller, Equal, or Larger.
EmptyColumns()
This action empty's the list, clearing out all of the items contained within it.
Equals(Libraries.Language.Object object)
This action determines if two objects are equal based on their hash code values.
Example Code
use Libraries.Language.Object
use Libraries.Language.Types.Text
Object o
Text t
boolean result = o:Equals(t)
Parameters
- Libraries.Language.Object: The to be compared.
Return
boolean: True if the hash codes are equal and false if they are not equal.
GetColumn(integer index)
This action gets the item at a given location in an array.
Parameters
Return
integer: The item at the given location.
GetColumnIterator()
This action gets an iterator for the object and returns that iterator.
Return
Libraries.Containers.Iterator: Returns the iterator for an object.
GetColumnSize()
This action gets the size of the array.
Return
integer:
GetCorrelateGroupsResult(integer leftIndex, integer rightIndex)
This returns a correlation between two particular columns. If no such correlation exists, this action returns undefined.
Example Code
use Libraries.Compute.Statistics.DataFrame
use Libraries.Compute.Statistics.Tests.CorrelateGroups
use Libraries.Containers.Iterator
DataFrame frame
frame:Load("Data/Data.csv")
CorrelateGroups correlate
correlate:Add(0)
correlate:Add(1)
frame:Calculate(correlate)
CorrelateGroupsResult result = correlate:GetCorrelateGroupsResult(0, 1)
Parameters
Return
Libraries.Compute.Statistics.Reporting.CorrelateGroupsResult: the correlation results between two groups.
GetCorrelation()
Obtains the raw correlation, typically named "r" in statistics. This calculation only returns a result in the case where the number of correlations to calculate is 2 (two columns). If the number of groups is 3 or more, GetCorrelation(integer leftIndex, integer rightIndex) should be used instead. This is a convenience action for the two-group case.
Example Code
use Libraries.Compute.Statistics.DataFrame
use Libraries.Compute.Statistics.Tests.CorrelateGroups
DataFrame frame
frame:Load("Data/Data.csv")
CorrelateGroups correlate
correlate:Add(0)
correlate:Add(1)
frame:Calculate(correlate)
output correlate:GetCorrelation()
Return
number: the correlation between two groups.
GetCorrelation(integer leftIndex, integer rightIndex)
Obtains the raw correlation, typically named "r" in statistics. This calculation only returns a result in the case where the left and right indexes are valid.
Example Code
use Libraries.Compute.Statistics.DataFrame
use Libraries.Compute.Statistics.Tests.CorrelateGroups
DataFrame frame
frame:Load("Data/Data.csv")
CorrelateGroups correlate
correlate:Add(0)
correlate:Add(1)
frame:Calculate(correlate)
output correlate:GetCorrelation(0, 1)
Parameters
- integer leftIndex: the first group
- integer rightIndex: the second group
Return
number: the correlation between two groups.
GetDegreesOfFreedom()
Obtains the degrees of freedom calculated by the test. This calculation only returns a result in the case where the number of correlations to calculate is 2 (two columns). If the number of groups is 3 or more, GetDegreesOfFreedom(integer leftIndex, integer rightIndex) should be used instead. This is a convenience action for the two-group case.
Example Code
use Libraries.Compute.Statistics.DataFrame
use Libraries.Compute.Statistics.Tests.CorrelateGroups
DataFrame frame
frame:Load("Data/Data.csv")
CorrelateGroups correlate
correlate:Add(0)
correlate:Add(1)
frame:Calculate(correlate)
output correlate:GetDegreesOfFreedom()
Return
number: the degrees of freedom.
GetDegreesOfFreedom(integer leftIndex, integer rightIndex)
Obtains the raw degrees of freedom. This calculation only returns a result in the case where the left and right indexes are valid.
Example Code
use Libraries.Compute.Statistics.DataFrame
use Libraries.Compute.Statistics.Tests.CorrelateGroups
DataFrame frame
frame:Load("Data/Data.csv")
CorrelateGroups correlate
correlate:Add(0)
correlate:Add(1)
frame:Calculate(correlate)
output correlate:GetDegreesOfFreedom(0, 1)
Parameters
- integer leftIndex: the first group
- integer rightIndex: the second group
Return
number: the degrees of freedom.
GetFormalSummary()
Obtains the raw probability value (p in statistics). This calculation only returns a result in the case where the left and right indexes are valid.
Example Code
use Libraries.Compute.Statistics.DataFrame
use Libraries.Compute.Statistics.Tests.CorrelateGroups
DataFrame frame
frame:Load("Data/Data.csv")
CorrelateGroups correlate
correlate:Add(0)
correlate:Add(1)
frame:Calculate(correlate)
output correlate:GetProbabilityValue(0, 1)
Return
text: the degrees of freedom.
GetHashCode()
This action gets the hash code for an object.
Example Code
Object o
integer hash = o:GetHashCode()
Return
integer: The integer hash code of the object.
GetProbabilityValue(integer leftIndex, integer rightIndex)
Obtains the raw probability value (p in statistics). This calculation only returns a result in the case where the left and right indexes are valid.
Example Code
use Libraries.Compute.Statistics.DataFrame
use Libraries.Compute.Statistics.Tests.CorrelateGroups
DataFrame frame
frame:Load("Data/Data.csv")
CorrelateGroups correlate
correlate:Add(0)
correlate:Add(1)
frame:Calculate(correlate)
output correlate:GetProbabilityValue(0, 1)
Parameters
- integer leftIndex: the first group
- integer rightIndex: the second group
Return
number: the degrees of freedom.
GetProbabilityValue()
Obtains the probability value (p in statistics) calculated by the test. This calculation only returns a result in the case where the number of correlations to calculate is 2 (two columns). If the number of groups is 3 or more, GetDegreesOfFreedom(integer leftIndex, integer rightIndex) should be used instead. This is a convenience action for the two-group case.
Example Code
use Libraries.Compute.Statistics.DataFrame
use Libraries.Compute.Statistics.Tests.CorrelateGroups
DataFrame frame
frame:Load("Data/Data.csv")
CorrelateGroups correlate
correlate:Add(0)
correlate:Add(1)
frame:Calculate(correlate)
output correlate:GetProbabilityValue()
Return
number: the probability.
GetResultIterator()
This returns an Iterator object of all results calculated. If there happened to only be two correlations calculated, this iterator will still contain the one correlation.
Example Code
use Libraries.Compute.Statistics.DataFrame
use Libraries.Compute.Statistics.Tests.CorrelateGroups
use Libraries.Containers.Iterator
DataFrame frame
frame:Load("Data/Data.csv")
CorrelateGroups correlate
correlate:Add(0)
correlate:Add(1)
frame:Calculate(correlate)
Iterator<CorrelateGroupsResult> iterator = correlate:GetResultIterator()
Return
Libraries.Containers.Iterator: the results for the correlation.
GetStatisticalFormatting()
Return
Libraries.Compute.Statistics.Reporting.StatisticsFormatting
IsEmptyColumns()
This action returns a boolean value, true if the container is empty and false if it contains any items.
Return
boolean: Returns true when the container is empty and false when it is not.
RemoveColumn(integer column)
This action removes the first occurrence of an item that is found in the Addable object.
Parameters
Return
boolean: Returns true if the item was removed and false if it was not removed.
RemoveColumnAt(integer index)
This action removes an item from an indexed object and returns that item.