-
Notifications
You must be signed in to change notification settings - Fork 240
Expand file tree
/
Copy pathabortion_ddd2.py
More file actions
30 lines (24 loc) · 868 Bytes
/
Copy pathabortion_ddd2.py
File metadata and controls
30 lines (24 loc) · 868 Bytes
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
import numpy as np
import pandas as pd
import statsmodels.api as sm
import statsmodels.formula.api as smf
from itertools import combinations
import plotnine as p
# read data
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
def read_data(file):
return pd.read_stata("https://github.com/scunning1975/mixtape/raw/master/" + file)
abortion = read_data('abortion.dta')
abortion = abortion[~pd.isnull(abortion.lnr)]
abortion_filt = abortion[(abortion.race == 2) & (abortion.sex == 2) & (abortion.age == 20)]
regdd = (
smf
.wls("""lnr ~ C(repeal)*C(year) + C(fip) + acc + ir + pi + alcohol+ crack + poverty+ income+ ur""",
data=abortion_filt, weights=abortion_filt.totpop.values)
.fit(
cov_type='cluster',
cov_kwds={'groups': abortion_filt.fip.values},
method='pinv')
)
regdd.summary()