VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



ANOVA Analysis of Variance.

by Ascher Stefan (8 Submissions)
Category: Math/Dates
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Tue 9th November 1999
Date Added: Mon 8th February 2021
Rating: (1 Votes)

ANOVA Analysis of Variance.

Rate ANOVA Analysis of Variance.



    VarTot As Double, _
    VarTread As Double, _
    VarE As Double, _
    QSTot As Double, _
    QSTreat As Double, _
    QSE As Double, _
    dfTot As Integer, _
    dfTread As Integer, _
    dfE As Integer) As Double
    
' Einfaktorielle Varianznalyse / Analysis of Variance

' Inputs:
' x()...2 dimensional array
' Outputs:
' VarTot...Variance total
' VarTreat...Treatmentvariance
' VarE...Errorvariance
' QSTot...Squaresum total
' QSTreat...Squaresum treatment
' QSE Squaresum error
' dtTot...Degrees of Freedom total
' dfTreat...Degrees of Freedom treatment
' dfE...Degrees of Freedom error

    Dim MwTot As Double                             ' Mittelwert total
    Dim SummenTest() As Double                      ' Summen der Tests
    Dim MweTest() As Double                         ' Mittelwerte der Tests
    Dim tmpQSE() As Double                          ' Fehlerquadratsumme
    Dim tmpSumTot As Double                         ' Summe total
    Dim t As Integer                                ' t... Anzahl Tests
    Dim N As Integer                                ' n...Anzahl Werte
    Dim i As Integer, j As Integer
    
    ReDim SummenTest(UBound(x, 2))
    ReDim MweTest(UBound(x, 2))
    
    N = UBound(x, 1) + 1
    t = UBound(x, 2) + 1
    For i = 0 To UBound(x, 2)
        For j = 0 To UBound(x, 1)
            SummenTest(i) = SummenTest(i) + x(j, i) ' Summen der Tests
        Next j
        MweTest(i) = SummenTest(i) / N
    Next i
    
    For i = 0 To UBound(SummenTest)
        tmpSumTot = tmpSumTot + SummenTest(i)       ' Summe total
    Next i
    MwTot = tmpSumTot / (N * t)                     ' Mittelwert total
    
    dfE = t * (N - 1)
    
    ReDim tmpQSE(UBound(x, 2))
    
    For i = 0 To UBound(x, 2)
        For j = 0 To UBound(x, 1)
            QSTot = QSTot + ((x(j, i) - MwTot) ^ 2) ' Quadratsumme total
            tmpQSE(i) = tmpQSE(i) + ((x(j, i) - MweTest(i)) ^ 2)
        Next j
        QSTreat = QSTreat + (((MweTest(i) - MwTot) ^ 2))
        QSE = QSE + tmpQSE(i)                       ' Fehlervarianz
        
    Next i
    VarE = QSE / dfE
    
    QSTreat = QSTreat * N
    dfTread = t - 1
    VarTread = QSTreat / dfTread                    ' Treatment Varianz
    
    dfTot = N * t - 1
    VarTot = QSTot / dfTot                          ' Gesamtvarianz
    
    ANOVA = (QSTreat / QSTot) * 100                 ' Varianzaufklärung
    
End Function

Download this snippet    Add to My Saved Code

ANOVA Analysis of Variance. Comments

No comments have been posted about ANOVA Analysis of Variance.. Why not be the first to post a comment about ANOVA Analysis of Variance..

Post your comment

Subject:
Message:
0/1000 characters