5

I'm using https://numerics.mathdotnet.com/Regression.html for reference. I attempted to get the r value for each independent variable in my code below but I don't know if this is correct and if this is the correct way to do it, how to also get the p value and T statistic as well.

Here is my current code:

var ema12 = calc.ListCalculationData.Select(i => (double)i.Ema12).ToArray();
var ema26 = calc.ListCalculationData.Select(i => (double)i.Ema26).ToArray();
var ema = calc.ListCalculationData.Select(i => (double)i.Ema).ToArray();
var targetvalue = calc.ListCalculationData.Select(i => (double)i.MRTargetValue).ToArray();
var matrixArray = CreateMatrix.DenseOfColumnArrays(ema12, ema26, ema);
var vectorArray = CreateVector.Dense(targetvalue);
var items = MultipleRegression.QR(matrixArray, vectorArray);
var r1 = GoodnessOfFit.RSquared(ema12, vectorArray);
var r2 = GoodnessOfFit.RSquared(ema26, vectorArray);
var r3 = GoodnessOfFit.RSquared(ema, vectorArray);
  1. Is this the correct way to get R value for each independent variable?
  2. How do I get the P value and T statistic for each independent variable?
  3. Also to check for multicollinearity between 2 independent variables would the code below be correct?

    var multiCol = GoodnessOfFit.RSquared(ema12, ema26);

DarthVegan
  • 1,719
  • 7
  • 25
  • 42
  • This is more of a math, statistic or computer science question. I believe you'll have better luck on https://mathoverflow.net/, https://stats.stackexchange.com/, or https://cs.stackexchange.com/. If you know how to calculate values yourself, just test whether the code is working. – GC_ Sep 18 '17 at 20:35
  • If you lucky, a moderator can transfer your q to another site. – GC_ Sep 18 '17 at 20:36
  • How do I ask a moderator to transfer my question? – DarthVegan Sep 19 '17 at 13:32
  • @GC_ I'm new to statistics so I'm not 100% sure yet if I can calculate these formulas correctly – DarthVegan Sep 19 '17 at 13:33
  • Flag the question, "in need of moderator intervention." – GC_ Nov 02 '17 at 16:25
  • Note: I suspect a lot of people on that site know a bit of code. – GC_ Nov 20 '17 at 14:53

0 Answers0