Skip to content

Commit babf992

Browse files
committed
add generated ANCOVA dataset + added to tests
1 parent 047dcbf commit babf992

File tree

4 files changed

+224
-1
lines changed

4 files changed

+224
-1
lines changed

causalpy/data/ancova_generated.csv

Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
group,pre,post
2+
1,12.264858355350702,14.642281485826853
3+
0,9.927449994409082,10.247109509774678
4+
1,11.143182680959526,13.208891968269526
5+
1,11.581027267217818,13.176653832648514
6+
0,10.212011893570054,9.588953081804807
7+
0,10.099040162649114,10.485018086502661
8+
0,9.848261857556366,10.17443467781112
9+
0,11.248891593197538,11.44914346555337
10+
0,9.988520810244031,9.982947871444773
11+
1,11.617199990961508,13.968112204434641
12+
1,11.357258461761651,13.086386661748689
13+
1,11.443642992680244,14.117123920581372
14+
1,12.418698299591519,14.556239848432652
15+
1,11.08695058268037,13.75020247980409
16+
1,11.903073922037589,14.37467647038186
17+
0,8.259941992017877,8.24264463958351
18+
1,11.260206775093495,13.38839323219005
19+
0,8.84328240290688,8.991555943487812
20+
1,12.833944746113795,14.237136574260715
21+
0,8.243694198122864,8.167157809735029
22+
0,9.549873086453907,9.482137435602832
23+
0,7.835284682165309,7.612336136673208
24+
1,12.88752541631879,14.20156778126195
25+
0,9.292511464335078,9.523798988308581
26+
0,6.719488929307644,6.828074824534081
27+
0,12.034900617958858,11.972499594137854
28+
1,12.8017475187411,15.201569801046992
29+
1,11.192165456103698,12.538373263956393
30+
0,9.218026719316452,9.030263180794165
31+
0,9.794321887202216,10.198486677176872
32+
1,11.20016101928247,12.824166571584524
33+
1,11.810122517971482,14.126998873357666
34+
1,12.113003771192073,14.036824795467137
35+
0,9.853702428392674,10.134049576701152
36+
1,11.581812146609074,13.07485589712462
37+
0,11.44840652163122,11.69112926558477
38+
0,9.349158155658037,9.500824731689992
39+
1,12.307317701635883,14.032196697704606
40+
1,11.521163845772623,13.538391033781803
41+
0,10.009662624335466,9.887190209442021
42+
0,9.033281858777084,9.338886734860036
43+
1,11.807639539107594,13.685887202945342
44+
1,12.261871954119055,14.28611940629696
45+
1,11.689690609394821,13.76124483586917
46+
0,8.911128292748554,8.993488979563084
47+
1,13.986389194790188,15.995992132088245
48+
1,11.45153204238965,14.049822896509092
49+
0,10.627081564978075,11.355650937465569
50+
1,11.480296147929169,13.20034610034534
51+
0,10.58098947444771,10.206358987350022
52+
1,11.648239555454863,14.089331157975257
53+
0,10.981675527174431,11.055058766740057
54+
0,10.50965455054716,11.04747252077189
55+
0,10.625315126287015,10.318955841019823
56+
1,11.554557224238774,12.85449149777984
57+
0,10.900812128840057,11.6259543261164
58+
1,11.854010777811842,13.489847911072802
59+
1,12.817650208204363,14.870388232209867
60+
1,10.848033033225063,12.839913751596841
61+
0,10.966934906053474,10.813747590173843
62+
0,10.520610302205263,10.796120263549959
63+
0,10.809431727759202,11.12251292573233
64+
1,12.317390921086742,14.945538687160642
65+
0,9.030030538887935,9.561708783696691
66+
0,9.693392158056453,10.018650351124018
67+
0,9.76386068297627,9.688878210224578
68+
0,9.467777687386512,9.344090442163484
69+
1,10.904517888189673,12.297713114527422
70+
1,11.905084055656603,13.759863062869309
71+
0,6.369206844201461,5.77845021451916
72+
0,8.894134569538416,8.254637265417841
73+
0,9.594751482931796,10.118800810581622
74+
1,12.058985852615915,14.667351520008605
75+
0,10.238595428637137,10.791232399316057
76+
1,12.158784012936945,14.054015730061467
77+
0,9.814345081491227,10.601782581217433
78+
1,12.141122803262492,14.656980603576939
79+
0,9.227043335151656,9.426941715795842
80+
0,9.903178883200862,8.765326384529072
81+
0,10.126966921640609,9.489665602782823
82+
1,11.13588268952632,12.876322536297383
83+
1,11.300107989923264,13.327382871088595
84+
1,13.272978942338987,15.585840771500374
85+
0,9.14906665334288,9.296816374189518
86+
1,13.393604977690963,14.675487876788951
87+
0,9.192828412985934,9.379279238594563
88+
0,9.373788708805776,9.478494343512358
89+
0,10.373292219777179,10.559437714400707
90+
1,11.961585386183025,13.833246351271987
91+
1,11.570707466740528,13.680172672911127
92+
1,13.567812559913143,15.135868319389388
93+
0,9.786454645494572,9.580975708036352
94+
1,12.212608107180793,13.694232107313065
95+
0,9.397077261006636,9.401053454968341
96+
1,10.989718910446546,12.231612211172177
97+
0,10.179643430531856,10.187005861094837
98+
0,10.661614250233816,10.450741283835002
99+
1,12.517893975625041,14.242553055257599
100+
0,8.186534061787329,7.769197674208002
101+
0,8.430748557999433,8.105732205758365
102+
0,9.948912626255728,9.990095979646151
103+
1,11.119208147257408,13.448160765847305
104+
0,10.116844072623824,10.044463935297504
105+
1,13.20734255110846,14.715956833385809
106+
0,10.058816735912718,9.568920513635073
107+
1,13.399131461277102,15.898598531725778
108+
0,9.183861278717954,9.05817250218202
109+
1,12.93215649379921,15.201097651149194
110+
1,11.247780032965364,13.31728117568601
111+
0,9.474570753816382,9.321507957947217
112+
0,11.029863789865384,10.617870761906703
113+
1,10.612534743385979,12.21293067230243
114+
0,8.162204171003342,8.161557410890328
115+
0,8.364184228934858,8.027395466630457
116+
1,13.231498472533868,15.460289619087318
117+
1,11.495426056170695,13.389206276180522
118+
1,13.597246796764637,16.25253360430974
119+
0,10.715558413738783,11.292696744480372
120+
1,11.373960868330322,12.840506571893563
121+
1,11.860168962863618,13.23180940040767
122+
1,12.155085338079964,14.011800436576367
123+
1,12.461259000750996,13.613506772155183
124+
0,10.640933127724542,10.775297359456811
125+
0,9.667968556475836,9.50939678375694
126+
0,10.294149423598189,10.196766564686822
127+
0,11.933900610983688,12.086776790684851
128+
0,9.872039239445167,10.160105674157954
129+
1,13.033479847041354,14.854905709755855
130+
1,12.026629349841249,13.552620635900984
131+
1,11.879439414827207,13.150523728615966
132+
0,9.566686505463542,9.704222475950209
133+
0,10.854664037419726,11.38175393879568
134+
1,11.098046113824383,12.62787100050706
135+
0,9.782165369675669,9.499915875474162
136+
1,10.946363184143978,12.839913823256849
137+
1,12.499486260308794,14.659496064291226
138+
1,10.993681063536865,12.232856790327482
139+
1,12.14072997893197,13.520399299749684
140+
1,12.741360844286929,14.093733041578513
141+
0,9.211192222054821,9.383914042257693
142+
1,13.913764933576681,15.90230836727072
143+
0,9.549618940826129,9.550021154993763
144+
0,10.900557041510229,11.004982845659425
145+
1,10.78976082147783,12.258212585685055
146+
0,9.610091590761158,9.288806688882772
147+
1,12.87082164331867,14.855594819083063
148+
1,13.226763655568835,14.741675343660166
149+
1,10.509134781612119,12.278683775650363
150+
0,9.392946687346507,9.251414329990293
151+
1,11.654899514693925,13.66826270458631
152+
1,12.345996772351288,13.908552145921075
153+
0,8.936573461339567,8.263868160092676
154+
1,13.444517967913384,15.155337552450447
155+
0,8.88648505864527,9.277111903412615
156+
1,11.143959465125791,13.464548955240314
157+
1,12.440516168823322,13.752017958160309
158+
0,10.56959536418749,9.993594680331267
159+
1,12.362879640914342,14.425151735546999
160+
1,14.754321117020414,16.66185852912643
161+
0,8.748985743665008,9.090324460954626
162+
1,12.116637901385804,13.890990060165413
163+
0,11.310129837671347,11.815079555186793
164+
0,9.056724450312705,8.908699440692132
165+
1,10.6713558110713,13.27267710957835
166+
1,11.768996408549217,13.609890869812782
167+
1,10.987663898349393,12.959770406961267
168+
0,9.271347690394514,8.972284210261076
169+
1,13.41062647812046,15.643150501577235
170+
1,12.080925001031122,13.969090283189457
171+
1,12.131309628632286,14.081290096923862
172+
0,9.148662952434565,9.959056582869447
173+
1,11.659141704267826,13.288607339068161
174+
1,13.730246049103854,16.332346664778708
175+
0,10.493705379414665,10.29265378097157
176+
0,9.61510292897469,10.005525775760427
177+
1,12.097005139591186,13.55533637332416
178+
0,9.70061849575247,10.161630504822973
179+
0,9.457096609096899,10.010365868615919
180+
0,10.677322714363163,10.80760495984205
181+
1,10.513325497923493,12.126984080601527
182+
1,12.062551901708142,14.712645533163277
183+
1,13.33252423398856,14.837332146889565
184+
1,13.953036672884672,16.20436478075008
185+
1,12.343834047799021,14.278233304758707
186+
0,9.730658103486451,9.471795169542592
187+
0,11.980654709795681,11.831425438132943
188+
1,12.663214987320673,14.739223146205598
189+
0,9.489950507583748,8.893683024254251
190+
1,10.33133189064659,12.532810875624302
191+
0,11.691805096688345,11.945931314422928
192+
1,11.714517371918909,13.468702907081228
193+
1,11.96599263232672,13.936729757214527
194+
1,14.185092904808357,15.587409097367365
195+
0,9.782312952391104,9.299757499093808
196+
0,10.79382217804355,11.450147359966014
197+
0,9.939731553868997,9.876398697296123
198+
0,9.064563009578302,9.19012720728962
199+
0,12.342369459765722,12.215277731909632
200+
1,11.721192710169209,13.235723336589501
201+
0,10.5218333495686,10.177956671617448

