CompareMeansPairwise
Package: Libraries.Compute.Statistics.Tests · Inherits from: Libraries.Compute.Statistics.DataFrameCalculation, Libraries.Compute.Statistics.Inputs.ColumnInput, Libraries.Language.Object, Libraries.Compute.Statistics.Tests.StatisticalTest, Libraries.Compute.Statistics.Tests.CompareMeans, Libraries.Compute.Statistics.Inputs.FactorInput
This class implements several post hoc analysis tests, which are intended to be used after a significant CompareMeans test with three or more samples. This class can take two approaches. The first, which is the default, called the 'fitted' approach, will use the fitted result of the prior CompareMeans test to calculate the standard error and adjustments to correct for familywise error. The formal names of tests included in fitted approach are as follows: Tukey's HSD, Tukey-Kramer, Games-Howell, Emmeans-Bonferroni, Nemenyi, Dunn-Bonferroni, and Conover-Iman-Bonferroni. The second approach, called the 'unfitted' approach, will not use the fitted result of prior CompareMeans test, instead it will run individual two-sample CompareMeans tests and then correct for familywise error using Bonferroni. The formal names of tests included in the unfitted approach are as follows: t-test, Welch's t-test, paired t-test, paired Wilcoxon test, and Mann-Whitney-Wilcoxon test. There are two types of corrections as well, the first is 'lenient', which is an inherent correction applied in some fitted tests, the second is 'strict' which refers to any test that applies the Bonferroni correction to the p-values. See the INFORMATION comment block at the bottom of this class for more information about each test. For more information: https://en.wikipedia.org/wiki/Post_hoc_analysis
Example Code
use Libraries.Compute.Statistics.DataFrame
use Libraries.Compute.Statistics.Tests.CompareMeansPairwise
DataFrame frame
frame:Load("Data/Data.csv")
// this example will show a two-factor between subjects design
// make a design for the test to follow
ExperimentalDesign design
// select the name of a column in your frame as a first factor (independent variable)
design:AddBetweenSubjectsFactor("Age")
// select the name of a column in your frame as a second factor (independent variable)
design:AddBetweenSubjectsFactor("Group")
// select the name of a column in your frame as the dependent variable
design:AddDependentVariable("Response")
// tell the frame to use this design and run a compare means pairwise test
CompareMeansPairwise pairwise = frame:CompareMeansPairwise(design)
// output the pairwise summary, a list of adjusted p-values for every comparison
output pairwise:GetPairwiseSummary()
// if you only want a specific set of comparisons based on a certain factor or interaction
output pairwise:GetPairwiseSummary("Age:Group")
Actions
AssumeEqualVariances(boolean assume)
Only one result from two-sample test
Parameters
assumeboolean
AssumeNormalDistribution(boolean assume)
Parameters
assumeboolean
BuildOnSignificantTest(boolean build)
For ranked pairwise comparisons with the strict correction: true runs the Conover-Iman test instead of Dunn's test. Both compare the groups' mean ranks with Bonferroni's correction. The Conover-Iman test measures each pair's error from the ranks the overall test (Kruskal-Wallis or Friedman) left unexplained, which is smaller when that test was significant, so it finds differences more readily; it is meant to follow a significant overall test. Neither test assumes or corrects for unequal variances, so AssumeEqualVariances doesn't choose between them. False by default.
Parameters
buildboolean: True to build on a significant overall test.
Calculate(Libraries.Compute.Statistics.DataFrame frame)
Parameters
Calculate(Libraries.Compute.Statistics.Reporting.CompareMeansResult result)
Parameters
GetPairwiseSummary()
This returns the simple pairwise summary of the results for all effects.
Returns
text: the pairwise summary.
Example
use Libraries.Compute.Statistics.DataFrame
use Libraries.Compute.Statistics.Tests.CompareMeansPairwise
DataFrame frame
frame:Load("Data/Data.csv")
ExperimentalDesign design
design:AddBetweenSubjectsFactor("Age")
design:AddBetweenSubjectsFactor("Group")
design:AddDependentVariable("Response")
CompareMeansPairwise compare
compare:SetExperimentalDesign(design)
frame:Calculate(compare)
output compare:GetPairwiseSummary()
GetPairwiseSummary(text source)
This returns the simple pairwise summary of the results for a given effect.
Parameters
sourcetext
Returns
text: the pairwise summary.
Example
use Libraries.Compute.Statistics.DataFrame
use Libraries.Compute.Statistics.Tests.CompareMeansPairwise
DataFrame frame
frame:Load("Data/Data.csv")
ExperimentalDesign design
design:AddBetweenSubjectsFactor("Age")
design:AddBetweenSubjectsFactor("Group")
design:AddDependentVariable("Response")
CompareMeansPairwise compare
compare:SetExperimentalDesign(design)
frame:Calculate(compare)
output compare:GetPairwiseSummary("Age")
GetResults(text source)
Parameters
sourcetext
Returns
Libraries.Containers.Array<Libraries.Compute.Statistics.Reporting.CompareMeansResult>: an array of the CompareMeansResult objects for a single source (i.e. a main effect or an interaction effect)
Example
use Libraries.Compute.Statistics.DataFrame
use Libraries.Compute.Statistics.Tests.CompareMeansPairwise
DataFrame frame
frame:Load("Data/Data.csv")
ExperimentalDesign design
design:AddBetweenSubjectsFactor("Age")
design:AddBetweenSubjectsFactor("Group")
design:AddDependentVariable("Response")
CompareMeansPairwise compare
compare:SetExperimentalDesign(design)
frame:Calculate(compare)
Array<CompareMeansResult> results = compare:GetResults("Age")
GetResults()
Returns
Libraries.Containers.Array<Libraries.Compute.Statistics.Reporting.CompareMeansResult>: an array of all the CompareMeansResult objects
Example
use Libraries.Compute.Statistics.DataFrame
use Libraries.Compute.Statistics.Tests.CompareMeansPairwise
DataFrame frame
frame:Load("Data/Data.csv")
ExperimentalDesign design
design:AddBetweenSubjectsFactor("Age")
design:AddBetweenSubjectsFactor("Group")
design:AddDependentVariable("Response")
CompareMeansPairwise compare
compare:SetExperimentalDesign(design)
frame:Calculate(compare)
Array<CompareMeansResult> results = compare:GetResults()
GetSources()
This returns the simple pairwise summary of the results for a given effect.
Returns
Libraries.Containers.Array<text>: the pairwise summary.
Example
use Libraries.Compute.Statistics.DataFrame
use Libraries.Compute.Statistics.Tests.CompareMeansPairwise
DataFrame frame
frame:Load("Data/Data.csv")
ExperimentalDesign design
design:AddBetweenSubjectsFactor("Age")
design:AddBetweenSubjectsFactor("Group")
design:AddDependentVariable("Response")
CompareMeansPairwise compare
compare:SetExperimentalDesign(design)
frame:Calculate(compare)
output compare:GetPairwiseSummary("Age")
IsBuildingOnSignificantTest()
Returns
boolean: True if ranked pairwise comparisons with the strict
correction run the Conover-Iman test, false for Dunn's test.
Inherited Actions
8 actions from Libraries.Compute.Statistics.Inputs.ColumnInput
8 actions from Libraries.Compute.Statistics.Inputs.FactorInput
62 actions from Libraries.Compute.Statistics.Tests.CompareMeans
- AddBetweenSubjectsFactor(text factorHeader, text variableHeader, text columnHeaders)
- AddBetweenSubjectsFactor(text header)
- AddBetweenSubjectsFactor(text factorHeader, text columnHeaders)
- AddDependentVariable(text header)
- AddSubjectIdentifier(text header)
- AddWithinSubjectsFactor(text header)
- AddWithinSubjectsFactor(text factorHeader, text variableHeader, text columnHeaders)
- AddWithinSubjectsFactor(text factorHeader, text columnHeaders)
- AssumeEqualVariances()
- AssumeNormalDistribution()
- CompareSeveralMeans(Libraries.Compute.Statistics.DataFrame frame)
- CompareSeveralRankedMeans(Libraries.Compute.Statistics.DataFrame frame)
- CompareSeveralRelatedMeans(Libraries.Compute.Statistics.DataFrame frame)
- CompareSeveralRelatedRankedMeans(Libraries.Compute.Statistics.DataFrame frame)
- CompareToMean(Libraries.Compute.Statistics.DataFrame frame)
- CompareToRankedMean(Libraries.Compute.Statistics.DataFrame frame)
- CompareTwoMeans(Libraries.Compute.Statistics.DataFrame frame)
- CompareTwoRankedMeans(Libraries.Compute.Statistics.DataFrame frame)
- CompareTwoRelatedMeans(Libraries.Compute.Statistics.DataFrame frame)
- CompareTwoRelatedRankedMeans(Libraries.Compute.Statistics.DataFrame frame)
- CorrectFamilyWiseError(boolean correctFamilyWiseError)
- CorrectFamilyWiseError()
- GetAssumptionTestSummary()
- GetChart()
- GetDegreesOfFreedom()
- GetDesign()
- GetDistributionResults()
- GetEffectSize()
- GetFormalSummary()
- GetPairwiseResults()
- GetProbabilities()
- GetProbabilityValue()
- GetReport(Libraries.System.File file)
- GetResult()
- GetSummary()
- GetSummaryDataFrame()
- GetTestStatistic()
- GetVarianceResult()
- Paired(boolean paired)
- Paired()
- Ranked()
- Ranked(boolean ranked)
- RepeatedMeasures()
- RepeatedMeasures(boolean repeatedMeasures)
- SaveReport(text filepath)
- SetExperimentalDesign(Libraries.Compute.Statistics.Tests.ExperimentalDesign design)
- SetMean(number mean)
- SetMedian(number median)
- TestAllAssumptions()
- TestDistributionAssumption()
- TestPairwise()
- TestPairwise(boolean test)
- TestVarianceAssumption()
- TestVarianceAssumption(boolean test)
- UseFittedApproach(boolean useFittedApproach)
- UseLenientCorrection(boolean useLenientCorrection)
- UseStrictCorrection(boolean useStrictCorrection)
- UseUnfittedApproach(boolean useUnfittedApproach)
- UsingFittedApproach()
- UsingLenientCorrection()
- UsingStrictCorrection()
- UsingUnfittedApproach()