library(readr)

Hypothesis:

Null Hypothesis: H0: β1 = 0 Alternative Hypothesis: H1: β1 ≠ 0

data <- read_csv("ab_testing1.csv")
## Rows: 29 Columns: 2
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## dbl (2): Ads, Purchase
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
ls(data)
## [1] "Ads"      "Purchase"
head(data)
## # A tibble: 6 × 2
##     Ads Purchase
##   <dbl>    <dbl>
## 1     1      152
## 2     0       21
## 3     2       77
## 4     0       65
## 5     1      183
## 6     1       87
data$Ads <- factor(data$Ads, levels = c(0, 1, 2), labels = c("Control", "Ad_Version_1", "Ad_Version_2"))
is.factor(data$Ads)
## [1] TRUE
# First 15 observations of the Ads variable
data$Ads[1:15]
##  [1] Ad_Version_1 Control      Ad_Version_2 Control      Ad_Version_1
##  [6] Ad_Version_1 Ad_Version_2 Ad_Version_2 Ad_Version_2 Control     
## [11] Ad_Version_2 Ad_Version_2 Control      Ad_Version_2 Ad_Version_2
## Levels: Control Ad_Version_1 Ad_Version_2
# Regression analysis: Purchase ~ Ads
model <- lm(Purchase ~ Ads, data = data)
summary(model)
## 
## Call:
## lm(formula = Purchase ~ Ads, data = data)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -59.75 -22.75  -3.75  30.25  64.29 
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)        49.00      10.21   4.800 5.69e-05 ***
## AdsAd_Version_1    69.71      15.91   4.383 0.000171 ***
## AdsAd_Version_2    24.75      13.82   1.791 0.084982 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 32.28 on 26 degrees of freedom
## Multiple R-squared:  0.4262, Adjusted R-squared:  0.3821 
## F-statistic: 9.656 on 2 and 26 DF,  p-value: 0.0007308