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.
The objective of this tutorial is to explain how bivariate analysis works.This analysis can be used by marketers to make decisions about their pricing strategies, advertising strategies, and promotion stratgies among others.
Bivariate analysis is one of the simplest forms of statistical analysis. It is generally used to find out if there is a relationship between two sets of values (or two variables). That said, it usually involves the variables X and Y (statisticshowto.com).
survey <- readr::read_csv("Retail Shopping Preferences Survey.csv",
show_col_types = FALSE)
# Remove Qualtrics metadata rows and keep completed pilot responses
pilot <- subset(survey[-c(1, 2), ],
Status == "Survey Preview" & Finished == "True")
# Score response categories from lowest to highest
motivation_levels <- c("Not a motivation", "Sometimes a motivation",
"Strong motivation")
analysis <- na.omit(data.frame(
shop_for_self = match(pilot$Q6_2, motivation_levels),
shop_for_gift = match(pilot$Q6_3, motivation_levels),
frequency = match(pilot$Q3, c(
"Less than once a month", "1–2 times per month",
"3–4 times per month", "5 or more times per month"
)),
spending = match(pilot$Q4, c(
"Less than $25", "$25–$74", "$75–$149", "$150–$499", "$500 or more"
))
))
model <- lm(spending ~ frequency, data = analysis)
plot(spending ~ frequency, data = analysis, pch = 16,
xlab = "Shopping frequency score", ylab = "Spending category score",
sub = "Pilot data for demonstration only")
abline(model, col = "steelblue", lwd = 2)
summary(model)
##
## Call:
## lm(formula = spending ~ frequency, data = analysis)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.0833 -0.7917 -0.3750 0.5000 1.9167
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.6667 1.0829 3.386 0.0117 *
## frequency -0.2917 0.3829 -0.762 0.4710
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.083 on 7 degrees of freedom
## Multiple R-squared: 0.07656, Adjusted R-squared: -0.05536
## F-statistic: 0.5804 on 1 and 7 DF, p-value: 0.471
# Simple linear regression
simple_model <- lm(spending ~ frequency, data = analysis)
# Multiple linear regression
multivariate_model <- lm(
spending ~ frequency + shop_for_self + shop_for_gift,
data = analysis
)
summary(simple_model)
##
## Call:
## lm(formula = spending ~ frequency, data = analysis)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.0833 -0.7917 -0.3750 0.5000 1.9167
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.6667 1.0829 3.386 0.0117 *
## frequency -0.2917 0.3829 -0.762 0.4710
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.083 on 7 degrees of freedom
## Multiple R-squared: 0.07656, Adjusted R-squared: -0.05536
## F-statistic: 0.5804 on 1 and 7 DF, p-value: 0.471
summary(multivariate_model)
##
## Call:
## lm(formula = spending ~ frequency + shop_for_self + shop_for_gift,
## data = analysis)
##
## Residuals:
## 8 9 10 11 12 13 14 16 17
## -0.8291 -0.3892 1.1646 -0.1487 0.9304 -1.1614 1.4177 -0.0538 -0.9304
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.661392 1.980565 2.354 0.0653 .
## frequency -0.325949 0.450335 -0.724 0.5016
## shop_for_self -0.433544 0.587100 -0.738 0.4934
## shop_for_gift 0.006329 0.518022 0.012 0.9907
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.209 on 5 degrees of freedom
## Multiple R-squared: 0.1776, Adjusted R-squared: -0.3158
## F-statistic: 0.3599 on 3 and 5 DF, p-value: 0.7852
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