Standard error calculation using Crossfilter reductio plugin?
Is there any way to implement standard error in cross filter reductio plugin. I will get all the values on measures of central tendency except {SE}
Any helps appriaticated..
var CFX = crossfilter([
{ foo: 'one', bar: 1 },
{ foo: 'two', bar: 2 },
{ foo: 'three', bar: 3 },
{ foo: 'one', bar: 4 },
{ foo: 'one', bar: 5 },
{ foo: 'two', bar: 6 },
]);
var fooDim = CFX.dimension(function(k){ return k.foo; });
var fooGrp = fooDim.group();
var stdDeviation = reductio()
.sumOfSq(function(d) { return d.bar; })
.sum(function(d) { return d.bar; })
.avg(true)
.count(true)
.std(true)
// How to implement Standard error
stdDeviation(fooGrp);
console.log('Standard Deviation:-',JSON.stringify(fooGrp.top(Infinity)) );
<script src="https://cdn.rawgit.com/crossfilter/reductio/0.5.4/reductio.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/crossfilter/1.3.12/crossfilter.min.js"></script>
Averages and average-like-things like standard error should probably be calculated at display-time instead of in reducers. Reductio provides an average calculation because so many people expect it, but it is really much better to just maintain the count and sum in the reducer and calculate the average at time of display.
I think the same goes for standard error. You will usually just calculate the standard error for a group when you want to show it by dividing the standard deviation ( reductio.std
) by the square root of the count.