P-value correction: Difference between revisions

m
merged 1 function into the main function p_adjust in C
(added that the C function can calculate using multiple methods)
m (merged 1 function into the main function p_adjust in C)
Line 17:
 
There are numerous implementations of how to do this, namely Benjamini-Hochberg, Holm, Hochberg, Hommel, Bonferroni. Each of which has its own advantages and disadvantages. This work is a translation of the R source code. In order to confirm that the new function is working correctly, each value is compared to R's output and a cumulative absolute error is returned.
The C function `p_adjust` is designed to work as similarly to the R function as possible, and is able to do any one of the methods.
 
=={{header|C}}==
Line 225:
}
return doubleArray;
 
unsigned short int string2FDRtype (const char *restrict STRING) {
//this functionshould be separate from p_adjust because this function will be
//called in multiple places
if (strcasecmp(STRING, "BH") == 0) {
return 0;
} else if (strcasecmp(STRING, "fdr") == 0) {
return 0;
} else if (strcasecmp(STRING, "by") == 0) {
return 1;
} else if (strcasecmp(STRING, "Bonferroni") == 0) {
return 2;
} else if (strcasecmp(STRING, "hochberg") == 0) {
return 3;
} else if (strcasecmp(STRING, "holm") == 0) {
return 4;
} else if (strcasecmp(STRING, "hommel") == 0) {
return 5;
} else {
printf("%s doesn't match any accepted cases.\n", STRING);
printf("Failed at %s line %u\n", __FILE__, __LINE__);
exit(EXIT_FAILURE);
}
}
 
Line 282 ⟶ 258:
exit(EXIT_FAILURE);
}
const unsigned short int TYPE = string2FDRtype(STRING)-1;
if (strcasecmp(STRING, "BH") == 0) {
returnTYPE = 0;
} else if (strcasecmp(STRING, "fdr") == 0) {
returnTYPE = 0;
} else if (strcasecmp(STRING, "by") == 0) {
returnTYPE = 1;
} else if (strcasecmp(STRING, "Bonferroni") == 0) {
returnTYPE = 2;
} else if (strcasecmp(STRING, "hochberg") == 0) {
returnTYPE = 3;
} else if (strcasecmp(STRING, "holm") == 0) {
returnTYPE = 4;
} else if (strcasecmp(STRING, "hommel") == 0) {
returnTYPE = 5;
} else {
printf("%s doesn't match any accepted casesFDR types.\n", STRING);
printf("Failed at %s line %u\n", __FILE__, __LINE__);
exit(EXIT_FAILURE);
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------