| 2.1.24.1.1 ocmath_anova_mean_comparison
 DescriptionFunction to compute One-Way ANOVA Mean Comparisons. Computes simultaneous confidence intervals for the differences
between means.
 Syntaxint 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 pMeanInput pointer to Mean of each group nSizeMeanInput size of pointer pMean, which should not be less than nGroupSize pNPTSInput pointer to size of each group nSizeNPTsInput size of pointer pNPTs, which should not be less than nGroupSize dMSEInput Mean Square for Error term of the model nDOFInput Degree of Freedom for Error term of the model dAlphaInput number indicates the significant level of the model nGroupSizeInput size indicates group number. pIndexComparisonOutput pointer to order of means comparison nSizeComparisonInput size of pointer pIndexComparison, which should not be less than (nGroupSize*(nGroupSize-1)/2) pMeanDiffsOutput pointer to difference of means of two Samples nSizeMeanDiffInput size of pointer pMeanDiffs, which should not be less than (nGroupSize*(nGroupSize-1)/2) pLCLsOutput pointer to lower confidence limits for difference of means nSizeLCLInput size of pointer pLCLs, which should not be less than (nGroupSize*(nGroupSize-1)/2) pUCLsOutput pointer to upper confidence limits for difference of means nSizeUCLInput size of pointer pUCLs, which should not be less than (nGroupSize*(nGroupSize-1)/2) pSeOutput pointer to Standard Errors of difference between means nSizeSeInput size of pointer pSe, which should not be less than (nGroupSize*(nGroupSize-1)/2) pStatOutput pointer to Statistic used to test difference between means nSizeStatInput size of pointer pStat, which should not be less than (nGroupSize*(nGroupSize-1)/2) pProbOutput pointer to Probability of the test for difference between means nSizeProbInput size of pointer pProb, which should not be less than (nGroupSize*(nGroupSize-1)/2) pSigOutput pointer to indicator whether the difference between means is significant or not.pSig[i] =1:		the difference is significantpSig[i] =0:		the difference is NOT significant	i=0, 1, ..., nSizeSig-1 nSizeSigInput size of pointer pSig, which should not be less than (nGroupSize*(nGroupSize-1)/2) pAlphaOutput pointer to significance level that depends upon the test nSizeAlphaInput size of pointer pAlpha, which should not be less than (nGroupSize*(nGroupSize-1)/2) nIntervalTypeInput interger that indicates which method to be used. Optional choice included as below
ANOVA_BONFERRON = 1:	the Bonferroni method is usedANOVA_TUKEY = 2:		the Tukey-Kramer method is usedANOVA_SCHEFFE = 3:		the Scheffe method is usedANOVA_SIDAK = 4:		the Dunn-Sidak method is usedANOVA_FISHER = 5:		the Fisher's LSD method is usedANOVA_BONHOLM = 6:		the Bonferroni-Holm method is usedANOVA_SIDAKHOLM = 7:	the Sidak-Holm method is usedANOVA_DUNNETT = 8:		the Dunnett method is used
 ReturnReturns STATS_NO_ERROR on successful exit and a non-zero STATS error code on failure.
 ExamplesEX1
 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");
    	}
    }
}RemarkSee AlsoHeader to Includedorigin.h
 Reference |