Load library
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
Read the data
artea<-read.csv("~/Desktop/R/Artea_tran.csv",header=T,sep=',')
Baseline model
# create the linear model
result<-lm(revenue_after~ test_coupon + channel_facebook +channel_instagram +channel_referral +channel_other +num_past_purch +spent_last_purchase +weeks_since_visit +browsing_minutes+shopping_cart,data=artea) 

# review the results
summary(result) 
## 
## Call:
## lm(formula = revenue_after ~ test_coupon + channel_facebook + 
##     channel_instagram + channel_referral + channel_other + num_past_purch + 
##     spent_last_purchase + weeks_since_visit + browsing_minutes + 
##     shopping_cart, data = artea)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -74.072 -10.128  -3.944   1.662 219.027 
## 
## Coefficients:
##                      Estimate Std. Error t value Pr(>|t|)    
## (Intercept)         -2.888538   1.031453  -2.800 0.005123 ** 
## test_coupon         -0.282455   0.609365  -0.464 0.643009    
## channel_facebook     6.044806   0.816559   7.403 1.56e-13 ***
## channel_instagram    5.976560   0.730055   8.186 3.39e-16 ***
## channel_referral     6.656827   1.477178   4.506 6.74e-06 ***
## channel_other        8.695892   2.055831   4.230 2.38e-05 ***
## num_past_purch       3.172673   0.131133  24.194  < 2e-16 ***
## spent_last_purchase -0.014413   0.006052  -2.382 0.017279 *  
## weeks_since_visit   -1.112759   0.134906  -8.248  < 2e-16 ***
## browsing_minutes     0.160609   0.044640   3.598 0.000324 ***
## shopping_cart        9.308647   0.677930  13.731  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 21.53 on 4989 degrees of freedom
## Multiple R-squared:  0.1712, Adjusted R-squared:  0.1695 
## F-statistic: 103.1 on 10 and 4989 DF,  p-value: < 2.2e-16
# check the residual plot
plot(result$residuals)

comment: customers from diifrent channels are not heterogeneous in response to coupon
# channel-facebook
artea<-artea %>%
  mutate(channel_facebookXcoupon=channel_facebook*test_coupon)

result1<-lm(revenue_after~ test_coupon + channel_facebook +channel_instagram +channel_referral +channel_other +num_past_purch +spent_last_purchase +weeks_since_visit +browsing_minutes+shopping_cart + channel_facebookXcoupon,data=artea) 

summary(result1)
## 
## Call:
## lm(formula = revenue_after ~ test_coupon + channel_facebook + 
##     channel_instagram + channel_referral + channel_other + num_past_purch + 
##     spent_last_purchase + weeks_since_visit + browsing_minutes + 
##     shopping_cart + channel_facebookXcoupon, data = artea)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -74.037 -10.134  -3.943   1.660 219.059 
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)             -2.863436   1.041411  -2.750 0.005989 ** 
## test_coupon             -0.338023   0.686689  -0.492 0.622564    
## channel_facebook         5.911361   1.115541   5.299 1.21e-07 ***
## channel_instagram        5.976066   0.730131   8.185 3.43e-16 ***
## channel_referral         6.658866   1.477367   4.507 6.72e-06 ***
## channel_other            8.696456   2.056033   4.230 2.38e-05 ***
## num_past_purch           3.172336   0.131159  24.187  < 2e-16 ***
## spent_last_purchase     -0.014417   0.006053  -2.382 0.017260 *  
## weeks_since_visit       -1.112130   0.134966  -8.240  < 2e-16 ***
## browsing_minutes         0.160780   0.044654   3.601 0.000321 ***
## shopping_cart            9.305380   0.678251  13.720  < 2e-16 ***
## channel_facebookXcoupon  0.262163   1.492996   0.176 0.860619    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 21.53 on 4988 degrees of freedom
## Multiple R-squared:  0.1712, Adjusted R-squared:  0.1694 
## F-statistic: 93.67 on 11 and 4988 DF,  p-value: < 2.2e-16
# channel-instagram 
artea<-artea %>%
  mutate(channel_instagramXcoupon=channel_instagram*test_coupon)

result2<-lm(revenue_after~ test_coupon + channel_facebook +channel_instagram +channel_referral +channel_other +num_past_purch +spent_last_purchase +weeks_since_visit +browsing_minutes+shopping_cart + channel_instagramXcoupon,data=artea) 

