-
Notifications
You must be signed in to change notification settings - Fork 3
Consistency Rate
Hi All,
I added a function for the consistency rate. I tried to make it really robust but I am a little worried there may be too many options and it may lead to the function breaking in the wild.
At its core, you can supply a data set as well as a column for IDs and Fiscal Years and a consistency rate will be calculated using the range from the fiscal years to define the active window and then just a count of distinct fiscal years for the numerator.
However, based on Sam's comments on our call, I provided an option fro setting the lower bound of the active period to the graduation year.
I also provided an option to hard code the lower and upper bound which I think might be especially useful if you want the upper bound set to the current fiscal year.
I also provided an option to filter based on the length of the active period. I think this will be helpful for removing cases where someone gives their first gift and as a result has a consistency of 100% though that doesn't really mean much so the user can set this threshold to 3 for example so that the defined active period needs to be at least 3 years in length for the constituent to receive a meaningful consistency score.
This worked on the following tests:
ct <- consistency(camp_fund, DONOR_ID, FISCAL_YEAR)
camp_class <- camp_fund %>%
filter(PREF_CLASS_YR > 0)
ct2 <- consistency(camp_class, DONOR_ID, FISCAL_YEAR, alt_year = 'PREF_CLASS_YR')
ct2b <- consistency(camp_class, DONOR_ID, FISCAL_YEAR, alt_year = 'PREF_CLASS_YR', max_year = 2019)
ct3 <- consistency(camp_fund, DONOR_ID, FISCAL_YEAR, alt_year = 2015, max_year = 2019)
In the examples above, I assume that if the user wants to use graduation year that the data set only includes alumni. I haven't built anything to throw a warning if the values are outside some type of range though we could possibly work in something like that.
Let me know if anyone has any additional ideas or feel free to just make edits if you can see a way to improve the code.