-1

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.ttest(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.

2
  • Are you sure ttest2() exists? The documentation only mentions ttest. Also, what values are you using? Commented Jan 24 at 12:54
  • Yes, I tried both ttest() and ttest2(). I will correct this. Moreover, there are at least three functions by the name ttest() with different inputs. But I do not know how to use them, since the documentation is insufficient. Commented Jan 24 at 13:03

1 Answer 1

0

A working solution by the means of the jStat library can look like this:

let pValue = jStat.tukeyhsd(groupsValue[count]);

gives all p-values for the combinations between every experimental variant.

The input for this function groupsValue is a 2D array, containing the repetitions of every experimental variant (not the combinations between them, but only the groups).

Here is other demonstration, from the documentation of jStat:

> jStat.tukeyhsd([[1, 2], [3, 4, 5], [6], [7, 8]])
[ [ [ 0, 1 ], 0.10745283896120883 ],
  [ [ 0, 2 ], 0.04374051946838586 ],
  [ [ 0, 3 ], 0.007850804224287633 ],
  [ [ 1, 2 ], 0.32191548545694226 ],
  [ [ 1, 3 ], 0.03802747415485819 ],
  [ [ 2, 3 ], 0.5528665999257486 ] ]

the last number on each row is the p-value (for the combination of two of these groups).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.