<jupyter_start><jupyter_text>Incumbency Advantage and Community Radio in BrazilIn Brazil, elected leaders are able to control approval for community radio stations. As a major source of news for Brazilian citizens, these radio stations provide a pivotal role in informing the public. This paper identifies both the causal effect of incumbency on politicians’ ability to control the media and the causal effect of media control on their future electoral prospects. To begin, let's load in the data<jupyter_code>import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
radio_df = pd.read_csv('data/applied_data.csv')
radio_df.head()<jupyter_output><empty_output><jupyter_text>This table contains several variables of interest, as well as many descriptive values.   | Variable | Meaning       ||--------|------------------------|| muni    | Municipality Name| name  | politician name|| party   | political party acronym               || votes     | total number of votes         || raw.vote.margin     | the margin of votes that the candidate won or lost by         |  | post.approved     | whether the candidate's radio application was approved following the election      |  | elected_bool    | whether the candidate won the election       |   We're specifically curious about close elections: if the election is close, then we can assume that external factors are relatively similar. In the following cell, set `within_250` equal to the condition that the absolute vote margin is less than 250 votes.<jupyter_code>within_250 = abs(radio_df['raw.vote.margin'])<250<jupyter_output><empty_output><jupyter_text>Great! Now, we want to plot the relationship between vote margin and the approval of a candidate's radio application after the election. In the following cell, plot the relationship under the additional condition that the candidate won the election. The plot for when the candidate did not win is filled out for you.<jupyter_code>unelected_data = radio_df[within_250 & (~radio_df['elected'].astype(bool))]
sns.regplot(x='raw.vote.margin',y='post.approved', 
            data=unelected_data, x_ci=None, 
            order=3, x_bins=15)

elected_data = radio_df[within_250 & radio_df['elected'].astype(bool)]
sns.regplot(x='raw.vote.margin',y='post.approved', 
            data=elected_data, x_ci=None, 
            order=3, x_bins=15)
plt.ylim(0,.5)
plt.ylabel('Application Approved After Election')
plt.xlabel('Vote Margin')
plt.title('Application Approved After Election')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08785120696478037, 'fraction_numerical': 0.010288880094974277, 'mean_word_length': 4.233954451345756, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 13, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '653402', 'license': 'MIT', 'n_tokens_mistral': 716, 'n_tokens_neox': 659, 'n_words': 267, 'path': 'lab/lab11/Brazilian Media Control.ipynb', 'repo_name': 'ds-modules/PS-88-21-DEV', 'size': '2527'}