private double CalculateNumeratorFor(Person p)
        {
            int result = 0;

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

            return (double)result;
        }
        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;
        }
        public Person CreateInstance(Observation observation)
        {
            string key = GetPersonKeyFor(observation);

            if (peopleCache.ContainsKey(key)) {
                return peopleCache[key];
            }
            else {
                string country = observation.Country;
                string personId = observation.PersonId;
                Person person = new Person(country, personId);
                peopleCache[key] = person;
                return person;
            }
        }
        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;
        }
Beispiel #5
0
        private void Validate(Person p)
        {
            if (p.MaxYear != YearMax) {
                string errorMessage = string.Format("Person ({0}, {1}): observations do not extend to {2} ", p.PersonId, p.Country, YearMax);
                AddError(errorMessage);
            }

            if (p.ObservationsMissingInYearSpan) {
                string errorMessage = string.Format("Person ({0}, {1}): observations do not cover entire personal span", p.PersonId, p.Country);
                AddError(errorMessage);
            }
        }
 public double CalculateFor(Person p)
 {
     return CalculateNumeratorFor(p) / denominator;
 }
Beispiel #7
0
 private SequenceEffect GetSequenceEffect(Person p)
 {
     return sequenceEffects[p];
 }
Beispiel #8
0
        private void ValidatePerson(Person p)
        {
            if (p.MinYear != yearMin) {
                AddError(string.Format("Panel_{0}: person {1}: first observation year does not correspond to first year for panel",
                    yearSpan,
                    GetIdStringFor(p)));
            }

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

            if (p.ObservationCount != yearSpan) {
                AddError(string.Format("Panel_{0}: person {1}: observations do not cover the entire span",
                    yearSpan,
                    GetIdStringFor(p)));
            }
        }
Beispiel #9
0
 private double GetEmergencyEffect(Person p)
 {
     return emergencyEffects[p];
 }
Beispiel #10
0
 private double GetDecayFactor(Person p)
 {
     return decayFactors[p];
 }
Beispiel #11
0
 private double GetBossetIndex(Person p)
 {
     return bossertIndexes[p];
 }
Beispiel #12
0
 private double GetBCD2Index(Person p)
 {
     return bcd2Indexes[p];
 }
Beispiel #13
0
 private static string GetIdStringFor(Person p)
 {
     return string.Format("({0}, {1})", p.Country, p.PersonId);
 }