Exemplo n.º 1
0
        private double CalculateNumeratorFor(Person p)
        {
            int result = 0;

            foreach (int year in p.GetPovertyYears())
            {
                result += (year - minYear) + 1;
            }

            return (double) result;
        }
Exemplo n.º 2
0
        public SequenceEffect CalculateFor(Person p)
        {
            var result = new SequenceEffect();

            var numerator = CalculateNumeratorFor(p);

            result.V1 = numerator.S1.Value / denominator1;
            result.V2 = numerator.S2.Value / denominator1;
            result.V3 = numerator.S3.Value / denominator2;
            result.V4 = numerator.S4.Value / denominator2;
            result.V5 = numerator.S5.Value / denominator2;

            return result;
        }
Exemplo n.º 3
0
        public Person CreateInstance(Observation observation)
        {
            int id = idMap.GetIdFor(observation);

            if (peopleCache.ContainsKey(id))
            {
                return peopleCache[id];
            }
            else
            {
                string country = observation.Country;
                string personId = observation.PersonId;
                Person person = new Person(country, personId);
                peopleCache[id] = person;
                return person;
            }
        }
Exemplo n.º 4
0
        private Numerator CalculateNumeratorFor(Person p)
        {
            var povertyYears = p.GetPovertyYears();

            int numPovertyYears = povertyYears.Count;

            if (numPovertyYears == 0)
                return Numerator.Zero; ;

            if (numPovertyYears == 1)
                return Numerator.Create(p.GetPovertyGapForYear(povertyYears[0]));

            var result = new Numerator();

            for (int n = 0; n < numPovertyYears - 1; n++)
            {
                for (int m = n+1; m < numPovertyYears; m++)
                {
                    int lowYear = povertyYears[n];
                    int highYear = povertyYears[m];
                    int i = (highYear - minYear) + 1;
                    int j = (lowYear - minYear) + 1;

                    double Oij = p.GetNonPovertyYearsBetween(lowYear, highYear);
                    double Wij = p.GetPovertyGapAverage(lowYear, highYear);
                    double Pij = GetPovertyPersistenceRatioValue(p.Country, lowYear, highYear);

                    // double term = (Math.Pow((i - j + 1), -(Pij * (Oij + 1)))) * Wij;

                    result.S1.Terms.Add(Wij * Math.Pow((i - j + 1), -(Pij * (Oij + 1))));
                    result.S2.Terms.Add(Math.Pow((i - j + 1), -(Pij * (Oij + 1))));
                    result.S3.Terms.Add(Wij * Math.Pow((i - j + 1), -(Oij+1)));
                    result.S4.Terms.Add(Wij * Math.Pow((i - j + 1) , -1.0));
                    result.S5.Terms.Add(Math.Pow((i - j + 1), -1.0));
                }
            }

            return result;
        }
Exemplo n.º 5
0
        private void ValidatePerson(Person p)
        {
            if (p.MinYear != yearMin)
            {
                AddError(string.Format("{0}: first observation year does not correspond to first year for panel",
                    GetIdStringFor(p)));
            }

            if (p.MaxYear != yearMax)
            {
                AddError(string.Format("{0}: last observation year does not correspond to last year for panel",
                    GetIdStringFor(p)));
            }

            if (p.ObservationCount != yearSpan)
            {
                AddError(string.Format("{0}: observations do not cover the entire span",
                    GetIdStringFor(p)));
            }
        }
Exemplo n.º 6
0
 private SequenceEffect GetSequenceEffect(Person p)
 {
     return sequenceEffects[p];
 }
Exemplo n.º 7
0
 private double GetEmergencyEffect(Person p)
 {
     return emergencyEffects[p];
 }
Exemplo n.º 8
0
 private static string GetIdStringFor(Person p)
 {
     return string.Format("({0}, {1})", p.Country, p.PersonId);
 }
Exemplo n.º 9
0
 public double CalculateFor(Person p)
 {
     return CalculateNumeratorFor(p) / denominator;
 }