Click or drag to resize
Accord.NET (logo)

PairedTTest Class

T-Test for two paired samples.
Inheritance Hierarchy
SystemObject
  Accord.Statistics.TestingHypothesisTestTDistribution
    Accord.Statistics.TestingPairedTTest

Namespace:  Accord.Statistics.Testing
Assembly:  Accord.Statistics (in Accord.Statistics.dll) Version: 3.8.0
Syntax
[SerializableAttribute]
public class PairedTTest : HypothesisTest<TDistribution>
Request Example View Source

The PairedTTest type exposes the following members.

Constructors
  NameDescription
Public methodPairedTTest
Creates a new paired t-test.
Top
Properties
  NameDescription
Public propertyConfidence
Gets the 95% confidence interval for the ObservedDifference statistic.
Public propertyCriticalValue
Gets the critical value for the current significance level.
(Inherited from HypothesisTestTDistribution.)
Public propertyHypothesis
Gets the alternative hypothesis under test. If the test is Significant, the null hypothesis can be rejected in favor of this alternative hypothesis.
Public propertyMean1
Gets the first sample's mean.
Public propertyMean2
Gets the second sample's mean.
Public propertyObservedDifference
Gets the observed mean difference between the two samples.
Public propertyPValue
Gets the P-value associated with this test.
(Inherited from HypothesisTestTDistribution.)
Public propertySampleSize
Gets the size of a sample. Both samples have equal size.
Public propertySignificant
Gets whether the null hypothesis should be rejected.
(Inherited from HypothesisTestTDistribution.)
Public propertySize
Gets the significance level for the test. Default value is 0.05 (5%).
(Inherited from HypothesisTestTDistribution.)
Public propertyStandardError
Gets the standard error of the difference.
Public propertyStatistic
Gets the test statistic.
(Inherited from HypothesisTestTDistribution.)
Public propertyStatisticDistribution
Gets the distribution associated with the test statistic.
(Inherited from HypothesisTestTDistribution.)
Public propertyTail
Gets the test type.
(Inherited from HypothesisTestTDistribution.)
Top
Methods
  NameDescription
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetConfidenceInterval
Gets a confidence interval for the ObservedDifference statistic within the given confidence level percentage.
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Protected methodOnSizeChanged
Update event.
(Overrides HypothesisTestTDistributionOnSizeChanged.)
Public methodPValueToStatistic
Converts a given p-value to a test statistic.
(Overrides HypothesisTestTDistributionPValueToStatistic(Double).)
Public methodStatisticToPValue
Converts a given test statistic to a p-value.
(Overrides HypothesisTestTDistributionStatisticToPValue(Double).)
Public methodToString
Converts the numeric P-Value of this test to its equivalent string representation.
(Inherited from HypothesisTestTDistribution.)
Public methodToString(String, IFormatProvider)
Converts the numeric P-Value of this test to its equivalent string representation.
(Inherited from HypothesisTestTDistribution.)
Top
Extension Methods
  NameDescription
Public Extension MethodHasMethod
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.)
Public Extension MethodIsEqual
Compares two objects for equality, performing an elementwise comparison if the elements are vectors or matrices.
(Defined by Matrix.)
Public Extension MethodTo(Type)Overloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Public Extension MethodToTOverloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Top
Remarks

The Paired T-test can be used when the samples are dependent; that is, when there is only one sample that has been tested twice (repeated measures) or when there are two samples that have been matched or "paired". This is an example of a paired difference test.

References:

Examples

Suppose we would like to know the effect of a treatment (such as a new drug) in improving the well-being of 9 patients. The well-being is measured in a discrete scale, going from 0 to 10.

// To do so, we need to register the initial state of each patient
// and then register their state after a given time under treatment.

double[,] patients =
{
        //                 before      after
        //                treatment  treatment
        /* Patient 1.*/ {     0,         1     },
        /* Patient 2.*/ {     6,         5     },
        /* Patient 3.*/ {     4,         9     },
        /* Patient 4.*/ {     8,         6     },
        /* Patient 5.*/ {     1,         6     },
        /* Patient 6.*/ {     6,         7     },
        /* Patient 7.*/ {     3,         4     },
        /* Patient 8.*/ {     8,         7     },
        /* Patient 9.*/ {     6,         5     },
};

// Extract the before and after columns
double[] before = patients.GetColumn(0);
double[] after = patients.GetColumn(1);

// Create the paired-sample T-test. Our research hypothesis is
// that the treatment does improve the patient's well-being. So
// we will be testing the hypothesis that the well-being of the
// "before" sample, the first sample, is "smaller" in comparison
// to the "after" treatment group.

PairedTTest test = new PairedTTest(before, after,
    TwoSampleHypothesis.FirstValueIsSmallerThanSecond);

bool significant = test.Significant; //   not significant
double pvalue = test.PValue;         //  p-value =  0.1650
double tstat  = test.Statistic;      //  t-stat  = -1.0371
See Also