R Tutorial: Baseline Conversion Rates

Learn how to calculate baseline conversion rates in R before running A/B tests. The tutorial uses tidyverse tools to find an overall 27.7% conversion rate, then breaks it down by month with lubridate and ggplot2 to spot seasonal patterns like summer and year-end spikes.
Chapters
In the previous lesson, we learned some of the principles of A B testing and took a look at our preliminary dataset. Let's spend some more time looking at our pre experiment or baseline values for an experiment before starting any A B testing experiment. You'll want to know your baseline value or the current value before any experimental changes happen. Why is this? Well, let's come back to our hypothesis. We said we expect a different photo to result in more conversions, but what does more really mean in this context? Is it compared to the conversion rate in the last year, today, next week? Or what about relative to when the experiment is actually run? If you're not planning to run your experiment for a couple months, there could be other factors that change your conversion rates between now and when the experiment is running. To have a clearly defined hypothesis and experiment, you need to know what your baseline for comparison is. Otherwise you can't really know if your experiment had an effect or not. For our experiment to start, we'll compute the current pre experiment conversion rate over all of time. As mentioned earlier, for most of our analyses we'll use a suite of packages referred to as the Tidyverse. Here. These packages will help us manipulate and plot our baseline data. We'll also read in our click data just as we did in the previous exercise. From here we can find the mean of our clicked Adopt Today column to see what percentage of the time people clicked, also known as our conversion rate. We can do that with the dplyr function summarize using the pipe to connect our data to the function. We then use the mean function to compute the conversion rate, averaging the ones and zeros in the clicked Adopt day column. If we look at the value of this new summarized column, we see that it is 0.277. So a conversion rate of 27.7%, meaning about 27 out of 100 visitors to the website clicked Adopt a day. With the current homepage picture, we've successfully computed our pre experiment conversion rate. However, we computed the conversion rate over the entire year. Maybe in certain months people are more likely to adopt than in other months. We'll compute conversion rates for each month to see if there's an effect of seasonality. Instead of summarizing over the entire data set, we'll add a group by from dplyr by month so we can find the conversion rate for each month of the year. Currently, the Visit date column gives dates up to the day of the month. To round off just the month, we'll use the Lubridate package and the Function month. Now Instead of getting a single number, our output is a conversion rate for each month the year, as we can see in the updated data frame. To really understand how conversion rates change throughout the year, it's useful to plot our data. We can do that with the package ggplot2 from the tidyverse. First, we'll save our summarized data in a dataframe. Click Data Sum. Then we'll use the new data frame in a ggplotcall, setting the X axis to our month column and the Y axis to our computed conversion rate column. To display the data, we'll plot the dots and connect them by a line with GOM point and GOM line. From this plot, it's clear that conversion rates are not steady across the year. Instead, rates are much higher in the summer months and at the end of the year than during the rest of the year. In the following exercises, we'll get some practice looking at.
More from Richie

#359 My Best Friend is AI with Valerie Tiberius, Professor of Philosophy at University of Minnesota

How AI Agents Will Work While You Sleep | Ruslan Salakhutdinov, Professor at Carnegie Mellon

#358 How AI Agents Will Work While You Sleep | Ruslan Salakhutdinov, Professor at Carnegie Mellon







