<jupyter_start><jupyter_text>PS 3 - Misc Notebook - The Butterfly DiD itHere we do a variant of a key analysis in Wand et al, "The Butterfly Did It"Replication data from here.Loading up the data<jupyter_code>import seaborn as sns
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
plt.style.use('seaborn-whitegrid')
# Loading in the data
florida = pd.read_csv('Abseday.FL2000.tab', sep='\t')
florida<jupyter_output><empty_output><jupyter_text>Computing the same day totals by subtracting Absentee from Total<jupyter_code>florida['SDTotal'] = florida['TotalPresVotes'] - florida['TotalAbsentee']
florida['SDBuchanan'] = florida['TotalBuchanan'] - florida['BuchananAbsentee']<jupyter_output><empty_output><jupyter_text>Separating out PBC from the rest of Florida<jupyter_code>PBC = florida[florida['County']=="Palm Beach"]
noPBC = florida[florida['County']!="Palm Beach"]
PBC
noPBC<jupyter_output><empty_output><jupyter_text>Computing the Buchanan vote share outside PBC for same day ballots...<jupyter_code>BS_SD_noPBC = np.sum(noPBC['SDBuchanan'])/np.sum(noPBC['SDTotal'])
BS_SD_noPBC<jupyter_output><empty_output><jupyter_text>...and absentee<jupyter_code>BS_A_noPBC = np.sum(noPBC['BuchananAbsentee'])/np.sum(noPBC['TotalAbsentee'])
BS_A_noPBC<jupyter_output><empty_output><jupyter_text>And now the difference in Buchanan vote share in Same day vs Absentee for outside PBC<jupyter_code>diff_noPBC = BS_SD_noPBC - BS_A_noPBC
diff_noPBC<jupyter_output><empty_output><jupyter_text>Basically no difference!Now doing the same for PBC<jupyter_code>PBC['County']
BS_SD_PBC = PBC['SDBuchanan']/PBC['SDTotal']
BS_SD_PBC
BS_A_PBC = PBC['BuchananAbsentee']/PBC['TotalAbsentee']
BS_A_PBC
diff_PBC = BS_SD_PBC - BS_A_PBC
diff_PBC<jupyter_output><empty_output><jupyter_text>Here is our Differences in Differences estimate of the causal effect of the butterfly ballot (in vote shares)<jupyter_code>DiD = diff_PBC - diff_noPBC
DiD<jupyter_output><empty_output><jupyter_text>Finally, let's translate this into a causal effect on the number of Buchanan votes: multiplying times the number of same day votes:<jupyter_code>DiD*PBC['SDTotal']
PBC['SDBuchanan']
3310 - DiD*PBC['SDTotal']<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10915651781686965, 'fraction_numerical': 0.0040595399188092015, 'mean_word_length': 8.728070175438596, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '9', 'dir': 'jupyter-structured-clean-dedup', 'id': '277118', 'license': 'MIT', 'n_tokens_mistral': 893, 'n_tokens_neox': 846, 'n_words': 176, 'path': 'PS 3 Misc Notebook - The Butterfly DiD It.ipynb', 'repo_name': 'ds-modules/POLSCI3-FA20', 'size': '2217'}