ocmath_anova_mean_comparison
Description
Function to compute One-Way ANOVA Mean Comparisons. Computes simultaneous confidence intervals for the differences between means.
Syntax
int ocmath_anova_mean_comparison( const double * pMean, uint nSizeMean, const int * pNPTS, uint nSizeNPTs, const double dMSE, const int nDOF, const double dAlpha, const int nGroupSize, int * pIndexComparison, uint nSizeComparison, double * pMeanDiffs, uint nSizeMeanDiff, double * pLCLs, uint nSizeLCL, double * pUCLs, uint nSizeUCL, double * pSe, uint nSizeSe, double * pStat, uint nSizeStat, double * pProb, uint nSizeProb, long * pSig, uint nSizeSig, double * pAlpha, uint nSizeAlpha, int nIntervalType )
Parameters
- pMean
- Input pointer to Mean of each group
- nSizeMean
- Input size of pointer pMean, which should not be less than nGroupSize
- pNPTS
- Input pointer to size of each group
- nSizeNPTs
- Input size of pointer pNPTs, which should not be less than nGroupSize
- dMSE
- Input Mean Square for Error term of the model
- nDOF
- Input Degree of Freedom for Error term of the model
- dAlpha
- Input number indicates the significant level of the model
- nGroupSize
- Input size indicates group number.
- pIndexComparison
- Output pointer to order of means comparison
- nSizeComparison
- Input size of pointer pIndexComparison, which should not be less than (nGroupSize*(nGroupSize-1)/2)
- pMeanDiffs
- Output pointer to difference of means of two Samples
- nSizeMeanDiff
- Input size of pointer pMeanDiffs, which should not be less than (nGroupSize*(nGroupSize-1)/2)
- pLCLs
- Output pointer to lower confidence limits for difference of means
- nSizeLCL
- Input size of pointer pLCLs, which should not be less than (nGroupSize*(nGroupSize-1)/2)
- pUCLs
- Output pointer to upper confidence limits for difference of means
- nSizeUCL
- Input size of pointer pUCLs, which should not be less than (nGroupSize*(nGroupSize-1)/2)
- pSe
- Output pointer to Standard Errors of difference between means
- nSizeSe
- Input size of pointer pSe, which should not be less than (nGroupSize*(nGroupSize-1)/2)
- pStat
- Output pointer to Statistic used to test difference between means
- nSizeStat
- Input size of pointer pStat, which should not be less than (nGroupSize*(nGroupSize-1)/2)
- pProb
- Output pointer to Probability of the test for difference between means
- nSizeProb
- Input size of pointer pProb, which should not be less than (nGroupSize*(nGroupSize-1)/2)
- pSig
- Output pointer to indicator whether the difference between means is significant or not.
- pSig[i] =1: the difference is significant
- pSig[i] =0: the difference is NOT significant i=0, 1, ..., nSizeSig-1
- nSizeSig
- Input size of pointer pSig, which should not be less than (nGroupSize*(nGroupSize-1)/2)
- pAlpha
- Output pointer to significance level that depends upon the test
- nSizeAlpha
- Input size of pointer pAlpha, which should not be less than (nGroupSize*(nGroupSize-1)/2)
- nIntervalType
-
Input interger that indicates which method to be used. Optional choice included as below
- ANOVA_BONFERRON = 1: the Bonferroni method is used
- ANOVA_TUKEY = 2: the Tukey-Kramer method is used
- ANOVA_SCHEFFE = 3: the Scheffe method is used
- ANOVA_SIDAK = 4: the Dunn-Sidak method is used
- ANOVA_FISHER = 5: the Fisher's LSD method is used
- ANOVA_BONHOLM = 6: the Bonferroni-Holm method is used
- ANOVA_SIDAKHOLM = 7: the Sidak-Holm method is used
- ANOVA_DUNNETT = 8: the Dunnett method is used
Return
Returns STATS_NO_ERROR on successful exit and a non-zero STATS error code on failure.
Examples
EX1
void ocmath_anova_mean_comparison_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);
vector vMeans(3), vMeanDiffs(3), vLCLs(3), vUCLs(3), vSE(3), vStats(3), vProbs(3), vAlphas(3);
vector<int> vnIndexComp(3), vnSigs(3);
vMeans[0] = DescStats[0].Mean;
vMeans[1] = DescStats[1].Mean;
vMeans[2] = DescStats[2].Mean;
double dMSE = ANOVATable.AnovaTable[1].MeanSq;
int DF = ANOVATable.AnovaTable[1].DOF;
nRet = ocmath_anova_mean_comparison(vMeans, 3, pIndex, iLevels, dMSE, DF, 0.05, 3, vnIndexComp, 3, vMeanDiffs, 3, vLCLs, 3, vUCLs, 3, vSE, 3, vStats, 3, vProbs, 3, vnSigs, 3, vAlphas, 3, ANOVA_TUKEY);
//print result if no error
if (0 == nRet)
{
vector<string> vstrMeanComp = {"2 v.s.1", "3 v.s. 1", "3 v.s. 2"};
for (int ii = 0; ii < 3; ii++)
{
printf("Mean Comparison Results (%s):\n", vstrMeanComp[ii]);
out_double("MeanDiff = ", vMeanDiffs[ii]);
out_double("SEM = ", vSE[ii]);
out_double("t-val = ", vStats[ii]);
out_double("LCL = ", vLCLs[ii]);
out_double("UCL = ", vUCLs[ii]);
printf("\n");
}
}
}
Remark
See Also
header to Included
origin.h
Reference
|