ANALIZA POVEZANOSTI MED DVEMA KATEGORIALNIMA SPREMENLJIVKAMA 1. Raziskovalno vprašanje: Ali lahko trdimo, da obstaja povezanost med spolom nakupovalcev in načinom plačila?

podatki <- read.table ("./shopping_trends.csv", header=TRUE, sep=";", dec=",")

head(podatki)
##   Customer.ID Age Gender Item.Purchased Category Purchase.Amount..USD.
## 1           1  55   Male         Blouse Clothing                    53
## 2           2  19   Male        Sweater Clothing                    64
## 3           3  50   Male          Jeans Clothing                    73
## 4           4  21   Male        Sandals Footwear                    90
## 5           5  45   Male         Blouse Clothing                    49
## 6           6  46   Male       Sneakers Footwear                    20
##        Location Size     Color Season Review.Rating Subscription.Status
## 1      Kentucky    L      Gray Winter           3.1                 Yes
## 2         Maine    L    Maroon Winter           3.1                 Yes
## 3 Massachusetts    S    Maroon Spring           3.1                 Yes
## 4  Rhode Island    M    Maroon Spring           3.5                 Yes
## 5        Oregon    M Turquoise Spring           2.7                 Yes
## 6       Wyoming    M     White Summer           2.9                 Yes
##   Shipping.Type Discount.Applied Promo.Code.Used Previous.Purchases
## 1       Express              Yes             Yes                 14
## 2       Express              Yes             Yes                  2
## 3 Free Shipping              Yes             Yes                 23
## 4  Next Day Air              Yes             Yes                 49
## 5 Free Shipping              Yes             Yes                 31
## 6      Standard              Yes             Yes                 14
##   Payment.Method Frequency.of.Purchases
## 1          Venmo            Fortnightly
## 2           Cash            Fortnightly
## 3    Credit Card                 Weekly
## 4         PayPal                 Weekly
## 5         PayPal               Annually
## 6          Venmo                 Weekly
podatki$Gender[podatki$Gender=="Male"] ="1"
podatki$Gender[podatki$Gender=="Female"] = "2"
podatki$Payment.Method[podatki$Payment.Method== "Bank Transfer" ] = "1"
podatki$Payment.Method[podatki$Payment.Method== "Cash" ] = "2"
podatki$Payment.Method[podatki$Payment.Method== "Credit Card" ] = "3"
podatki$Payment.Method[podatki$Payment.Method== "Debit Card" ] = "4"
podatki$Payment.Method[podatki$Payment.Method== "PayPal" ] = "5"
podatki$Payment.Method[podatki$Payment.Method== "Venmo" ] = "6"

head(podatki)
##   Customer.ID Age Gender Item.Purchased Category Purchase.Amount..USD.
## 1           1  55      1         Blouse Clothing                    53
## 2           2  19      1        Sweater Clothing                    64
## 3           3  50      1          Jeans Clothing                    73
## 4           4  21      1        Sandals Footwear                    90
## 5           5  45      1         Blouse Clothing                    49
## 6           6  46      1       Sneakers Footwear                    20
##        Location Size     Color Season Review.Rating Subscription.Status
## 1      Kentucky    L      Gray Winter           3.1                 Yes
## 2         Maine    L    Maroon Winter           3.1                 Yes
## 3 Massachusetts    S    Maroon Spring           3.1                 Yes
## 4  Rhode Island    M    Maroon Spring           3.5                 Yes
## 5        Oregon    M Turquoise Spring           2.7                 Yes
## 6       Wyoming    M     White Summer           2.9                 Yes
##   Shipping.Type Discount.Applied Promo.Code.Used Previous.Purchases
## 1       Express              Yes             Yes                 14
## 2       Express              Yes             Yes                  2
## 3 Free Shipping              Yes             Yes                 23
## 4  Next Day Air              Yes             Yes                 49
## 5 Free Shipping              Yes             Yes                 31
## 6      Standard              Yes             Yes                 14
##   Payment.Method Frequency.of.Purchases
## 1              6            Fortnightly
## 2              2            Fortnightly
## 3              3                 Weekly
## 4              5                 Weekly
## 5              5               Annually
## 6              6                 Weekly
podatki$GenderF <- factor(podatki$Gender,
                          levels = c(1, 2),
                          labels = c("M", "F"))