summary(result2)
## 
## Call:
## lm(formula = revenue_after ~ test_coupon + channel_facebook + 
##     channel_instagram + channel_referral + channel_other + num_past_purch + 
##     spent_last_purchase + weeks_since_visit + browsing_minutes + 
##     shopping_cart + channel_instagramXcoupon, data = artea)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -74.890 -10.158  -3.929   1.704 218.214 
## 
## Coefficients:
##                           Estimate Std. Error t value Pr(>|t|)    
## (Intercept)              -2.496595   1.054380  -2.368 0.017931 *  
## test_coupon              -1.011535   0.733655  -1.379 0.168030    
## channel_facebook          6.057018   0.816409   7.419 1.38e-13 ***
## channel_instagram         4.818582   0.976853   4.933 8.37e-07 ***
## channel_referral          6.675761   1.476893   4.520 6.32e-06 ***
## channel_other             8.698613   2.055382   4.232 2.36e-05 ***
## num_past_purch            3.172964   0.131104  24.202  < 2e-16 ***
## spent_last_purchase      -0.014351   0.006051  -2.372 0.017745 *  
## weeks_since_visit        -1.115326   0.134884  -8.269  < 2e-16 ***
## browsing_minutes          0.158558   0.044645   3.552 0.000387 ***
## shopping_cart             9.310931   0.677783  13.737  < 2e-16 ***
## channel_instagramXcoupon  2.348603   1.316757   1.784 0.074545 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 21.53 on 4988 degrees of freedom
## Multiple R-squared:  0.1717, Adjusted R-squared:  0.1699 
## F-statistic: 94.01 on 11 and 4988 DF,  p-value: < 2.2e-16
# channel-referral
artea<-artea %>%
  mutate(channel_referralXcoupon=channel_referral*test_coupon)

result3<-lm(revenue_after~ test_coupon + channel_facebook +channel_instagram +channel_referral +channel_other +num_past_purch +spent_last_purchase +weeks_since_visit +browsing_minutes+shopping_cart + channel_referralXcoupon,data=artea) 

summary(result3)
## 
## Call:
## lm(formula = revenue_after ~ test_coupon + channel_facebook + 
##     channel_instagram + channel_referral + channel_other + num_past_purch + 
##     spent_last_purchase + weeks_since_visit + browsing_minutes + 
##     shopping_cart + channel_referralXcoupon, data = artea)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -74.051 -10.104  -3.944   1.650 219.052 
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)             -2.863057   1.034037  -2.769 0.005647 ** 
## test_coupon             -0.330724   0.624398  -0.530 0.596365    
## channel_facebook         6.045583   0.816633   7.403 1.55e-13 ***
## channel_instagram        5.976819   0.730119   8.186 3.40e-16 ***
## channel_referral         6.123826   2.106193   2.908 0.003659 ** 
## channel_other            8.696057   2.056011   4.230 2.38e-05 ***
## num_past_purch           3.172899   0.131146  24.194  < 2e-16 ***
## spent_last_purchase     -0.014433   0.006053  -2.385 0.017139 *  
## weeks_since_visit       -1.112689   0.134918  -8.247  < 2e-16 ***
## browsing_minutes         0.160486   0.044645   3.595 0.000328 ***
## shopping_cart            9.310416   0.678008  13.732  < 2e-16 ***
## channel_referralXcoupon  1.016981   2.864340   0.355 0.722568    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 21.53 on 4988 degrees of freedom
## Multiple R-squared:  0.1712, Adjusted R-squared:  0.1694 
## F-statistic: 93.68 on 11 and 4988 DF,  p-value: < 2.2e-16
# channel-other
artea<-artea %>%
  mutate(channel_otherXcoupon=channel_other*test_coupon)

result4<-lm(revenue_after~ test_coupon + channel_facebook +channel_instagram +channel_referral +channel_other +num_past_purch +spent_last_purchase +weeks_since_visit +browsing_minutes+shopping_cart + channel_otherXcoupon,data=artea) 

summary(result4)
## 
## Call:
## lm(formula = revenue_after ~ test_coupon + channel_facebook + 
##     channel_instagram + channel_referral + channel_other + num_past_purch + 
##     spent_last_purchase + weeks_since_visit + browsing_minutes + 
##     shopping_cart + channel_otherXcoupon, data = artea)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -74.099 -10.125  -3.964   1.645 219.007 
## 
## Coefficients:
##                       Estimate Std. Error t value Pr(>|t|)    
## (Intercept)          -2.907979   1.032243  -2.817 0.004864 ** 
## test_coupon          -0.234961   0.616571  -0.381 0.703163    
## channel_facebook      6.043809   0.816622   7.401 1.58e-13 ***
## channel_instagram     5.977139   0.730110   8.187 3.38e-16 ***
## channel_referral      6.654919   1.477293   4.505 6.80e-06 ***
## channel_other         9.721354   2.884408   3.370 0.000757 ***
## num_past_purch        3.172900   0.131143  24.194  < 2e-16 ***
## spent_last_purchase  -0.014380   0.006053  -2.376 0.017552 *  
## weeks_since_visit    -1.112777   0.134916  -8.248  < 2e-16 ***
## browsing_minutes      0.160200   0.044650   3.588 0.000337 ***
## shopping_cart         9.305554   0.678008  13.725  < 2e-16 ***
## channel_otherXcoupon -2.051372   4.046990  -0.507 0.612256    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 21.53 on 4988 degrees of freedom
## Multiple R-squared:  0.1712, Adjusted R-squared:  0.1694 
## F-statistic: 93.69 on 11 and 4988 DF,  p-value: < 2.2e-16