Research question

Can we say that there is a difference between the average spend money with credit card in Female and Male in India?

Data

mydata <- read.table( "./Credit card transactions - India - Simple.csv", header = TRUE, sep = ",")

head(mydata)
##   index                  City      Date Card.Type Exp.Type Gender Amount
## 1     0          Delhi, India 29-Oct-14      Gold    Bills      F  82475
## 2     1 Greater Mumbai, India 22-Aug-14  Platinum    Bills      F  32555
## 3     2      Bengaluru, India 27-Aug-14    Silver    Bills      F 101738
## 4     3 Greater Mumbai, India 12-Apr-14 Signature    Bills      F 123424
## 5     4      Bengaluru, India  5-May-15      Gold    Bills      F 171574
## 6     5          Delhi, India  8-Sep-14    Silver    Bills      F 100036

Description of data

  • Unit of observation: credit card transactions in India

  • Sample size: 26052 observations

  • Variables:

    • Index

    • City: the city in which the transaction took place

    • Date: the date of the transaction

    • Card Type: the type of credit card used for the transaction

    • Exp Type: the type of expense associated with the transaction

    • Gender: F or M

    • Amount: The amount of the transaction

  • Source: https://www.kaggle.com/datasets/ayushchandramaurya/credit-card-spendings

Clear the data

mydata$GenderFactor <- factor(mydata$Gender, 
                             levels = c('F', 'M'), 
                             labels = c("Female", "Male"))
library(psych)
## Warning: package 'psych' was built under R version 4.3.3
describeBy(mydata$Amount, g = mydata$GenderFactor)
## 
##  Descriptive statistics by group 
## group: Female
##    vars     n   mean       sd median  trimmed      mad  min    max  range skew
## X1    1 13680 161207 115965.2 154797 153810.4 113438.9 1005 998077 997072  2.3
##    kurtosis     se
## X1    11.92 991.48
## ------------------------------------------------------------ 
## group: Male
##    vars     n     mean       sd median  trimmed      mad  min    max  range
## X1    1 12372 151109.1 86282.54 151242 151331.6 110364.7 1018 299981 298963
##     skew kurtosis     se
## X1 -0.02     -1.2 775.72

T-test

First I have to check the assumptions of the independent t-test with Welch correction:

library(ggplot2)
## 
## Attaching package: 'ggplot2'
## The following objects are masked from 'package:psych':
## 
##     %+%, alpha
Transaction_F <- ggplot(mydata[mydata$GenderFactor == "Female",  ], aes(x = Amount)) +
  theme_linedraw() + 
  geom_histogram() +
  ggtitle("Female")

Transaction_M <- ggplot(mydata[mydata$GenderFactor == "Male",  ], aes(x = Amount)) +
  theme_linedraw() + 
  geom_histogram() +
  ggtitle("Male")

library(ggpubr)
## Warning: package 'ggpubr' was built under R version 4.3.3
ggarrange(Transaction_F, Transaction_M,
          ncol = 2, nrow = 1)
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

As the number of observations is very large, I can trust in the histogram and say that the distribution of Amount is not normal in the populations. I can not do the Shapiro test with such number of observations.

Since the assumption of normal distribution is not met we have to perform the corresponding non-parametric alternative test: Wilcoxon Rank Sum Test.

\(H_0\): There is no difference in location distribution of money spending with credit card in Female and Male in India. \(H_1\): There is a difference in location distribution of money spending with credit card in Female and Male in India.

wilcox.test(mydata$Amount ~ mydata$GenderFactor,
            paired = FALSE,
            correct = FALSE,
            exact = FALSE,
            alternative = "two.sided")
## 
##  Wilcoxon rank sum test
## 
## data:  mydata$Amount by mydata$GenderFactor
## W = 86097896, p-value = 0.01507
## alternative hypothesis: true location shift is not equal to 0

I reject \(H_0\) at p = 0.01507 as p < 0.05

Effect size:

#install.packages('effectsize')
library(effectsize)
## Warning: package 'effectsize' was built under R version 4.3.3
## 
## Attaching package: 'effectsize'
## The following object is masked from 'package:psych':
## 
##     phi
effectsize(wilcox.test(mydata$Amount ~ mydata$GenderFactor,
                       paired = FALSE,
                       correct = FALSE,
                       exact = FALSE,
                       alternative = "two.sided"))
## r (rank biserial) |       95% CI
## --------------------------------
## 0.02              | [0.00, 0.03]
interpret_rank_biserial(0.02)
## [1] "tiny"
## (Rules: funder2019)

Conclusion

Based on the sample data, I find that men and women differ in terms of amount of money spent with credit card in India as $ p < 0.05$. Female spend more but the difference in distribution is tiny (𝑟 = 0.02).