<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Manuel Andere on Medium]]></title>
        <description><![CDATA[Stories by Manuel Andere on Medium]]></description>
        <link>https://medium.com/@manuel_71987?source=rss-b60811c059df------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Lt26Buovae6AiP_olvzkhw.jpeg</url>
            <title>Stories by Manuel Andere on Medium</title>
            <link>https://medium.com/@manuel_71987?source=rss-b60811c059df------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 22:36:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@manuel_71987/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Creating an A/B testing system]]></title>
            <link>https://medium.com/art-work-behind-the-scenes-at-patreon/creating-an-a-b-testing-system-b541de0ba73?source=rss-b60811c059df------2</link>
            <guid isPermaLink="false">https://medium.com/p/b541de0ba73</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[testing-framework]]></category>
            <category><![CDATA[analytics]]></category>
            <category><![CDATA[a-b-testing]]></category>
            <category><![CDATA[testing]]></category>
            <dc:creator><![CDATA[Manuel Andere]]></dc:creator>
            <pubDate>Wed, 30 May 2018 21:23:52 GMT</pubDate>
            <atom:updated>2018-05-30T21:48:44.424Z</atom:updated>
            <content:encoded><![CDATA[<p><em>This is the third and final post of our A/B testing series. Enjoy!</em></p><h3>What we’ve learned so far</h3><p>In our <a href="https://patreonhq.com/a-framework-to-design-randomized-experiments-the-right-way-3640d4271d1f">first</a> A/B testing series post, we defined causal inference and explained why randomized experiments (or A/B tests) allow us to make causal claims. We established a framework that simplifies the design of randomized experiments, which uses three main concepts:</p><ol><li><strong>Observation units.</strong> The units that experience the treatments. Composed of <em>Identifiability (</em>how you identify the units) and <em>Eligibility</em> (the set of conditions they have to meet to participate in the experiment)</li><li><strong>Treatments (aka variants).</strong> The experiences that the observation units can potentially have.</li><li><strong>Response metric.</strong> A measurement you’ll get for each observation unit.</li></ol><p>An experiment analysis consists of comparing the <strong>response metric</strong> among <strong>treatment</strong> <strong>groups</strong> to determine if the treatment had an effect on the <strong>observation units</strong>.</p><p>In the <a href="https://patreonhq.com/a-framework-to-determine-how-much-data-you-need-for-an-experiment-a20fcd2719eb">second</a> post of the series, we discussed the importance of sizing an experiment, and established a reusable randomization framework for power and sample size calculations.</p><p>At this point, you should be able to answer:</p><ul><li>Who will be part of the experiment?</li><li>What will the treatments consist of?</li><li>What metric will we measure?</li><li>What type and size of effect we expect our treatment to have on the response metric?</li><li>How much data do we need if we assume a given effect size and an analysis method?</li></ul><p>This post will help you answer the following question: <strong>How do I decide which unit gets which treatment?</strong> This question is at the core of the experiment implementation stage. In the causal inference literature, the procedure by which assignment is done is called the <a href="https://en.wikipedia.org/wiki/Rubin_causal_model#The_assignment_mechanism">assignment mechanism</a>. We will not focus on the theoretical aspects of assignment mechanisms, but on how to implement a basic assignment mechanism that works for online experiments.</p><h3>Simplest assignment mechanisms</h3><p>The simplest assignment mechanism is called <strong>complete randomization</strong>. It consists of distributing a fixed set of observation units among treatments at random. For example, you have a list of 100 user_ids, and you randomly assign 30 to treatment A, 40 to treatment B, and 30 to treatment C.</p><p>This randomization is very easy if you have a fixed population to experiment on, and if you can identify all the units at the design stage. In many online experiments, these assumptions do not hold. We usually don’t know who will visit a website in the next few days (there might even be new users that we can’t identify at the design stage).</p><p>A way to get around this problem is to assign units “as they arrive.” Every time we see an identifier (e.g., a user_id), we draw a treatment at random. In probabilistic terms, we draw a <a href="https://en.wikipedia.org/wiki/Categorical_distribution">categorical random vector</a>. The <a href="https://en.wikipedia.org/wiki/Law_of_large_numbers">Law of Large Numbers</a> guarantees approximately correct group proportions. This assignment mechanism is called <strong>independent Bernoulli trials</strong>. Although this algorithm solves the problem of not knowing who and how many units will visit, it has a clear limitation: think about an experiment that consists of showing different versions of a webpage. Under the independent Bernoulli trials mechanism, if the same unit loads the page more than once, they might experience a different treatment every time, which could make the unit useless for the experiment (it would not be clear which treatment we should attribute their reactions to).</p><h3>Hash functions to the rescue</h3><p><a href="https://en.wikipedia.org/wiki/Hash_function">Hash algorithms</a> come to the rescue. Let’s take <a href="https://en.wikipedia.org/wiki/MD5">MD5</a> as an example. The MD5 hash function takes a string of almost any size and converts it into a 128-bit hash value.</p><p>md5(&#39;my_string&#39;) = &#39;3d212b21fad7bed63c1fb560c6a5c5d0&#39;</p><p>That hash value is just a random set of characters. Think of it as a number between one and one <a href="https://en.wikipedia.org/wiki/Duodecillion">Duodecillion</a> 😮. We don’t need that many numbers, so let’s keep the first 10 bits of the hash value (this is equivalent to approximately any number between one and 1,000).</p><p>The truncated MD5 map function guarantees:</p><ul><li><strong>Determinism</strong>: Always maps an input to the same output (otherwise it wouldn’t be a function).</li><li><strong>Uniformity</strong>: Given a new input, it’s equally likely to produce any number from one to 1,000.</li><li><strong>Anti-continuity</strong>: Two similar inputs will most likely lead to non-similar outputs.</li><li><strong>Speed</strong>: It’s really fast to compute (probably faster than retrieving a value from storage).</li></ul><p>Why is the truncated MD5 function useful for us, you might ask? Because we can use it to map any identifier (old or new, known or unknown) to a random uniform number between one and 1,000. Further, if we assign treatments to the 1,000 buckets according to some desired proportions, by transitivity, we’ve built a method that assigns treatments to identifiers in a consistent way, and with the desired probabilities.</p><h3>More about buckets</h3><p>Thanks to the bucket layer that separates the universe of observation unit identifiers and the treatment space (the set of possible treatments), any experiment can be treated as a <em>completely randomized </em>experiment (we can randomize the 1,000 buckets as a fixed and known population).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JyjlxYlW9JqQfxWY.png" /></figure><p>This bucketing framework is quite powerful because it can be used with any type of identifier. Common identifiers are: cookie-based device_ids, and user_ids. However, we could also extend it to request_ids, query_ids, emails, or domain specific identifiers (like campaign_ids at Patreon).</p><p>At Patreon, Jonas and Cathy (two of our awesome growth team engineers) created an experiment dashboard where we explore and manage all of our experiments. One of the key things we show for each experiment is the type of identifier(top right of each experiment card).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7Fl9iNYJ6qXcGv5C.png" /></figure><h3>Other critical features of the system: versions, overrides, and more</h3><p><strong>Versioning</strong></p><p>In online experiments, it is common to roll up and down treatment proportions. For example, you might want to cautiously roll out to a small proportion of identifiers in order to get a first glance of their reaction. You might also have to roll back the experiment because of a bug, or you might want to change the treatment proportions to get more data for one treatment after you’ve discarded another one. This experiment framework allows for treatment proportion changes through a <em>versioning</em> feature.</p><p>A version is a mapping from buckets to treatments. Within a version’s life, each bucket will keep a single treatment. Across versions, we impose one fundamental restriction: a bucket can be assigned to at most one active treatment (an active treatment is any treatment that is not the control). This rule allows us to always fall back to control, and ensures some level of stability in the experiences that users can have.</p><p>Stability primarily matters because it leads to a better user experience. Users expect websites to be generally consistent. If they’ve seen a given version of a page or feature in the past, they expect it to behave the same the next time they visit. If their experience changes because they’re in an active treatment of an experiment, they have to make an effort to learn the new version. The least we can do is guarantee that the users will have to learn at most one new experience during the test. Second, you could (to some extent) argue that every user has potentially seen the control version in the past. Therefore the group contamination that control-active switches imply for analytic purposes is slightly less bad than switching between active treatments.</p><p>The next table shows how our implementation would handle a sequence of versions. The trick is that we first create a static random bucket order for each experiment. Then we fill the reorganized buckets in order according to the proportions that we want.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xmJaNTciaO1CeChE.png" /></figure><p>At the analysis stage, to have a valid analysis, you should only analyze units that experienced the experiment within a given version. This way you can claim that during that time window they only saw one version, and during their whole life, they’ve seen at most one active version and the control experience.</p><p>Here’s a quick look at what rolling out a new version looks like in Patreon’s experiment dashboard:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/621/0*qJgYpUrCzXaZ4Jr0.png" /></figure><p><strong>Overriding identifiers</strong></p><p>As the name suggest, the override feature allows admin users to override a specific identifier to always receive a specific treatment, completely ignoring the randomization process. The ability to override was a highly-requested feature by developers and product managers. It facilitates development, showcasing the feature, and user research, because admins can override their own identifiers depending on what they want to QA or show. We implemented this by bypassing the bucket layer and directly assigning a treatment to the unit. This feature is also managed through Patreon’s experiment dashboard, as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ptgClzlX9ivnS1z2.png" /></figure><p><strong>Restricted bucket space</strong></p><p>An additional advantage of the bucket layer is that we can easily block certain parts of the identifier space across experiments. By defining a bucket as blocked for a specific experiment, you guarantee that any identifier that would be mapped to that bucket would get the control version of the experiment.</p><p>This makes it easier to have long-term holdout groups: you can just block certain buckets for multiple experiments and guarantee that they’ll see only control experiences. It can also be useful to deal with multiple conflicting experiments within a specific identifier space. Team A could be assigned to buckets 1 to 500 to experiment on their feature, while Team B could be assigned buckets 501 to 1,000.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*av6xbcZjUY_nhEhS.png" /></figure><h3>How does the backend work?</h3><p>The implementation of this experimentation framework consists of three elements:</p><ol><li>A MySQL-backed <strong>data model:</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wKtSGTljvTcC9apM.png" /></figure><p>Some of the less obvious attributes from above are:</p><ul><li>Registered_at, activated_at, and archived_at. Registration corresponds to the moment the experiment is defined, activation to the moment the first version is rolled out, and archiving to the moment the experiment will no longer be used.</li><li>Randomization_type defines the type of identifier that will be used for randomization during the experiment.</li><li>Available_bucket_space indicates buckets that are free to receive an active treatment; any bucket not considered in the available_bucket_space will be assigned the control variant.</li></ul><p>2. A <strong>controller,</strong> which lets us:</p><ul><li>Register the attributes of an experiment (and its variants)</li><li>Update the experiment attributes</li><li>Archive the experiment</li><li>Rollout a new version (versions can’t be edited or deleted)</li><li>Create, modify, or delete an override</li><li>Retrieve a variant assignment for an identifier by: i) verifying experiment status, ii) checking the experiment-identifier pair for overrides, iii) computing a bucket for the identifier using a hash function, iv) retrieving the latest bucket-variant mapping from the last experiment version, and v) returning the corresponding assignment.</li></ul><p>3. An <strong>API</strong> that allows on-demand retrieval of experiment information.</p><p>We expose the experiment and variant objects through a single <strong>experiment resource</strong>. We also expose the experiment version as its own <strong>experiment version resource</strong>. However, we don’t expose a resource for the overrides object. Instead we created an ephemeral resource called <strong>ExperimentAssignment</strong>, which acts as an interface to retrieve or modify assignments (whether overridden or natural).</p><h3>Wrapping up</h3><p>After reading this blog post, you should understand the core concepts required to implement an experimentation system, including what an assignment mechanism is, why hashing functions are so powerful, why it’s useful to separate the identifier space from the treatment space, why versioning and treatment overriding are required features, and how conflicting experiments and holdout groups can be handled. I also provided a sneak peek into Patreon’s experiment backend implementation and its experiment management dashboard. I hope this is a good starting point for anyone who is planning to build randomized experimentation infrastructure for their website!</p><p>Want to help us solve problems like this every day? <a href="http://patreon.com/careers">Join us!</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b541de0ba73" width="1" height="1" alt=""><hr><p><a href="https://medium.com/art-work-behind-the-scenes-at-patreon/creating-an-a-b-testing-system-b541de0ba73">Creating an A/B testing system</a> was originally published in <a href="https://medium.com/art-work-behind-the-scenes-at-patreon">art/work -behind the scenes at patreon</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Framework for Determining How Much Data You Need for an Experiment]]></title>
            <link>https://medium.com/art-work-behind-the-scenes-at-patreon/a-framework-to-determine-how-much-data-you-need-for-an-experiment-a20fcd2719eb?source=rss-b60811c059df------2</link>
            <guid isPermaLink="false">https://medium.com/p/a20fcd2719eb</guid>
            <category><![CDATA[ab-testing]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[patreon-engineering]]></category>
            <category><![CDATA[patreon]]></category>
            <category><![CDATA[data]]></category>
            <dc:creator><![CDATA[Manuel Andere]]></dc:creator>
            <pubDate>Wed, 28 Jun 2017 20:37:59 GMT</pubDate>
            <atom:updated>2018-02-01T01:10:29.387Z</atom:updated>
            <content:encoded><![CDATA[<h4><strong>Part 2 of our A/B Testing Series</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VoboMjV4ZoYX2fcECAzhkQ.jpeg" /></figure><p><a href="https://patreonhq.com/a-framework-to-design-randomized-experiments-the-right-way-3640d4271d1f">Part one</a> of our A/B testing series provided a clear framework to design randomized experiments. There, we established that a correct experiment is designed by clearly defining:</p><ul><li><strong>Observation units</strong>: the unit that we randomly assign to a treatment, and for which we measure a response metric (usually a user, but could also be a web request, a device-browser combination, a machine, etc.)</li><li><strong>Treatments</strong>: the set of experiences that the observation units can potentially have during the experiment</li><li><strong>Response metrics</strong>: the measurement that we use to represent the state of each observation unit after they experience a treatment</li></ul><p>We also discussed that the ultimate goal of experimentation is to identify whether applying a treatment to an observation unit <em>causes</em> the response metric to change. The most common A/B testing procedure to achieve this goal is:</p><ul><li>randomly split a sample of the eligible population into treatment and control groups</li><li>apply the treatment to the observation units in the treatment group</li><li>use a statistical procedure to identify significant (non-random) differences in the response metric between the treatment and control groups</li></ul><p>One of the most important factors to consider at the design stage of an experiment is the amount of data required to decide confidently whether the groups differ. It’s intuitive that more data leads to better conclusions. The trade-off is also clear: more data means more money or more time. However, it’s not easy to determine a specific sample size without diving into a statistics book and dealing with some non-trivial math. This post creates a bridge so that experimenters can perform formal required sample size calculations without going deeply into the mathematical details.</p><p>First, we’ll walk through a series of preparatory steps that are essential to determine a sample size:</p><ol><li>Understand the distribution of the response metric</li><li>Determine a treatment effect type and minimum effect to detect</li><li>Pick a target confidence and power</li><li>Select the statistical procedure to detect differences in the response metric</li></ol><p>Next, we’ll discuss a simulation procedure we use at Patreon to determine the exact amount of data that we need for any given experiment. Finally, we’ll illustrate the whole methodology with a real-world example.</p><h3>A walk through the preparatory steps</h3><h4>Understand the distribution of the response metric</h4><p>The first thing you should do once you’ve determined the main components of the experiment (observation unit, treatment and response metric), is understand the distribution of the response metric for the eligible population. Often, it is possible to do this with historical data, but if empirical data is not available, you can assume an appropriate probability distribution based on your domain knowledge. Besides forcing you to think about the range of values you expect to observe in the response metric, this allows you to calculate baseline summary metrics for the distribution (average and variance are the most relevant ones).</p><p>Some common distributions for the response metric are:</p><ul><li>Binary (e.g., Bernoulli): whether a user signs up or not at the end of a sign-up funnel.</li><li>Count (e.g., Poisson): how many pledges a patron makes in a given month.</li><li>Skewed continuous distribution (e.g., Gamma): the amount of income that a new creator will make during their 6 month at Patreon.</li><li>Symmetric continuous distribution (e.g., Normal): the net change in a Patreon creator pledge base from one month to another.</li></ul><h4>Determine a treatment effect type and minimum effect to detect</h4><p>Next, you should think about what type of effect your treatment will have on the response metric. The most common assumption is that the treatment will cause the response metric to increase (or decrease) by a constant value for every observation unit. Because you’ve already established some baseline values during the first step, you should be able to quantify the size of the effect concretely. For example, if you are evaluating the amount of income that a new creator will make during their sixth month at Patreon, you could say that the treatment will cause them to have a additional $15 (on top of what they would make without the treatment). Or if you know that average earnings at the sixth month is $1000, then you could assume that the treatment will cause a 1% boost, which would be equivalent to $10 extra for everyone who gets the treatment.</p><p>Once the effect type is settled, think about the minimum effect size you are interested in detecting. Keep in mind that not all effect sizes are relevant in every domain, regardless of how statistically significant they are. If it’s hard to determine whether a specific effect in your response metric is relevant from a business perspective, you should link it, using at least a back-of-the-envelope calculation, to one of your core company metrics where you can make that assessment. For example, you might want to understand how a user sign-up translates to income.</p><h4>Pick a target confidence and power</h4><p>Because the ultimate goal of running an experiment is to conclude whether the treatment caused an effect, one way to assess the quality and robustness of your experimental procedure is on the basis of:</p><ol><li><strong>Confidence: </strong>The probability that you conclude the treatment did not have an effect when it in fact did not.</li><li><strong>Power: </strong>The probability that you conclude the treatment had an effect when there in fact was an effect at least as big as the minimum relevant effect determined in the previous section.</li></ol><p>The higher the confidence and power, the better your experimental procedure.</p><p>To determine a target confidence and power, you need to think about the consequences of making each mistake. For example, if you’re testing a product or feature that you expect will have a positive impact on the response metric, low power might mislead you to think that you didn’t have the minimum effect that you were aiming for. This might cause you to roll back the feature and lose its potential gains. Having low confidence, on the other hand, could make you believe that there is an effect, when in fact there isn’t, causing you to roll out and maintain a feature that doesn’t have the effect you observed in the experiment. At Patreon, we aim to run experiments that have 90% confidence and 90% power, but we adjust these values on a case-by-case basis, depending on the feature’s importance.</p><h4>Select the statistical procedure to detect differences in the response metric</h4><p>Lastly, you should define the statistical procedure that you will use to assess whether the groups differ after running the experiment. Different tests are better at detecting certain type of effects. For example, a t-test for a difference in averages is usually good if you expect the treatment to impact all observation units similarly, but under different assumptions there might be better statistical methods. In a future blog post, we will cover a few statistical techniques that can be used under different scenarios, so keep an eye out for it!</p><h3>The POWER of simulation</h3><p>You’ll know you’re ready to determine the exact amount of data (or sample size) required for your experiment when you have:</p><ul><li>a historical sample of the response metric for your eligible population (or some theoretical distribution)</li><li>clarity on what type of effect your treatment will cause and the effect size that you want to detect</li><li>target values for your confidence and power</li><li>a statistical approach to compare the groups</li></ul><p>All these elements are inputs required to determine the optimal sample size. Their impact on sample size, under the assumption that <em>all other factors are kept constant</em>, is intuitive; each of the following would require more data:</p><ul><li><strong>More variance in the distribution of the response metric </strong>(we need more data to detect the signal when there’s a lot of noise)</li><li><strong>Smaller effect size </strong>(we need more data to detect more subtle effects)</li><li><strong>More power or confidence</strong> (we need more data to make fewer mistakes)</li><li><strong>Worse statistical approach </strong>(we need more data if we use a statistical approach that is not suited to analyze the type of effect that the treatment causes)</li></ul><p>However, it’s not trivial to quantify precisely how much each element will impact the required sample size in any given experiment. For this reason, at Patreon, we use a simulation framework to avoid difficult math.</p><p>The framework is designed with power as the dependent variable, and all other factors (including sample size) are treated as inputs. However, we can easily reverse-engineer it to make conclusions about required sample sizes. Our framework works in the following way:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oNPUhlcv43vVmRFq.png" /></figure><p>The great thing about this approach is that it is flexible and modular enough so that we can move any of the parameters and understand how our experiments react to the changes. Additionally, the framework ultimately allows us to:</p><ul><li>facilitate discussions with product managers about what type and size of effect our features need to have for A/B testing or experimentation to be the right tool to assess their success</li><li>avoid running and analyzing experiments for which we don’t have enough data to reach meaningful conclusions (this saves a lot of resources)</li><li>be more confident about our positive or negative experimental results, because we trust that we correctly determined how much data to collect</li></ul><h3>A real-world example (with fake numbers)</h3><p>In this section, we’ll illustrate how the above procedure (preparatory steps and simulations) was used in a real-world example to determine a sample size for a Patreon experiment.</p><p>Consider the following example of a feature that we released a few months ago. The feature allows creators to schedule their posts ahead of time. The numbers in the example are solely illustrative.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/315/1*yQV4eae0Hn0uBCs9_44OZw.png" /><figcaption>Scheduled posts feature snap shot</figcaption></figure><p>We began with the three core definitions for our experiment:</p><ul><li>the <strong>observation unit</strong> was every Patreon creator active when we released the feature to a random subset of creators</li><li>there were two <strong>treatments: </strong>having access to the new feature (active treatment) or not having access (control)</li><li>the main <strong>response metric</strong> was the number of posts that the creator made during the one-month experiment</li></ul><p>Then, we proceeded with the preparatory stage:</p><p><strong>Historical sample</strong>: we pulled data for the number of posts that creators made during the month prior to the experiment. Let’s say this sample had 20,000 creators and it produced a right-skewed histogram with a mean of four posts per month and a standard deviation of one post.</p><p><strong>Type and size of effect</strong>: We assumed that even though we were going to release the feature to a certain number of participating creators and let them know that they could use it, not all of them would actually be impacted by it. Therefore, the way we modeled the effect on the response metric during each simulation was by assuming that only 25% of the creators that had access to the feature would post more than they otherwise would have, and the rest would not be impacted by the feature. We additionally thought it was reasonable to assume that this 25% of creators would increase their observed monthly post count (the response metric) by one post.</p><p><strong>Confidence and power</strong>: For this feature we used 90% confidence and 90% power.</p><p><strong>Statistical procedure</strong>: We used a t-test to detect a difference in means.</p><p>Finally, we started simulating. The first simulation was done assuming a sample of 5,000 creators.</p><p>The steps for a single simulation were:</p><ul><li>Sample 5,000 creators with replacement from the 20,000 creators in the historical data.</li><li>Randomly select 50% of those 5,000 creators to be in the active treatment group.</li><li>Randomly select 25% of the 2,500 creators selected in the previous step and add one post to their observed historical response metric (the remaining 75% keep their original observed response metric).</li><li>Run a t-test, with a 90% confidence level, comparing the 2,500 creators in the treatment group with the 2,500 in the control group, and record whether we detect the difference.</li></ul><p>We repeated the simulation 10,000 times to determine the proportion of cases where we correctly identified the effect. This proportion is an estimate of the power of the procedure under the established assumptions. Because a sample size of 5,000 creators did not achieve the desired 90% power, we increased the sample size several times in increments of 1,000 and repeated the procedure until we reached our target 90% power with a sample size of 15,000 creators.</p><p>From this procedure, we were able to conclude that if we ran this experiment with two groups of 7,500 units each, and the feature actually caused 25% or more creators in the treatment group to increase their monthly number of posts by at least one post, we would be sure that a 90%-confidence t-test would detect the effect with at least 90% probability.</p><h3>Conclusion</h3><p>As stated throughout the post, the factors that come into play when determining sample size for an experiment are the distribution of response metric, the type of treatment effect and it’s size, power, confidence, and statistical comparison procedure. Though these factors’ directional impact on required sample size is intuitive, it is not easy to quantify their precise impact on every experiment. Simulation makes this task much easier.</p><p>Our hope is that after reading this post, when someone asks, “How much data do we need for this test? How long do we need to run our experiment? Are we running experiments with sufficient power?” you won’t need to make up a hand-wavy and unintelligible explanation, or spend hours reading statistics literature. You can just send them to read this post while you run the necessary simulations to answer their question in an accurate way!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a20fcd2719eb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/art-work-behind-the-scenes-at-patreon/a-framework-to-determine-how-much-data-you-need-for-an-experiment-a20fcd2719eb">A Framework for Determining How Much Data You Need for an Experiment</a> was originally published in <a href="https://medium.com/art-work-behind-the-scenes-at-patreon">art/work -behind the scenes at patreon</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Framework to Design Randomized Experiments (The Right Way)]]></title>
            <link>https://medium.com/art-work-behind-the-scenes-at-patreon/a-framework-to-design-randomized-experiments-the-right-way-3640d4271d1f?source=rss-b60811c059df------2</link>
            <guid isPermaLink="false">https://medium.com/p/3640d4271d1f</guid>
            <category><![CDATA[patreon-engineering]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[patreon]]></category>
            <category><![CDATA[ab-testing]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Manuel Andere]]></dc:creator>
            <pubDate>Wed, 08 Mar 2017 21:23:08 GMT</pubDate>
            <atom:updated>2017-03-09T05:58:28.936Z</atom:updated>
            <content:encoded><![CDATA[<h4>Part 1 of our A/B Testing Series</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OxamKgTAbecnceTWSqJWsA.jpeg" /></figure><p><a href="http://patreon.com/">Patreon</a> is a small company with around eighty employees, which means that our five-person data science team does a broad range of activities: <strong>business analysis</strong> (e.g. defining and tracking company KPIs), <strong>data requests</strong> (e.g. building dashboards for teams), <strong>data modeling</strong> (e.g. recommendation systems and predictive models), and, <strong>product evaluation</strong> (e.g. designing and analyzing randomized experiments).</p><p>Out of these four, we probably spend the most time doing product analysis, so standardizing the way we think about experiments was a must in order to ensure Patreon could make better product decisions faster.</p><p>This post will give an overview of the main concepts that compose our framework (mainly an adaptation of the <a href="https://en.wikipedia.org/wiki/Rubin_causal_model">Potential Outcomes</a> framework that I learned during my graduate program in Statistics), and will be most useful for data analysts or data scientists who want a clearer picture of what randomized experiments (aka a/b tests) are, and who would appreciate a reusable theoretical framework to <strong>design</strong>, <strong>implement</strong>, and <strong>analyze</strong> experiments in a software/website context.</p><h3>1. What is causal inference and experiment design?</h3><p><strong>1.1 What is causal inference?</strong></p><p>Imagine you wake up with a headache today, you take some medicine, and within one hour your headache goes away. Did the medicine <strong>cause</strong> you to feel better? The answer is not obvious, because you don’t know <strong>what would have happened </strong>if you had not taken the medicine.</p><p>That is what causal inference — and ultimately, experiment design — is all about. Making statements about events that might cause other events, and estimating the uncertainty associated with those claims.</p><p><strong>1.2 Why do randomized experiments help identify causality?</strong></p><p>Continuing with the example from before, imagine that, every single time you got a headache in the past 5 years, before taking the medicine, you also slept 15 minutes longer than usual, you drank some extra coffee, and you didn’t receive a call from Betsy: that annoying friend who calls you every day and just talks and talks. How can you tell if it was the medicine, the sleep, the coffee, or your lack of Betsy that relieved your headache? The answer is: you can’t.</p><p>How about if you do the following: every time you get a headache, throw a coin to decide whether or not you’ll take the medicine. Note that you shouldn’t make any other decision based on the result of the coin flip. This is where the magic of randomness comes in, if you always throw a coin before deciding to take the medicine, and you make no other decision based on the result, then, in the long run, the group of cases where you took the medicine and the group of cases where you didn’t will be similar in every aspect, except for presence or lack of medicine! Therefore, it’s “reasonable” to assume that any difference between the groups is an effect of the medicine.</p><h3>2. The framework: concepts and definitions</h3><p>The framework that we use at Patreon to think about randomized experiments is surprisingly simple.</p><p>You have a <strong>target</strong> <strong>observation unit</strong> (in the example above, it’s you), and you want to know the effect that a certain set of <strong>treatments</strong> (e.g., taking the medicine or not) would have on you. Then you assume that you (the observation unit), after taking the medicine or not (each of the treatments), could end up in a set of potential states, which we’ll assume can be well-represented by a <strong>response metric</strong>.</p><p>Ideally, you’d like to observe the response metric for your target observation unit after applying all treatments, so that you can claim that any differences were <strong>caused</strong> by the treatments, but unfortunately, that is impossible, because as Heraclitus said: <em>“No man ever steps in the same river twice, for it’s not the same river and he’s not the same man.”</em> So, what’s the next best thing?</p><p>Get a group of observation units that are similar to (or to sound fancier, representative of) your target observation unit, assign them the treatments at random, measure the response metric for each observation unit, compute some summary (usually the average) of the response metric for each treatment group, and compare the summaries, assuming that this comparison represents well the original difference that you wanted to understand for the target observation unit.</p><p>Summarizing, there are three main concepts that we talked about:</p><ul><li><strong>observation units</strong>: the thing that you assign randomly to treatments</li><li><strong>treatments</strong>: all the different experiences that the observation units can have</li><li><strong>response metric</strong>: the measurement that you use to represent the state of each observation unit after they experience a treatment</li></ul><p>Here’s a diagram that might help visualize the concepts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SXQgFYh44EjgufFI.png" /><figcaption>Observation units, treatments and response metric diagram.</figcaption></figure><p>The key thing to remember is that for each observation unit, there are different potential states that they could end up in after taking each treatment, but we will just be able to ever see one of the potential states represented by a single measurement of the response metric.</p><h3>3. Randomized experiments in websites</h3><p><strong>3.1 Why do software (and website) companies use experimentation?</strong></p><p>Randomized experiments are not so new, and several industries have used them for a long time. For example, the Pharmaceutical industry uses experiments to prove that their medicines work when they present them to the <a href="https://www.fda.gov/AboutFDA/WhatWeDo/History/Overviews/ucm304485.htm">Food and Drug Administration</a>.</p><p>So, why is A/B testing such a hot topic in silicon valley if several industries have done it for many years? Well, it could be because silicon valley folks (like me, unfortunately) tend to claim that everything they do is new and interesting, but more likely, because designing experiments and capturing data in software companies and particularly, websites, is an easy and fast way to learn about the way users are engaging with the product and iterate through features towards a better product.</p><p>Next, I’ll continue to describe how to map each of the concepts in section 2 to a website experiment design, where the target is, as we mentioned earlier, to understand user reactions to product changes. To make it clearer, we’ll describe each step with a (semi) real Patreon example where we wanted to understand if a new creator page layout (on the right) was better at getting users to become Patreon members.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/969/1*7_tPQOzMsZ2B-qzoV2-6Tg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/1*vpYZOi6DR-A6-ZEwVKmynQ.png" /><figcaption>Old (left) and new (right) creator page versions.</figcaption></figure><p><strong>3.2 Identifying observation units</strong></p><p>We use two concepts to define an observation unit: <strong>identifiability</strong> and <strong>eligibility</strong>.</p><p><strong>3.2.1 Identifiability.</strong></p><p>You should start with finding a way to identify your users. If the experiment is visible to logged in users only, you can probably identify your users with a<em> user_id</em>. However, if the experiment is also visible to logged out users, you probably want to do it via setting a “permanent” unique user identifier (uuid) in the visitors’ cookies. This will allow you to approximately track the behavior of a specific person as they browse through the site.</p><p>In our experiment, logged out users can see any creator page, so we used a uuid that we put on the browser’s cookies whenever someone interacts with any part of our site. These uuid did not have a 1 to 1 relationship with users because cookies change by browser/device, but we made the judgement call that this identifier was good enough.</p><p><strong>3.2.2 Eligibility.</strong></p><p>The key here is to clearly identify the last thing that all of the users in all of the treatment groups will have in common immediately before they get forked into different experiences (treatments). At Patreon, we’ve found that logging an event for this “last experience” is a good practice, because it allows you to very explicitly say who is participating in the experiment, and therefore who you can extrapolate your results to. We call this the <strong>eligibility event</strong>.</p><p>In our experiment, the eligibility event was receiving a request to load a creator page. So any uuid that requested a creator page during a given week was susceptible of being an observation unit.</p><p>Note that the eligibility event could be something more complicated, like spending 10 seconds within a given page, receiving a specific email, running a specific query, etc.</p><p>Also, we could have used something super general for our eligibility event, like being active anywhere on the site during that week, however, the ideal is to have the eligibility event as close to the real forking point as possible to avoid diluting our observation units. The further the eligibility event is from the real forking point, the least sure you will be that observation units in distinct groups actually had different experiences.</p><p>A lot of times there’s additional characteristics that you want to consider to make a user eligible to participate in the experiment. At Patreon, we call these additional criteria<strong> eligibility criteria</strong>, and we usually log them as a properties of the eligibility event.</p><p>In our experiment, for example, we wanted to understand the behavior of people in the US only, so, at the moment when the creator page request was made we identified where the user was located and logged a location property in the eligibility event.</p><p>Summarizing, in every experiment, you should have clarity on the following:</p><ul><li><strong>Identifiability</strong></li><li><strong>Eligibility </strong>(eligibility event within a certain time window and eligibility criteria)</li></ul><p><strong>3.3 Applying the treatments</strong></p><p>The way we assign treatments to observation units at Patreon is by mapping the identifier to a random number between 0 and 1 (you can use a hash function for this to ensure that the number is random but always the same for a given identifier). Then, you can just re-direct the user to a different experience based on the random number they get. The key thing to notice here is that you should always randomly assign the treatment on an observation unit level through the identifier that you picked.</p><p>To make analysis easy, we also log the treatment that the user gets as a property of the eligibility event.</p><p>In our example, the moment we got a request to load a creator page that was done within the us, we hashed the uuid to map it to a number between 0 and 1, and when the result was above 0.5 we showed the new layout of the creator page, otherwise we showed the old version.</p><p>To be very specific, the eligibility event you should be logging should look something like:</p><pre>{ &#39;event&#39;: &#39;request_creator_page&#39;,</pre><pre>  &#39;uuid&#39;: &#39;0f3e39a8-ff84-11e6-bc64-92361f002671&#39;,</pre><pre>  &#39;event_time&#39;: &#39;2016-11-07 10:04:03&#39;,</pre><pre>  &#39;event_properties&#39;: {</pre><pre>      &#39;location&#39;: &#39;US&#39;,</pre><pre>      &#39;treatment&#39;: &#39;new_creator_page&#39;</pre><pre>  }</pre><pre>}</pre><p><strong>3.4 Measuring a response metric</strong></p><p>If you recall, the response metric is responsible for representing the state of the observation unit after the treatment has been applied. Therefore, you should always be able to measure the response metric for each observation unit. If you can’t measure it for all observation units, then something is not defined correctly.</p><p>In our example, we checked whether we had a “Sign-up” event associated to the uuid within 1 day after we saw their first creator page load event. If so, we assigned a one to that observation unit, otherwise we assigned a zero.</p><p><strong>3.5 Analyzing the results</strong></p><p>The final data set for analysis should have a single observation unit for each line (represented by the identifier), the treatment that the observation unit got, and the response metric that you measured for that observation unit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9mmb3mPeGKgUkwGsmzJv1g.png" /><figcaption>Analysis data frame for ab test with uuid as identifier of observation unit, two treatments and binary response metric.</figcaption></figure><p>To make the comparison across groups, you will probably want to summarize the responses by some aggregation, like the average, median or max. In theory, you can go crazy with this, but the crazier you go, the harder it will be to analyze correctly. The most typical analysis to do here is to use your favorite library, (e.g. pandas or plyr), to compute the average and variance of the response metric for every treatment group, construct confidence intervals for each mean, and see if the confidence intervals overlap. Or even better, you can use a Welch t-test to assess the difference in means between the two groups.</p><p><strong>3.6 Some important topics we didn’t talk about</strong></p><p>We did not talk about analysis in a very formal way, we did not talk about the analysis tools that we use, we did not discuss the technical aspects of how we randomize our users or how we log the events, we did not mention anything about making sure that the implementation of the experiment is correct (Quality Assurance), we did not talk about how to size your experiment (or determining run time). We expect to cover some of these topics in other blog posts of our A/B testing series, so, keep an eye out for them!</p><h3>4. Wrap up</h3><p>Randomized experiments (aka A/B testing) are a powerful tool that allow us to make statements about causality. Tech companies use them a lot because gathering data is relatively easy and it allows them to objectively learn how users use their products fast and iterate based on what they observe. The framework that we use at Patreon is composed of mainly three concepts: <strong>observation units</strong>, <strong>treatments</strong> and <strong>response metrics</strong>. We briefly discussed what each one is, and how to identify them and use them in a website experiment context. We hope you enjoyed reading this post!</p><p>Reference: As mentioned before, this framework is based the Potential Outcomes Framework, also known as Rubin’s Causal Model. You can find a more formal discussion of it in the book <a href="https://www.amazon.com/Causal-Inference-Statistics-Biomedical-Sciences/dp/0521885884"><strong>Causal Inference for Statistics, Social, and Biomedical Sciences: An Introduction</strong></a><strong> </strong>(by Guido Imbens and Don Rubin).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3640d4271d1f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/art-work-behind-the-scenes-at-patreon/a-framework-to-design-randomized-experiments-the-right-way-3640d4271d1f">A Framework to Design Randomized Experiments (The Right Way)</a> was originally published in <a href="https://medium.com/art-work-behind-the-scenes-at-patreon">art/work -behind the scenes at patreon</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>