Exemple #1
0
        public string ToReport(string dv, string filter)
        {
            Console.WriteLine($"Filter by: {filter}");
            var regex = new Regex(filter, RegexOptions.IgnoreCase);

            var result = new StringBuilder($"Name:{dv}Independent(X){dv}vs Dependent(Y){dv}Correlation{dv}MeanX{dv}Slope\n");

            if (dv.Equals("|"))
            {
                result.Append(IntelCore.WriteDivider(Regex.Matches(result.ToString(), @"\|").Count) + "\n");
            }

            foreach (var item in Stats.OrderByDescending(r => r.Value.Correlation()))
            {
                var xyNames = IntelCore.GetNames(item.Key.Split('_'));
                var stat    = item.Value;

                if (regex.IsMatch(item.Key))
                {
                    result.Append(
                        $"{item.Key}:{dv}{xyNames[0]}{dv}vs {xyNames[1]}{dv}{stat.Correlation():F3}{dv}{stat.MeanX():F1}{dv}{stat.Slope():F5} {IntelCore.GetXyUnits(item.Key)}\n");
                }
            }

            return(result.ToString());
        }
Exemple #2
0
        /// <summary>
        /// </summary>
        /// <param name="dv"></param>
        /// <param name="gdpAbove"></param>
        /// <param name="gdpBelow"></param>
        /// <returns></returns>
        public string ToReport(string dv, double gdpAbove, double gdpBelow)
        {
            var result = new StringBuilder($"Name:{dv}Independent(X){dv}vs Dependent(Y){dv}Correlation{dv}MeanX{dv}Slope\n");

            if (dv.Equals("|"))
            {
                result.Append(IntelCore.WriteDivider(Regex.Matches(result.ToString(), @"\|").Count) + "\n");
            }

            foreach (var item in Stats.OrderByDescending(r => r.Value.Correlation()))
            {
                var xyNames = IntelCore.GetNames(item.Key.Split('_'));

                var stat = item.Value;
                if (item.Value.Correlation() > gdpAbove || item.Value.Correlation() < gdpBelow)
                {
                    result.Append(
                        $"{item.Key}:{dv}{xyNames[0]}{dv}vs {xyNames[1]}{dv}{stat.Correlation():F3}{dv}{stat.MeanX():F1}{dv}{stat.Slope():F3} {IntelCore.GetXyUnits(item.Key)}\n");
                }
            }

            return(result.ToString());
        }
Exemple #3
0
        /// <summary>
        /// </summary>
        /// <param name="c"></param>
        public void AddCrossTableRegressions(Country c)
        {
            IDictionary <string, int> exclude = new Dictionary <string, int>();

            var x = IntelCore.ColumnConfigs.Keys.ToArray();

            for (var a = 0; a < x.Length; a++)
            {
                for (var b = 0; b < x.Length; b++)
                {
                    if (a != b)
                    {
                        var statName = $"{x[a]}_{x[b]}";
                        var reverse  = $"{x[b]}_{x[a]}";

                        if (!exclude.ContainsKey(statName))
                        {
                            var m = IntelCore.XValue(x[a], c);
                            var n = IntelCore.XValue(x[b], c);

                            if (!Stats.ContainsKey(statName))
                            {
                                Stats.Add(statName, new Statistic());
                            }
                            //Console.WriteLine($"AddStat: {statName}");

                            if (!(m is double.NaN || n is double.NaN))
                            {
                                Stats[statName].Add(m, n);
                            }

                            exclude.Add(reverse, 0);
                        }
                    }
                }
            }
        }
Exemple #4
0
        public double Stand(string statName, Country c)
        {
            var xy = statName.Split('_');

            return(Stand(statName, IntelCore.XValue(xy[0], c), IntelCore.XValue(xy[1], c)));
        }