type TMtxHypothesisTest = class(TMtxComponent);
Encapsulates parametric and non-parametric hypothesis testing routines.
Encapsulates parametric and non-parametric hypothesis testing routines. Many problems in engineering require that we decide whether to accept or reject a statement about some parameter. The statement is called a hypothesis and the decision-making procedure about the hypothesis is called hypothesis testing.
The following hypothesis tests are supported:
- one or two sample Sign test,
- one or two sample Wilcoxon Signed-Rank test,
- one or two sample (on pooled or paired data) T test,
- one sample Z test,
- one sample ChiSquared test,
- two sample F test.
How to use TMtxHypothesisTest component?
- Drop a TMtxHypothesisTest component on the form.
- Define the hypothesis test you want to perform (Sign, Wilcoxon, Z, T, ChiSquared, F).
- Define hypothesis type (the null hypothesis type) : two, left or right tailed.
- Depending on hypothesis method define one or two sample datasets. You can do this by clicking on TMtxHypothesisTest.DataVec1 (and TMtxHypothesisTest.DataVec2) properties.
- Depending on hypothesis method you'll also have to define test mean (and in Z, F Test case sigma) property.
- Define the desired significance level TMtxHypothesisTest.Alpha.
- Call the TMtxHypothesisTest.Recalc method to calculate hypothesis test results.
Results:
- TMtxHypothesisTest.Result : The hypothesis result (accept, reject null hypothesis).
- TMtxHypothesisTest.Significance : actual significance level.
- TMtxHypothesisTest.ConfLower,TMtxHypothesisTest.ConfUpper : 100*(1-Alpha) confidence interval limits for mean (median, standard deviation).
Examples
delphi
Uses MtxVec, Statistics, StatTools;
var MtxHypothesis1: TMtxHypothesisTest;
begin
MtxHypothesis1.Alpha := 0.03; // desired significance level at 3%
MtxHypothesis1.HypothesisType := htTwoTailed; // two tailed => Ha= means are not equal
MtxHypothesis1.DataVec1.SetIt(false,[1.0, 2.0, 3.0, 4.0]); // first dataset
MtxHypothesis1.DataVec2.SetIt(false,[1.5, 3.1, 4.2, 4.3]); // second dataset
MtxHypothesis1.HypothesisMethod := hmTTest2Pooled; // comparing means of two datasets
MtxHypothesis1.Recalc;
//Results ==> Significance = 0.43036618314 , Result = hrNotReject
end;
Properties
| Name | Type | Description |
|---|---|---|
| Alpha | Double | Desired significance level. |
| AutoUpdate | Boolean | If true then changing any of the TMtxHypothesisTest properties will trigger the TMtxHypothesisTest.Recalc method. |
| BlockAssign | Boolean | Block streaming of specific properties when storing only a "template". |
| ConfLower | Double | Returns lower confidence interval limit. |
| ConfUpper | Double | Returns upper confidence interval limit. |
| DataVec1 | TVec | First sample values. |
| DataVec2 | TVec | Second sample values. |
| Dirty | Boolean | When any of the TMtxHypothesisTest properties changes, this property is automatically set to true. |
| EditorActive | Boolean | Returns True, if the component editor is displayed. |
| HypothesisMethod | THypothesisMethod | Defines which hypothesis routine will be used for data testing. |
| HypothesisType | THypothesisType | Defines hypothesis type (left, right and two-tailed). |
| Mean | Double | Defines mean/median value for one-sample test. |
| Reference | TReferenceList | Stores a list of components that have to be notified, when this component is destroyed. |
| Result | THypothesisResult | Returns hypothesis result. |
| Sigma | Double | Defines standard deviation value for single test. |
| Significance | Double | Returns calculated significance level. |
| TestStatistics | Double | Returns test statistics. |
Methods
| Name | Description |
|---|---|
| AllowStreaming | Returns the negatated value of BlockAssign. |
| Assign | Assign values of all published properties from Source. |
| AssignTemplate | Assign values of "template-like" published properties from Source. |
| EditorClass | To be overriden in descendanr classses. |
| LoadFromStream | Load the component from Src stream. |
| LoadTemplateFromFile | Load a template from file. |
| LoadTemplateFromStream | Load a template from stream. |
| Recalc | Triggers hypothesis test recalculation. |
| Reset | Reset is called after loading the data from stream or file. |
| SaveTemplateToFile | Save template to file. |
| SaveTemplateToStream | Save template to stream. |
| SaveToStream | Save the component to Dst stream. |