Two Sample Paired T-Test Demo Example (VB.NET)
[VB.NET]
' COPYRIGHT(C), SIMPLEXAR SOFTWARE LIMITED, 2006-2008.
' All rights reserved.
'
' Use of this copyright notice is precautionary only, and does not imply
' publication or disclosure. The content of this work contains confidential
' and proprietary information of Simplexar Software Limited. Any duplication,
' modification, distribution, or disclosure in any form, in whole, or in part,
' is strictly prohibited without express prior written permission.
' Get namespaces.
Imports System
Imports Simplexar.Statsar
Imports Simplexar.Statsar.HypothesisTests
' Start namespace.
Namespace Simplexar.Examples.Statsar
' This example shows how to perform a statistical hypothesis test
' by using the two sample paired T-test class. This tests if the
' mean of the paired differences of two samples is 0.
Module Example
' The application entry point.
Public Sub Main()
Try
RunExample()
Catch exception As Exception
Console.WriteLine(exception)
End Try
Console.WriteLine("Press ENTER to terminate.")
Console.ReadLine()
End Sub
Private Sub RunExample()
' Define test parameters.
Dim xbar As Double = 0.18 ' The mean of the differences.
Dim pairedStandardDeviation As Double = 0.79
Dim n As Integer = 45 ' The sample size.
Dim alpha As Double = 0.05
' Create a new two sample paired T-test. In this example
' we create the test using explict test parameters. A second
' constructor is also provided which constructs a test from
' sample data.
Dim test As New TwoSamplePairedTTest( _
xbar, pairedStandardDeviation, n, alpha, _
HypothesisType.TwoSided)
' Display test statistics.
Console.WriteLine( _
"P-value: {0}", test.P)
Console.WriteLine( _
"Reject: {0}", test.Reject)
Console.WriteLine( _
"Statistic: {0}", test.Statistic)
Console.WriteLine( _
"Left critical value: {0}", test.LeftCriticalValue)
Console.WriteLine( _
"Right critical value: {0}", test.RightCriticalValue)
Console.WriteLine( _
"Left probability: {0}", test.LeftProbability)
Console.WriteLine( _
"Right probability: {0}", test.RightProbability)
Console.WriteLine( _
"Lower confidence limit: {0}", test.LowerConfidenceLimit)
Console.WriteLine( _
"Upper confidence limit: {0}", test.UpperConfidenceLimit)
Console.WriteLine( _
"Standard error of the mean: {0}", test.SEM)
Console.WriteLine( _
"Distribution degrees of freedom: {0}", test.DegreesOfFreedom)
End Sub
End Module
End Namespace