Joseph Spada commited on
Commit
9f04c37
·
1 Parent(s): 25415d0

added revenues slider, not functional yet

Browse files
Files changed (1) hide show
  1. app.py +20 -5
app.py CHANGED
@@ -33,17 +33,20 @@ print(data)
33
 
34
  # %%
35
  baseline_interest_rate = 3.67
 
36
 
37
- def plot_interest_coverage(interest_rate):
38
 
39
  # calculate the yearly increase in the interest rate based on the projected interest rate in 2054
40
- yearly_increase = (interest_rate - baseline_interest_rate) / (2054 - 2025) / 100
 
 
41
 
42
  # add a projected average rate on federal debt column
43
  data["Average Rate on Federal Debt (Projected)"] = np.where(
44
  data["Year"].astype(int) < 2026,
45
  data["Average Rate on Federal Debt"],
46
- data["Average Rate on Federal Debt"] + (yearly_increase * (data["Year"].astype(int) - 2025)))
47
 
48
  # add a projected interest / revenues column
49
  data["Net Interest / Revenues (Projected)"] = np.where(
@@ -123,11 +126,14 @@ def plot_interest_coverage(interest_rate):
123
  interest_rate_lowerbound = 0
124
  interest_rate_upperbound = 15
125
 
 
 
 
126
  with gr.Blocks() as interface:
127
  # Create the image output
128
- graph = gr.Image(type="filepath", label = "Graph", value = plot_interest_coverage(baseline_interest_rate))
129
 
130
- # Create the slider input below the image
131
  interest_rate_slider = gr.Slider(
132
  interest_rate_lowerbound,
133
  interest_rate_upperbound,
@@ -136,6 +142,15 @@ with gr.Blocks() as interface:
136
  label = "2054 Projected Average Interest Rate on Federal Debt"
137
  )
138
 
 
 
 
 
 
 
 
 
 
139
  gr.Markdown('<p style="font-size:11px;">Source: CBO June 2024 An Update to the Budget and Economic Outlook: 2024 to 2034, March 2024 report The Long-Term Budget Outlook: 2024 to 2054, and author\'s calculations. Scenario of higher interest rate is author\'s calculations. Data points for 2035-2054 calculated to build on CBO\'s June 2024 10-year update and be consistent with the March 2024 long-term report. Historical Social Security OASDI payroll tax revenue from Table 4-3 of the SSA\'s Trust Fund Data, and projections from the CBO\'s August 2024 Long Term Projections for Social Security.</p>')
140
 
141
  # Set up an action that updates the graph when the slider value changes
 
33
 
34
  # %%
35
  baseline_interest_rate = 3.67
36
+ baseline_revenues = 15928.73
37
 
38
+ def plot_interest_coverage(interest_rate, revenues):
39
 
40
  # calculate the yearly increase in the interest rate based on the projected interest rate in 2054
41
+ interest_rate_yearly_increase = (interest_rate - baseline_interest_rate) / (2054 - 2025) / 100
42
+ # calculate the yearly increase in revenues based on the projected interest rate in 2054
43
+ revenues_yearly_increase = (revenues - baseline_revenues) / (2054 - 2025)
44
 
45
  # add a projected average rate on federal debt column
46
  data["Average Rate on Federal Debt (Projected)"] = np.where(
47
  data["Year"].astype(int) < 2026,
48
  data["Average Rate on Federal Debt"],
49
+ data["Average Rate on Federal Debt"] + (interest_rate_yearly_increase * (data["Year"].astype(int) - 2025)))
50
 
51
  # add a projected interest / revenues column
52
  data["Net Interest / Revenues (Projected)"] = np.where(
 
126
  interest_rate_lowerbound = 0
127
  interest_rate_upperbound = 15
128
 
129
+ revenues_lower_bound = 10000
130
+ revenues_upper_bound = 20000
131
+
132
  with gr.Blocks() as interface:
133
  # Create the image output
134
+ graph = gr.Image(type="filepath", label = "Graph", value = plot_interest_coverage(baseline_interest_rate, baseline_revenues))
135
 
136
+ # Create the slider input below the image for projected interest rate
137
  interest_rate_slider = gr.Slider(
138
  interest_rate_lowerbound,
139
  interest_rate_upperbound,
 
142
  label = "2054 Projected Average Interest Rate on Federal Debt"
143
  )
144
 
145
+ # Create the slider input below the image for projected revenues
146
+ interest_rate_slider = gr.Slider(
147
+ revenues_lower_bound,
148
+ revenues_upper_bound,
149
+ step = 500,
150
+ value = baseline_revenues,
151
+ label = "2054 Projected Revenues ($B)"
152
+ )
153
+
154
  gr.Markdown('<p style="font-size:11px;">Source: CBO June 2024 An Update to the Budget and Economic Outlook: 2024 to 2034, March 2024 report The Long-Term Budget Outlook: 2024 to 2054, and author\'s calculations. Scenario of higher interest rate is author\'s calculations. Data points for 2035-2054 calculated to build on CBO\'s June 2024 10-year update and be consistent with the March 2024 long-term report. Historical Social Security OASDI payroll tax revenue from Table 4-3 of the SSA\'s Trust Fund Data, and projections from the CBO\'s August 2024 Long Term Projections for Social Security.</p>')
155
 
156
  # Set up an action that updates the graph when the slider value changes