{"id":745,"date":"2017-01-25T15:43:58","date_gmt":"2017-01-25T23:43:58","guid":{"rendered":"http:\/\/www.deaneckles.com\/blog\/?p=745"},"modified":"2017-04-07T18:41:14","modified_gmt":"2017-04-08T02:41:14","slug":"using-covariates-to-increase-the-precision-of-randomized-experiments","status":"publish","type":"post","link":"http:\/\/www.deaneckles.com\/blog\/745_using-covariates-to-increase-the-precision-of-randomized-experiments\/","title":{"rendered":"Using covariates to increase the precision of randomized experiments"},"content":{"rendered":"<p>A simple difference-in-means estimator of the average treatment effect (ATE) from a randomized experiment is, being unbiased, a good start, but may often leave a lot of additional precision on the table. Even if you haven&#8217;t used covariates (pre-treatment variables observed for your units) in the design of the experiment (e.g., this is often difficult to do in streaming random assignment in Internet\u00a0experiments; see <a href=\"https:\/\/arxiv.org\/abs\/1409.3174\">our paper<\/a>), you can use them to increase the precision of your estimates in the analysis phase. Here are some simple ways to do that. I&#8217;m not including a whole range of more sophisticated\/complicated approaches. And, of course, if you don&#8217;t have any covariates for the units in your experiments \u2014\u00a0or they aren&#8217;t very predictive of your outcome, this all won&#8217;t help you much.<\/p>\n<h3>Post-stratification<\/h3>\n<p>Prior to the experiment you could do stratified randomization (i.e. blocking) according to some categorical covariate (making sure that there there are same number of, e.g., each gender, country, paid\/free accounts in each treatment). But you can also do something similar after: compute an ATE within each stratum and then combine the strata-level estimates, weighting by the total number of observations in each stratum. For details \u2014 and proofs showing this often won&#8217;t be much worse than blocking, consult <a href=\"http:\/\/sekhon.berkeley.edu\/papers\/postadjustment.pdf\">Miratrix, Sekhon &amp; Yu (2013)<\/a>.<\/p>\n<h3>Regression adjustment with a single covariate<\/h3>\n<p>Often what you most want to adjust for is a single\u00a0numeric covariate,<sup><a href=\"#footnote_0_745\" id=\"identifier_0_745\" class=\"footnote-link footnote-identifier-link\" title=\"As Winston Lin notes in the comments and as is implicit in my&nbsp;comparison with post-stratification, as long as the number of covariates is small and not growing with sample size, the same&nbsp;asymptotic results apply.\">1<\/a><\/sup> such as a lagged version of your outcome (i.e., your outcome from some convenient period before treatment). You can simply use ordinary least squares regression to adjust for this covariate by regressing your outcome on both a treatment indicator and the covariate. Even better (particularly if treatment and control are different sized by design), you should regress your outcome on: a treatment indicator, the covariate centered such that it has mean zero, and the product of the two.<sup><a href=\"#footnote_1_745\" id=\"identifier_1_745\" class=\"footnote-link footnote-identifier-link\" title=\"Note that if the covariate is binary or, more generally, categorical, then this exactly coincides&nbsp;with the post-stratified estimator considered above.\">2<\/a><\/sup> Asymptotically (and usually in practice with a reasonably sized experiment), this will increase precision and it is pretty easy to do. For more on this, see <a href=\"https:\/\/projecteuclid.org\/euclid.aoas\/1365527200\">Lin (2012)<\/a>.<\/p>\n<h3>Higher-dimensional adjustment<\/h3>\n<p>If you have a lot more covariates to adjust for, you may want to use some kind of penalized regression. For example, you could use the Lasso (L1-penalized regression); see <a href=\"https:\/\/arxiv.org\/abs\/1507.03652\">Bloniarz et al. (2016)<\/a>.<\/p>\n<h3>Use out-of-sample predictions from any model<\/h3>\n<p>Maybe you instead want to use neural nets, trees, or an ensemble of a bunch of models? That&#8217;s fine, but if you want to be able to do valid statistical inference (i.e., get 95% confidence intervals that actually cover 95% of the time), you have to be careful. The easiest way to be careful in many Internet industry settings is just to use historical data to train the model and then get out-of-sample predictions Yhat from that model for your present experiment. You then then just subtract Yhat from Y and use the simple difference-in-means estimator. <a href=\"http:\/\/aronow.research.yale.edu\/unbiased.pdf\">Aronow and Middleton (2013)<\/a> provide some technical details and extensions. A simple extension that makes this more robust to changes over time is to use this out-of-sample Yhat as a covariate, as described above.<sup><a href=\"#footnote_2_745\" id=\"identifier_2_745\" class=\"footnote-link footnote-identifier-link\" title=\"I added this sentence in response to Winston Lin&amp;#8217;s comment.\">3<\/a><\/sup><\/p>\n<ol class=\"footnotes\"><li id=\"footnote_0_745\" class=\"footnote\">As Winston Lin notes in the comments and as is implicit in my\u00a0comparison with post-stratification, as long as the number of covariates is small and not growing with sample size, the same\u00a0asymptotic results apply. [<a href=\"#identifier_0_745\" class=\"footnote-link footnote-back-link\">\u21a9<\/a>]<\/li><li id=\"footnote_1_745\" class=\"footnote\">Note that if the covariate is binary or, more generally, categorical, then this exactly coincides\u00a0with the post-stratified estimator considered above. [<a href=\"#identifier_1_745\" class=\"footnote-link footnote-back-link\">\u21a9<\/a>]<\/li><li id=\"footnote_2_745\" class=\"footnote\">I added this sentence in response to Winston Lin&#8217;s comment. [<a href=\"#identifier_2_745\" class=\"footnote-link footnote-back-link\">\u21a9<\/a>]<\/li><\/ol>","protected":false},"excerpt":{"rendered":"<p>A simple difference-in-means estimator of the average treatment effect (ATE) from a randomized experiment is, being unbiased, a good start, but may often leave a lot of additional precision on the table. Even if you haven&#8217;t used covariates (pre-treatment variables observed for your units) in the design of the experiment (e.g., this is often difficult [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[83,88,93,13,76],"tags":[],"class_list":["post-745","post","type-post","status-publish","format-standard","hentry","category-causal-inference","category-econometrics","category-experiments","category-research-methods","category-statistics"],"_links":{"self":[{"href":"http:\/\/www.deaneckles.com\/blog\/wp-json\/wp\/v2\/posts\/745","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.deaneckles.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.deaneckles.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.deaneckles.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.deaneckles.com\/blog\/wp-json\/wp\/v2\/comments?post=745"}],"version-history":[{"count":13,"href":"http:\/\/www.deaneckles.com\/blog\/wp-json\/wp\/v2\/posts\/745\/revisions"}],"predecessor-version":[{"id":769,"href":"http:\/\/www.deaneckles.com\/blog\/wp-json\/wp\/v2\/posts\/745\/revisions\/769"}],"wp:attachment":[{"href":"http:\/\/www.deaneckles.com\/blog\/wp-json\/wp\/v2\/media?parent=745"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.deaneckles.com\/blog\/wp-json\/wp\/v2\/categories?post=745"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.deaneckles.com\/blog\/wp-json\/wp\/v2\/tags?post=745"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}