While writing a JS application for performing a pairwise Tukey test, I encountered an issue with the function jStat.ttest()
I described my experience below.
However, in addition I would very much like to complain here about the lack of sufficient documentation (e.g. in the github of jStat), and anywhere online.
I tried to calculate the p-value, by the means of the function ttest(), like so:
var groupsKey = groups.map(item => item.key);
var groupsValue = groups.map(item => item.value.map(val => parseFloat(val)));
// As you can see, I tried to convert the input data
// Into array with float numbers
// and checked it if everything is correct
console.log(groupsValue[0]);
// I used the nested loop construction for cycling into the groups
for (let i = 0; i < groups.length; i++) {
for (let j = i + 1; j < groups.length; j++) {
//assuming everything is correct, I loaded the input data into the function:
let pValue = jStat.ttest2(groupsValue[i], groupsValue[j], 2);
However, the result was always ‘NaN’
It appears, that the best solution in this case would be to write the function for calculating the p-value from scratch. The other option is to search for other JS library, however, I already am using jStat, and chart.js so I am afraid I will load this project too much.