コード例 #1
0
        public static double[] StandardError([NotNull][ItemNotNull] this double[][] design, [NotNull] double[] squaredErrors, StandardErrorType heteroscedasticityConsistent)
        {
            if (design is null)
            {
                throw new ArgumentNullException(nameof(design));
            }
            if (squaredErrors is null)
            {
                throw new ArgumentNullException(nameof(squaredErrors));
            }
            if (design.Length != squaredErrors.Length)
            {
                throw new ArrayConformabilityException <double>(design, squaredErrors);
            }

            double[][] covariance = design.Covariance(squaredErrors, heteroscedasticityConsistent);

            double[] result = new double[covariance.Length];

            for (int i = 0; i < result.Length; i++)
            {
                result[i] = Math.Sqrt(covariance[i][i]);
            }

            return(result);
        }
コード例 #2
0
 public StandardError(string screen_message, StandardErrorType type)
 {
     this.screen_message      = screen_message;
     this.screen_error        = type;
     this.screen_error_string = this.screen_error.ToString();
 }
コード例 #3
0
        public static double[][] Covariance([NotNull][ItemNotNull] this double[][] design, [NotNull] double[] squaredErrors, StandardErrorType heteroscedasticityConsistent)
        {
            if (design is null)
            {
                throw new ArgumentNullException(nameof(design));
            }
            if (squaredErrors is null)
            {
                throw new ArgumentNullException(nameof(squaredErrors));
            }
            if (design.Length != squaredErrors.Length || design.Length == 0)
            {
                throw new ArrayConformabilityException <double>(design, squaredErrors);
            }

            switch (heteroscedasticityConsistent)
            {
            case StandardErrorType.HC0:
            {
                return(design.Covariance(squaredErrors, 1.0));
            }

            case StandardErrorType.HC1:
            {
                return(design.Covariance(squaredErrors, (double)design.Length / (design.Length - design[0].Length)));
            }

            case StandardErrorType.Ols:
            {
                return(design.Covariance(squaredErrors));
            }

            default:
            {
                throw new ArgumentException(nameof(StandardErrorType));
            }
            }
        }