|
103 | 103 | " <tbody>\n", |
104 | 104 | " <tr>\n", |
105 | 105 | " <th>0</th>\n", |
106 | | - " <td>0.452636</td>\n", |
107 | | - " <td>0</td>\n", |
108 | | - " <td>1.684484</td>\n", |
| 106 | + " <td>0.898227</td>\n", |
| 107 | + " <td>1</td>\n", |
| 108 | + " <td>1.288637</td>\n", |
109 | 109 | " </tr>\n", |
110 | 110 | " <tr>\n", |
111 | 111 | " <th>1</th>\n", |
112 | | - " <td>0.380215</td>\n", |
| 112 | + " <td>0.462092</td>\n", |
113 | 113 | " <td>0</td>\n", |
114 | | - " <td>0.745268</td>\n", |
| 114 | + " <td>0.771976</td>\n", |
115 | 115 | " </tr>\n", |
116 | 116 | " <tr>\n", |
117 | 117 | " <th>2</th>\n", |
118 | | - " <td>0.584036</td>\n", |
119 | | - " <td>1</td>\n", |
120 | | - " <td>0.762300</td>\n", |
| 118 | + " <td>0.858974</td>\n", |
| 119 | + " <td>0</td>\n", |
| 120 | + " <td>1.881019</td>\n", |
121 | 121 | " </tr>\n", |
122 | 122 | " <tr>\n", |
123 | 123 | " <th>3</th>\n", |
124 | | - " <td>0.505191</td>\n", |
125 | | - " <td>0</td>\n", |
126 | | - " <td>1.425354</td>\n", |
| 124 | + " <td>0.228084</td>\n", |
| 125 | + " <td>1</td>\n", |
| 126 | + " <td>0.357797</td>\n", |
127 | 127 | " </tr>\n", |
128 | 128 | " <tr>\n", |
129 | 129 | " <th>4</th>\n", |
130 | | - " <td>0.384110</td>\n", |
| 130 | + " <td>0.962512</td>\n", |
131 | 131 | " <td>1</td>\n", |
132 | | - " <td>1.834628</td>\n", |
| 132 | + " <td>1.066413</td>\n", |
133 | 133 | " </tr>\n", |
134 | 134 | " </tbody>\n", |
135 | 135 | "</table>\n", |
136 | 136 | "</div>" |
137 | 137 | ], |
138 | 138 | "text/plain": [ |
139 | 139 | " X T1 Y1\n", |
140 | | - "0 0.452636 0 1.684484\n", |
141 | | - "1 0.380215 0 0.745268\n", |
142 | | - "2 0.584036 1 0.762300\n", |
143 | | - "3 0.505191 0 1.425354\n", |
144 | | - "4 0.384110 1 1.834628" |
| 140 | + "0 0.898227 1 1.288637\n", |
| 141 | + "1 0.462092 0 0.771976\n", |
| 142 | + "2 0.858974 0 1.881019\n", |
| 143 | + "3 0.228084 1 0.357797\n", |
| 144 | + "4 0.962512 1 1.066413" |
145 | 145 | ] |
146 | 146 | }, |
147 | 147 | "execution_count": 2, |
|
216 | 216 | " <tbody>\n", |
217 | 217 | " <tr>\n", |
218 | 218 | " <th>0</th>\n", |
219 | | - " <td>0.452636</td>\n", |
220 | | - " <td>0</td>\n", |
221 | | - " <td>1.684484</td>\n", |
222 | | - " <td>0.726318</td>\n", |
223 | | - " <td>0</td>\n", |
224 | | - " <td>0.273682</td>\n", |
225 | | - " <td>0.904259</td>\n", |
| 219 | + " <td>0.898227</td>\n", |
| 220 | + " <td>1</td>\n", |
| 221 | + " <td>1.288637</td>\n", |
| 222 | + " <td>0.949114</td>\n", |
| 223 | + " <td>1</td>\n", |
| 224 | + " <td>0.949114</td>\n", |
| 225 | + " <td>2.229118</td>\n", |
226 | 226 | " </tr>\n", |
227 | 227 | " <tr>\n", |
228 | 228 | " <th>1</th>\n", |
229 | | - " <td>0.380215</td>\n", |
| 229 | + " <td>0.462092</td>\n", |
230 | 230 | " <td>0</td>\n", |
231 | | - " <td>0.745268</td>\n", |
232 | | - " <td>0.690108</td>\n", |
233 | | - " <td>1</td>\n", |
234 | | - " <td>0.690108</td>\n", |
235 | | - " <td>1.930383</td>\n", |
| 231 | + " <td>0.771976</td>\n", |
| 232 | + " <td>0.731046</td>\n", |
| 233 | + " <td>0</td>\n", |
| 234 | + " <td>0.268954</td>\n", |
| 235 | + " <td>0.572308</td>\n", |
236 | 236 | " </tr>\n", |
237 | 237 | " <tr>\n", |
238 | 238 | " <th>2</th>\n", |
239 | | - " <td>0.584036</td>\n", |
240 | | - " <td>1</td>\n", |
241 | | - " <td>0.762300</td>\n", |
242 | | - " <td>0.792018</td>\n", |
| 239 | + " <td>0.858974</td>\n", |
| 240 | + " <td>0</td>\n", |
| 241 | + " <td>1.881019</td>\n", |
| 242 | + " <td>0.929487</td>\n", |
243 | 243 | " <td>1</td>\n", |
244 | | - " <td>0.792018</td>\n", |
245 | | - " <td>0.959608</td>\n", |
| 244 | + " <td>0.929487</td>\n", |
| 245 | + " <td>2.601592</td>\n", |
246 | 246 | " </tr>\n", |
247 | 247 | " <tr>\n", |
248 | 248 | " <th>3</th>\n", |
249 | | - " <td>0.505191</td>\n", |
250 | | - " <td>0</td>\n", |
251 | | - " <td>1.425354</td>\n", |
252 | | - " <td>0.752596</td>\n", |
| 249 | + " <td>0.228084</td>\n", |
| 250 | + " <td>1</td>\n", |
| 251 | + " <td>0.357797</td>\n", |
| 252 | + " <td>0.614042</td>\n", |
253 | 253 | " <td>1</td>\n", |
254 | | - " <td>0.752596</td>\n", |
255 | | - " <td>1.017777</td>\n", |
| 254 | + " <td>0.614042</td>\n", |
| 255 | + " <td>0.542638</td>\n", |
256 | 256 | " </tr>\n", |
257 | 257 | " <tr>\n", |
258 | 258 | " <th>4</th>\n", |
259 | | - " <td>0.384110</td>\n", |
| 259 | + " <td>0.962512</td>\n", |
260 | 260 | " <td>1</td>\n", |
261 | | - " <td>1.834628</td>\n", |
262 | | - " <td>0.692055</td>\n", |
| 261 | + " <td>1.066413</td>\n", |
| 262 | + " <td>0.981256</td>\n", |
263 | 263 | " <td>1</td>\n", |
264 | | - " <td>0.692055</td>\n", |
265 | | - " <td>2.374030</td>\n", |
| 264 | + " <td>0.981256</td>\n", |
| 265 | + " <td>2.401383</td>\n", |
266 | 266 | " </tr>\n", |
267 | 267 | " </tbody>\n", |
268 | 268 | "</table>\n", |
269 | 269 | "</div>" |
270 | 270 | ], |
271 | 271 | "text/plain": [ |
272 | 272 | " X T1 Y1 p T2 p_of_actual Y2\n", |
273 | | - "0 0.452636 0 1.684484 0.726318 0 0.273682 0.904259\n", |
274 | | - "1 0.380215 0 0.745268 0.690108 1 0.690108 1.930383\n", |
275 | | - "2 0.584036 1 0.762300 0.792018 1 0.792018 0.959608\n", |
276 | | - "3 0.505191 0 1.425354 0.752596 1 0.752596 1.017777\n", |
277 | | - "4 0.384110 1 1.834628 0.692055 1 0.692055 2.374030" |
| 273 | + "0 0.898227 1 1.288637 0.949114 1 0.949114 2.229118\n", |
| 274 | + "1 0.462092 0 0.771976 0.731046 0 0.268954 0.572308\n", |
| 275 | + "2 0.858974 0 1.881019 0.929487 1 0.929487 2.601592\n", |
| 276 | + "3 0.228084 1 0.357797 0.614042 1 0.614042 0.542638\n", |
| 277 | + "4 0.962512 1 1.066413 0.981256 1 0.981256 2.401383" |
278 | 278 | ] |
279 | 279 | }, |
280 | 280 | "execution_count": 3, |
|
319 | 319 | "name": "stdout", |
320 | 320 | "output_type": "stream", |
321 | 321 | "text": [ |
322 | | - "Average outcome of the actual biased assignment experiment: 1.411675477573636\n", |
323 | | - "Estimated outcome of random assignment: 1.251567372523789\n", |
324 | | - "95% confidence interval for estimated outcome: 1.2311928820519622 1.2719418629956158\n", |
325 | | - "Average outcome of the actual random assignment experiment: 1.2559621877416332\n" |
| 322 | + "Average outcome of the actual biased assignment experiment: 1.4064676444383317\n", |
| 323 | + "Estimated outcome of random assignment: 1.2594221770638483\n", |
| 324 | + "95% confidence interval for estimated outcome: 1.230204391668238 1.2886399624594587\n", |
| 325 | + "Average outcome of the actual random assignment experiment: 1.2461659092712785\n" |
326 | 326 | ] |
327 | 327 | } |
328 | 328 | ], |
|
360 | 360 | "name": "stdout", |
361 | 361 | "output_type": "stream", |
362 | 362 | "text": [ |
363 | | - "Average outcome of the actual random assignment experiment: 1.2559621877416332\n", |
364 | | - "Estimated outcome of biased assignment: 1.4147647990746988\n", |
365 | | - "Confidence interval for estimated outcome: 1.398423601541284 1.4311059966081134\n", |
366 | | - "Average outcome of the actual biased assignment experiment: 1.411675477573636\n" |
| 363 | + "Average outcome of the actual random assignment experiment: 1.2461659092712785\n", |
| 364 | + "Estimated outcome of biased assignment: 1.405112521603215\n", |
| 365 | + "95% confidence interval for estimated outcome: 1.3814865905561569 1.428738452650273\n", |
| 366 | + "Average outcome of the actual biased assignment experiment: 1.4064676444383317\n" |
367 | 367 | ] |
368 | 368 | } |
369 | 369 | ], |
370 | 370 | "source": [ |
371 | | - "# Conversely, we can take the outcome of the fully random test and use it to estimate what the outcome of the biased assignment would have been\n", |
| 371 | + "# Conversely, we can take the outcome of the fully random test and use it \n", |
| 372 | + "# to estimate what the outcome of the biased assignment would have been\n", |
372 | 373 | "\n", |
373 | | - "# Let's use data from biased assignment experiment to estimate the average effect of fully random assignment\n", |
374 | 374 | "hypothetical_policy = df[\"T2\"]\n", |
375 | 375 | "est, std = erupt_with_std(actual_propensity=0.5*pd.Series(np.ones(len(df))), \n", |
376 | 376 | " actual_treatment=df[\"T1\"],\n", |
|
379 | 379 | "\n", |
380 | 380 | "print(\"Average outcome of the actual random assignment experiment:\", df[\"Y1\"].mean())\n", |
381 | 381 | "print(\"Estimated outcome of biased assignment:\", est)\n", |
382 | | - "print(\"Confidence interval for estimated outcome:\", est-2*std, est + 2*std)\n", |
| 382 | + "print(\"95% confidence interval for estimated outcome:\", est-2*std, est + 2*std)\n", |
383 | 383 | "print(\"Average outcome of the actual biased assignment experiment:\", df[\"Y2\"].mean())" |
384 | 384 | ] |
385 | 385 | }, |
|
388 | 388 | "id": "f724dbc3", |
389 | 389 | "metadata": {}, |
390 | 390 | "source": [ |
391 | | - "As you can see, the actual outcome is well within the confidence interval estimated by ERUPT" |
| 391 | + "As you can see, the actual outcome is within the confidence interval estimated by ERUPT" |
392 | 392 | ] |
393 | 393 | }, |
394 | 394 | { |
|
0 commit comments