Getting R, P value, and T Statistic for each coefficient in multiple regression (math.net)

809 views Asked by At

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);

0

There are 0 answers