ocmath_anova_one_way

 

Description

Function to perform a One-Way ANOVA.

Syntax

int ocmath_anova_one_way( const double * pData, uint nSize, int iLevels, const int * pIndex, ANOVADescStats * DescStats, uint nSizeDescStat, ANOVAStats * TotalStats, RegANOVA * ANOVATable )

Parameters

pData
[input] pointer to data points
nSize
[input] size of pointer pData
iLevels
[input] number indicates the number of levels
pIndex
[input] pointer to the number of each group, size of pLevel should be iLevels
DescStats
[output] pointer to struct containing descriptive statistics
nSizeDescStat
[input] size (number of structs) of DescStats, which should be less than iLevels.
TotalStats
[output] pointer to struct containing ANOVA statistics
ANOVATable
[output] pointer to struct containing ANOVA table

Return

Returns STATS_NO_ERROR on successful exit and a non-zero STATS error code on failure.

Examples

EX1

void ocmath_anova_one_way_ex1()
{
    vector pData ={77.7111,88.07729,92.15046,77.70871,72.25362,  //Group 1
                     83.52885,75.17097,87.96739,91.59955,81.93563, //Group 2
                     78.15473,79.42937,83.52293,71.4648,72.90409 }; //Group 3
    int nSize = pData.GetSize();
    vector<int> pIndex = { 5,5,5 };
    int iLevels = pIndex.GetSize();
 
    ANOVADescStats DescStats[3];
    ANOVAStats TotalStats;
    RegANOVA ANOVATable;
 
    int nRet = ocmath_anova_one_way(pData, nSize, iLevels, pIndex, DescStats, 3, &TotalStats, &ANOVATable);
    out_int("nRet=", nRet); //nRet should be 0 for no error
 
    //print results
    Tree trTotalStats, trANOVATable;
    trTotalStats = TotalStats;
    trANOVATable = ANOVATable;
    out_tree(trTotalStats);
    out_tree(trANOVATable);
}

Remark

See Also

header to Included

origin.h

Reference