causalpy/data/datasets.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"its simple": {"filename": "its_simple.csv"},
1515
"rd": {"filename": "regression_discontinuity.csv"},
1616
"sc": {"filename": "synthetic_control.csv"},
17+
"anova1": {"filename": "ancova_generated.csv"},
1718
}
1819

1920

causalpy/data/simulate_data.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,3 +210,13 @@ def impact(x):
210210
y = np.sin(x * 3) + impact(x) + norm.rvs(scale=0.1, size=N)
211211

212212
return pd.DataFrame({"x": x, "y": y, "treated": is_treated(x)})
213+
214+
215+
def generate_ancova_data(
216+
N=200, pre_treatment_means=np.array([10, 12]), treatment_effect=2
217+
):
218+
group = np.random.choice(2, size=N)
219+
pre = np.random.normal(loc=pre_treatment_means[group])
220+
post = pre + treatment_effect * group + np.random.normal(size=N) * 0.4
221+
df = pd.DataFrame({"group": group, "pre": pre, "post": post})
222+
return df

causalpy/tests/test_data_loading.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,18 @@
33

44
import causalpy as cp
55

6-
tests = ["banks", "brexit", "covid", "did", "drinking", "its", "its simple", "rd", "sc"]
6+
tests = [
7+
"banks",
8+
"brexit",
9+
"covid",
10+
"did",
11+
"drinking",
12+
"its",
13+
"its simple",
14+
"rd",
15+
"sc",
16+
"anova1",
17+
]
718

819

920
@pytest.mark.parametrize("dataset_name", tests)

0 commit comments

Comments
 (0)