-
Notifications
You must be signed in to change notification settings - Fork 12
/
minimum_working_example.do
44 lines (31 loc) · 1.07 KB
/
minimum_working_example.do
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
cd ~/Documents/repo/ui_calculator
clear
import delimited "example_annual.csv"
gen weekly_earnings = wage/weeks_worked
foreach quarter of num 1/4 {
gen q`quarter'_weeks = weeks_worked - 52 + 13 * (`quarter')
gen q`quarter' = q`quarter'_weeks * weekly_earnings
replace q`quarter' = 0 if q`quarter'_weeks < 0
replace q`quarter' = 13*weekly_earnings if q`quarter'_weeks > 13
drop q`quarter'_weeks
}
/*
This code loads python and calls the UI calculator from python.
The strings, 'q1', 'q2', 'q3', 'q4' and 'state' should be modified
to reflect the names of the first quarter, second quarter etc variables
and the state of benefits variable. The state should be as a two digit code */
python
from sfi import Data
import pandas as pd
from ui_calculator import calc_weekly_state_quarterly
benefits = calc_weekly_state_quarterly(
Data.get('q1'),
Data.get('q2'),
Data.get('q3'),
Data.get('q4'),
Data.get('state'),
Data.get('weeks_worked'))
Data.addVarDouble('benefits')
Data.store('benefits', None, benefits)
end
su benefits