One Way ANOVA 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.Anova
' Start namespace.
Namespace Simplexar.Examples.Statsar
' This example illustrates how to perform a one way
' analysis of variance by using the OneWayAnova class
' from the Statsar.Simplexar.Anova namespace.
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()
' Create sheet.
Dim calculator As New StatsCalculator()
Dim sheet As DataSheet = calculator.Sheet
Dim columns As ColumnList = sheet.Columns
columns.Add("Level1", GetType(Double))
columns.Add("Level2", GetType(Double))
columns.Add("Level3", GetType(Double))
' Populate data.
Dim rows As RowList = sheet.Rows
rows.Add(6.9, 8.3, 8.0)
rows.Add(5.4, 6.8, 10.5)
rows.Add(5.8, 7.8, 8.1)
rows.Add(4.6, 9.2, 6.9)
rows.Add(4.0, 6.5, 9.3)
Console.WriteLine(sheet)
' Perform analysis of variance.
Dim anova As New OneWayAnova(sheet)
' Access ANOVA table. This holds the results.
Dim anovaTable As OneWayAnovaTable = anova.AnovaTable
Console.WriteLine(anovaTable)
' Access individual ANOVA properties.
Console.WriteLine( _
"Treatments sum of squares: {0}", _
anovaTable.SumOfSquareTreatments)
Console.WriteLine( _
"Error sum of squares: {0}", _
anovaTable.SumOfSquareError)
Console.WriteLine( _
"Total sum of squares: {0}", _
anovaTable.SumOfSquareTotal)
Console.WriteLine( _
"Treatments degrees of freedom: {0}", _
anovaTable.DegreesOfFreedomTreatments)
Console.WriteLine( _
"Error degrees of freedom: {0}", _
anovaTable.DegreesOfFreedomError)
Console.WriteLine( _
"Total degrees of freedom: {0}", _
anovaTable.DegreesOfFreedomTotal)
Console.WriteLine( _
"Treatments mean square: {0}", _
anovaTable.MeanSquareTreatments)
Console.WriteLine( _
"Error mean square: {0}", _
anovaTable.MeanSquareError)
Console.WriteLine( _
"Total mean square: {0}", _
anovaTable.MeanSquareTotal)
Console.WriteLine( _
"F-statistic: {0}", _
anovaTable.FStatistic)
Console.WriteLine( _
"P-value: {0}", _
anovaTable.PValue)
End Sub
End Module
End Namespace