Пример #1
0
        /// <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);
        }
Пример #2
0
        /// <summary>
        /// Residuals the variance.
        /// </summary>
        /// <returns></returns>
        /// <acknowledgment>
        /// https://github.com/SarahFrem/AutoRegressive_model_cs/blob/master/RegressionLineaire.cs
        /// </acknowledgment>
        public double ResidualVariance()
        {
            var E    = Errors();
            var var  = Operations.Multiply(Operations.Transpose(E), E);
            var size = (double)E.GetLength(0);

            return(var[0, 0] / size);
        }
Пример #3
0
        /// <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);
        }
Пример #4
0
 /// <summary>
 /// Predictionses this instance.
 /// </summary>
 /// <returns></returns>
 /// <acknowledgment>
 /// https://github.com/SarahFrem/AutoRegressive_model_cs/blob/master/RegressionLineaire.cs
 /// </acknowledgment>
 public double[,] Predictions() => Operations.Multiply(RegressionMatrix(), RegressorsMCO());