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 goal of this project is to use survey data to see whether people who give higher ratings to shopping for special events also tend to shop more often. I will use R to make a scatterplot and fit a regression line to look for a pattern.

Dataset - We will be using one online dataset available in R for this tutorial

Segmentation <- read_csv('Final_Retail_Shopping_122.csv')
plot(How_Often ~ Special_Event, data = Segmentation, pch = 16)
abline(lm(How_Often ~ Special_Event, Segmentation), col = "grey20")
library(readr)
library(readr)
 Segmentation <- read_csv('Final_Retail_Shopping_122.csv')
plot(How_Often ~ Special_Event, data = Segmentation)

Shopping frequency regression

Segmentation <- readr::read_csv("/cloud/project/Final_Retail_Shopping_122.csv",
                                show_col_types = FALSE)

# Estimate monthly trips using range midpoints and 5 for the 5+ category.
frequency_scores <- c(
  "Less than once a month" = 0.5,
  "1–2 times per month" = 1.5,
  "3–4 times per month" = 3.5,
  "5 or more times per month" = 5
)
Segmentation$How_Often_num <- unname(
  frequency_scores[trimws(Segmentation$How_Often)]
)

frequency_model <- lm(How_Often_num ~ Special_Event, data = Segmentation)
summary(frequency_model)
## 
## Call:
## lm(formula = How_Often_num ~ Special_Event, data = Segmentation)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2.3333 -0.4583  0.6667  0.6667  2.1667 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)  
## (Intercept)     4.5833     1.7107   2.679   0.0316 *
## Special_Event  -0.8750     0.8115  -1.078   0.3167  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.623 on 7 degrees of freedom
##   (7 observations deleted due to missingness)
## Multiple R-squared:  0.1424, Adjusted R-squared:  0.01993 
## F-statistic: 1.163 on 1 and 7 DF,  p-value: 0.3167
plot(How_Often_num ~ Special_Event, data = Segmentation,
     xlab = "Special event score",
     ylab = "Estimated shopping trips per month", pch = 16)
abline(frequency_model, col = "blue", lwd = 2)

Conclusion

The survey gave little evidence that people who rated shopping for special events more highly also shopped more often. The regression used only 9 of the 16 survey responses because 7 were missing a special event rating. A larger survey with more complete responses could help show whether there is a clear relationship.

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