/// <summary> /// Compute the regressors coefficients from MCO /// beta = inv(X'*X)*X'*Y /// </summary> /// <returns> /// beta /// </returns> /// <acknowledgment> /// https://github.com/SarahFrem/AutoRegressive_model_cs/blob/master/RegressionLineaire.cs /// </acknowledgment> public double[,] RegressorsMCO() { var R = RegressionMatrix(); var beta = Operations.Multiply(Operations.Multiply(Operations.Inverse(Operations.Multiply(Operations.Transpose(R), R)), Operations.Transpose(R)), responseVariable); return(beta); }
/// <summary> /// Variances the covariance beta. /// </summary> /// <returns></returns> /// <acknowledgment> /// https://github.com/SarahFrem/AutoRegressive_model_cs/blob/master/RegressionLineaire.cs /// </acknowledgment> public double[,] VarianceCovarianceBeta() { var R = RegressionMatrix(); var var = ResidualVariance(); var res = Operations.Inverse(Operations.Multiply(Operations.Transpose(R), R)); var resRow = res.GetLength(0); var resCol = res.GetLength(1); for (var i = 0; i < resRow; i++) { for (var j = 0; j < resCol; j++) { res[i, j] *= var; } } return(res); }