podatki$Payment.MethodF <- factor(podatki$Payment.Method,
                            levels = c(1, 2, 3, 4, 5, 6),
                            labels = c("Bank Transfer", "Cash", "Credit Card", "Debit Card", "Paypal", "Venmo"))
head(podatki)
##   Customer.ID Age Gender Item.Purchased Category Purchase.Amount..USD.
## 1           1  55      1         Blouse Clothing                    53
## 2           2  19      1        Sweater Clothing                    64
## 3           3  50      1          Jeans Clothing                    73
## 4           4  21      1        Sandals Footwear                    90
## 5           5  45      1         Blouse Clothing                    49
## 6           6  46      1       Sneakers Footwear                    20
##        Location Size     Color Season Review.Rating Subscription.Status
## 1      Kentucky    L      Gray Winter           3.1                 Yes
## 2         Maine    L    Maroon Winter           3.1                 Yes
## 3 Massachusetts    S    Maroon Spring           3.1                 Yes
## 4  Rhode Island    M    Maroon Spring           3.5                 Yes
## 5        Oregon    M Turquoise Spring           2.7                 Yes
## 6       Wyoming    M     White Summer           2.9                 Yes
##   Shipping.Type Discount.Applied Promo.Code.Used Previous.Purchases
## 1       Express              Yes             Yes                 14
## 2       Express              Yes             Yes                  2
## 3 Free Shipping              Yes             Yes                 23
## 4  Next Day Air              Yes             Yes                 49
## 5 Free Shipping              Yes             Yes                 31
## 6      Standard              Yes             Yes                 14
##   Payment.Method Frequency.of.Purchases GenderF Payment.MethodF
## 1              6            Fortnightly       M           Venmo
## 2              2            Fortnightly       M            Cash
## 3              3                 Weekly       M     Credit Card
## 4              5                 Weekly       M          Paypal
## 5              5               Annually       M          Paypal
## 6              6                 Weekly       M           Venmo

Sledi parametrični preizkus H0: Spremenljivki nista povezani. H1: Spremenljivki sta povezani.

hi_kvadrat <- chisq.test(podatki$GenderF, podatki$Payment.MethodF,
                         correct=FALSE)
hi_kvadrat
## 
##  Pearson's Chi-squared test
## 
## data:  podatki$GenderF and podatki$Payment.MethodF
## X-squared = 4.8776, df = 5, p-value = 0.431

H0 ne moremo zavrniti, ne moremo trditi, da sta spol in način plačila povezana.

addmargins(hi_kvadrat$observed)
##                podatki$Payment.MethodF
## podatki$GenderF Bank Transfer Cash Credit Card Debit Card Paypal Venmo  Sum
##             M             409  458         448        455    456   426 2652
##             F             203  212         223        181    221   208 1248
##             Sum           612  670         671        636    677   634 3900
addmargins(round(hi_kvadrat$expected, 2))
##                podatki$Payment.MethodF
## podatki$GenderF Bank Transfer  Cash Credit Card Debit Card Paypal  Venmo  Sum
##             M          416.16 455.6      456.28     432.48 460.36 431.12 2652
##             F          195.84 214.4      214.72     203.52 216.64 202.88 1248
##             Sum        612.00 670.0      671.00     636.00 677.00 634.00 3900
library(effectsize)

effectsize::cramers_v(podatki$GenderF, podatki$Payment.MethodF)
## Cramer's V (adj.) |       95% CI
## --------------------------------
## 0.00              | [0.00, 1.00]
## 
## - One-sided CIs: upper bound fixed at [1.00].
interpret_cramers_v(0.00)
## [1] "tiny"
## (Rules: funder2019)

Velikost učinka

fisher.test(podatki$GenderF, podatki$Payment.Method,
               simulate.p.value=TRUE)
## 
##  Fisher's Exact Test for Count Data with simulated p-value (based on
##  2000 replicates)
## 
## data:  podatki$GenderF and podatki$Payment.Method
## p-value = 0.4443
## alternative hypothesis: two.sided

Primernejši se mi zdi parametrični preiskus, saj so izpolnjene vse predpostavke.

Vir podatkov: Banerjee, S. (2022). Customer Shopping Trends Dataset. Kaggle. https://www.kaggle.com/datasets/iamsouravbanerjee/customer-shopping-trends-dataset?select=shopping_trends_updated.csv