R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

Note: this analysis was performed using the open source software R and Rstudio.

Objective

The objective of this analysis is to find out whether how often people shop is related to how much they typically spend per purchase. Using data from the Retail Shopping Preferences Survey, I use simple linear regression and a scatterplot to examine the relationship between shopping frequency and spending category. The results may help marketers better understand shopping habits and plan promotions.

Dataset - We will be using datasets available in R for this tutorial

# Upload Final_Retail_Shopping_122.csv to your Posit project first
survey <- read.csv(
  "Final_Retail_Shopping_122.csv",
  na.strings = "",
  fileEncoding = "UTF-8",
  stringsAsFactors = FALSE
)

# Shopping frequency: scores 1–4, from least to most frequent
survey$frequency_score <- match(
  trimws(survey$How_Often),
  c(
    "Less than once a month",
    "1–2 times per month",
    "3–4 times per month",
    "5 or more times per month"
  )
)

# Spending category: scores 1–5, from lowest to highest
survey$spending_score <- match(
  trimws(survey$Average_Cost),
  c(
    "Less than $25",
    "$25–$74",
    "$75–$149",
    "$150–$499",
    "$500 or more"
  )
)

# Keep responses with both scores
regression_data <- survey[
  complete.cases(survey[c("frequency_score", "spending_score")]),
]

# Number of responses used
nrow(regression_data)
## [1] 14
# Simple linear regression: spending predicted by frequency
simple_model <- lm(
  spending_score ~ frequency_score,
  data = regression_data
)

# Display results
summary(simple_model)
## 
## Call:
## lm(formula = spending_score ~ frequency_score, data = regression_data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.2789 -0.6202 -0.2788  0.5240  1.9327 
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)       3.8558     0.7547   5.109 0.000258 ***
## frequency_score  -0.3942     0.2600  -1.517 0.155279    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.002 on 12 degrees of freedom
## Multiple R-squared:  0.1608, Adjusted R-squared:  0.0909 
## F-statistic:   2.3 on 1 and 12 DF,  p-value: 0.1553
# Confidence intervals
confint(simple_model)
##                      2.5 %    97.5 %
## (Intercept)      2.2114070 5.5001315
## frequency_score -0.9606272 0.1721657
# Scatterplot and regression line
plot(
  spending_score ~ frequency_score,
  data = regression_data,
  main = "Shopping Frequency and Spending",
  xlab = "Shopping frequency score (1–4)",
  ylab = "Spending category score (1–5)",
  xlim = c(1, 4),
  ylim = c(1, 5),
  xaxt = "n",
  yaxt = "n",
  pch = 16,
  col = "steelblue"
)

axis(1, at = 1:4)
axis(2, at = 1:5)

abline(simple_model, col = "red", lwd = 2)

Does Shopping More Often Mean Spending Less?

My chart shows that people who shop more often tend to spend less per purchase. However, the regression’s p-value was 0.155, so the relationship was not statistically significant. Shopping frequency explained about 16% of the variation in spending-category scores. With only 14 responses, I would need more data before making recommendations for marketers.

References

Bivariate Analysis Definition & Example https://www.statisticshowto.com/bivariate-analysis/#:~:text=Bivariate%20analysis%20means%20the%20analysis,the%20variables%20X%20and%20Y.

https://www.sciencedirect.com/topics/mathematics/bivariate-data