Skip to content

Commit

Permalink
Merge pull request #22 from ORNL-AMO/jStat
Browse files Browse the repository at this point in the history
J stat
  • Loading branch information
pshires authored Jul 31, 2018
2 parents eda50a1 + 7171dfd commit 5e7d358
Show file tree
Hide file tree
Showing 6 changed files with 821 additions and 834 deletions.
Binary file added SmallerTest.xlsx
Binary file not shown.
Binary file modified TestData.xlsx
Binary file not shown.
6 changes: 5 additions & 1 deletion app/enpi_tool.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// import {findResults} from './app/maths.ts'

d3 = require('d3');
Json2csvParser = require('json2csv').Parser;
converter = require('json-2-csv');
Expand Down Expand Up @@ -1966,9 +1968,11 @@ function exportData(){

//date
export_formatJson[i][outputKeys[0]] = tables[z]["results"][k][outputKeys[0]][i][0];
//pValue for model
//export_formatJson[i]["pValue"] = tables[z]["results"][k]["pValue"][i];

for (var j = 1; j < outputKeys.length; j++) {
if(outputKeys[j] != "comboNumber"){
if(outputKeys[j] != "comboNumber" && outputKeys[j] != "rSquare"){
export_formatJson[i]["(" + dependentNames[z] + ")" + outputKeys[j]] = tables[z]["results"][k][outputKeys[j]][i];
}
}
Expand Down
11 changes: 8 additions & 3 deletions app/maths.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

function getCombinations(array) {
const results = [[]];
for (const value of array) {
Expand Down Expand Up @@ -40,6 +39,8 @@ function findResults(json, dependentNumber){
var col = independentCombinations.length;
var totalResult = [];

var calc = require('./app/regression_calc.js');

for(var i = 0; i < col; i++){
var result = [];
var variables = [];
Expand All @@ -53,9 +54,11 @@ function findResults(json, dependentNumber){
Date: [],
};
results["rSquare"] = [];
results[i + "rSquare"] = [];
results["comboNumber"] = [];
results[i + "Intercept"] = [];
results[i + "fittedModel"] = [];
results[i + "pValue"] = [];

for(var k = 0; k < independentCombinations[i].length; k++){
results[i + independentCombinations[i][k] + "Coeff"] = [];
Expand All @@ -71,17 +74,19 @@ function findResults(json, dependentNumber){
independentVariables[k] = json.independent[independentCombinations[i][k]].slice(j, j + 12);
independentNames[k] = independentCombinations[i][k];
}
var model = calc3(5, dependent, independentVariables, independentNames);
var model = calc.calc3(5, dependent, independentVariables, independentNames);

results.Date[j] = json.date[dateKeys[0]][j];

results["rSquare"][j] = model.rSquare;
results[i + "rSquare"][j] = model.rSquare;
results["comboNumber"][j] = i;
results[i + "Intercept"][j] = model.intercept;
results[i + "pValue"][j] = model.pValue;

for(var n = 0; n < independentCombinations[i].length; n++){
results[i + independentCombinations[i][n] + "Coeff"][j] = model.params[n];
results[i + independentCombinations[i][n] + "pvalue"][j] = "p Value of " + independentCombinations[i][n];
results[i + independentCombinations[i][n] + "pvalue"][j] = model.coeffPVals[n];
}

results[i + "fittedModel"][j] = model.fittedModel;
Expand Down
Loading

0 comments on commit 5e7d358

Please sign in to comment.