Created
June 7, 2025 19:46
-
-
Save acbass49/ee421e3bba4276ed24811344e3116f26 to your computer and use it in GitHub Desktop.
11 tithing & income
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pandas as pd | |
| import numpy as np | |
| import survey_tools as st | |
| import scipy as sp | |
| # read in the PRLS | |
| data_prls = pd.read_spss('../data/rls/rls2024.sav') | |
| data_prls['inc'] = data_prls.INC_SDT1.replace({ | |
| 'Less than $30,000': 'Less than 30k', | |
| '$30,000 to less than $40,000': '30k to 50k', | |
| '$40,000 to less than $50,000': '30k to 50k', | |
| '$50,000 to less than $75,000': '50k to 75k', | |
| '$75,000 to less than $100,000': '75k to 100k', | |
| '$100,000 to less than $125,000': '100k to 150k', | |
| '$125,000 to less than $150,000': '100k to 150k', | |
| '$150,000 or more': 'More than 150k', | |
| "DON'T KNOW/REFUSED": np.nan, | |
| }) | |
| data_prls['inc'].cat.set_categories( | |
| ['Less than 30k', '30k to 50k', '50k to 75k', '75k to 100k', '100k to 150k', 'More than 150k'], | |
| inplace=True, | |
| ordered=True | |
| ) | |
| data_prls['attend'] = np.where(data_prls.ATTNDPERRLS.isin(['More than once a week', 'Once a week']), "Weekly", "Less than weekly") | |
| final_df = pd.DataFrame({ | |
| 'income_cat' : data_prls.inc.cat.categories, | |
| 'overall_prls': st.tabs(data_prls,'inc', display='column', wts='WEIGHT').to_list(), | |
| 'mormon_prls': st.tabs(data_prls.query('RELTRAD == "Church of Jesus Christ of Latter-day Saints (Mormon)"'),'inc', display='column').to_list(), | |
| 'mormon_active_prls': st.tabs(data_prls.query('RELTRAD == "Church of Jesus Christ of Latter-day Saints (Mormon)" & attend == "Weekly"'),'inc', display='column').to_list(), | |
| 'mormon_lessactive_prls': st.tabs(data_prls.query('RELTRAD == "Church of Jesus Christ of Latter-day Saints (Mormon)" & attend == "Less than weekly"'),'inc', display='column').to_list(), | |
| 'tithe_payers_2023': [11.7, 9.6, 18.8, 18.3, 23.2, 18.4], #hardcoded from CFLDS | |
| 'non_tithe_payers_2023': [14.5, 16.7, 24, 12.8, 19, 13] #hardcoded from CFLDS | |
| }) | |
| final_df = final_df.set_index('income_cat') | |
| final_df.T.loc[['overall_prls', 'mormon_prls'],:] | |
| # let's do some tests... | |
| # let's test Mormons vs. Overall | |
| sp.stats.ttest_ind( | |
| data_prls[~data_prls.inc.isna()].inc.cat.codes.to_list(), | |
| data_prls.query('RELTRAD == "Church of Jesus Christ of Latter-day Saints (Mormon)" & inc.notna()').inc.cat.codes.to_list(), | |
| ) | |
| sp.stats.mannwhitneyu( | |
| data_prls[~data_prls.inc.isna()].inc.cat.codes.to_list(), | |
| data_prls.query('RELTRAD == "Church of Jesus Christ of Latter-day Saints (Mormon)" & inc.notna()').inc.cat.codes.to_list(), | |
| alternative='two-sided' | |
| ) | |
| # mormons not statistically different from overall | |
| # Now let's test less active vs. active Mormons | |
| sp.stats.ttest_ind( | |
| data_prls.query('RELTRAD == "Church of Jesus Christ of Latter-day Saints (Mormon)" & attend == "Weekly" & inc.notna()').inc.cat.codes.to_list(), | |
| data_prls.query('RELTRAD == "Church of Jesus Christ of Latter-day Saints (Mormon)" & attend == "Less than weekly" & inc.notna()').inc.cat.codes.to_list(), | |
| ) | |
| sp.stats.mannwhitneyu( | |
| data_prls.query('RELTRAD == "Church of Jesus Christ of Latter-day Saints (Mormon)" & attend == "Weekly" & inc.notna()').inc.cat.codes.to_list(), | |
| data_prls.query('RELTRAD == "Church of Jesus Christ of Latter-day Saints (Mormon)" & attend == "Less than weekly" & inc.notna()').inc.cat.codes.to_list(), | |
| alternative='greater' # i expect active Mormons to have higher income | |
| ) | |
| # active Mormons have statistically significantly higher income than less active Mormons | |
| # active Mormons vs. the overall population | |
| sp.stats.ttest_ind( | |
| data_prls.query('RELTRAD == "Church of Jesus Christ of Latter-day Saints (Mormon)" & attend == "Weekly" & inc.notna()').inc.cat.codes.to_list(), | |
| data_prls[~data_prls.inc.isna()].inc.cat.codes.to_list(), | |
| alternative='greater' # i expect active Mormons to have higher income than the overall population | |
| ) | |
| sp.stats.mannwhitneyu( | |
| data_prls.query('RELTRAD == "Church of Jesus Christ of Latter-day Saints (Mormon)" & attend == "Weekly" & inc.notna()').inc.cat.codes.to_list(), | |
| data_prls[~data_prls.inc.isna()].inc.cat.codes.to_list(), | |
| alternative='greater' # i expect active Mormons to have higher income than the overall population | |
| ) | |
| # active Mormons have statistically significantly higher income than the overall population at 90% confidence | |
| # less active Mormons vs. the overall population | |
| sp.stats.ttest_ind( | |
| data_prls.query('RELTRAD == "Church of Jesus Christ of Latter-day Saints (Mormon)" & attend == "Less than weekly" & inc.notna()').inc.cat.codes.to_list(), | |
| data_prls[~data_prls.inc.isna()].inc.cat.codes.to_list(), | |
| alternative='less' | |
| ) | |
| sp.stats.mannwhitneyu( | |
| data_prls.query('RELTRAD == "Church of Jesus Christ of Latter-day Saints (Mormon)" & attend == "Less than weekly" & inc.notna()').inc.cat.codes.to_list(), | |
| data_prls[~data_prls.inc.isna()].inc.cat.codes.to_list(), | |
| alternative='less' # i expect less active Mormons to have higher income than the overall population | |
| ) | |
| # active Mormons have statistically significantly lower income than the overall population |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment