Do shoppers who consider free delivery important also consider an immediate discount important? Does including preferences for loyalty points and personalized offers improve the explanation?
I used our team’s Customer Shopping and Promotion Preferences survey. My outcome is the importance of a discount on today’s purchase. My simple model uses free-delivery importance as the predictor. My multiple model adds loyalty-point importance and personalized-offer importance.
survey_raw <- read.csv(
"Customer Shopping and Promotion Preferences raw data.csv",
stringsAsFactors = FALSE,
check.names = FALSE,
na.strings = c("", "NA"),
fileEncoding = "UTF-8-BOM"
)
dim(survey_raw)
## [1] 53 31
The first two imported rows contain question descriptions and import information rather than respondent answers. I removed these rows without changing the original file.
survey_responses <- survey_raw[-c(1, 2), ]
rownames(survey_responses) <- NULL
dim(survey_responses)
## [1] 51 31
I checked whether responses were finished, had reached 100% progress, and had the standard recorded-response status.
These fields help identify incomplete or preview records, although they cannot identify every possible test response.
table(survey_responses$Finished, useNA = "ifany")
##
## 1
## 51
table(survey_responses$Progress, useNA = "ifany")
##
## 100
## 51
table(survey_responses$Status, useNA = "ifany")
##
## 0
## 51
keep_response <- (
survey_responses$Finished == "1" &
survey_responses$Progress == "100" &
survey_responses$Status == "0"
)
keep_response[is.na(keep_response)] <- FALSE
completed_responses <- survey_responses[
keep_response,
,
drop = FALSE
]
dim(completed_responses)
## [1] 51 31
question_columns <- grep(
"^Q[0-9]",
names(completed_responses),
value = TRUE
)
missing_answers <- sapply(
completed_responses[question_columns],
function(x) {
is.na(x) | trimws(x) == ""
}
)
colSums(missing_answers)
## Q2 Q3 Q4 Q5 Q6 Q7 Q8_1 Q8_2 Q8_3 Q8_4 Q8_5 Q9
## 2 2 3 2 2 2 3 3 4 4 4 3
Some records were marked finished but contained no survey answers. I removed these records.
empty_responses <- (
rowSums(missing_answers) == length(question_columns)
)
sum(empty_responses)
## [1] 2
answered_responses <- completed_responses[
!empty_responses,
,
drop = FALSE
]
dim(answered_responses)
## [1] 49 31
I selected four questions with the same clearly defined rating scale:
The original scale runs from 0 = most important to 10 = least important.
rating_columns <- c(
"Q8_1", "Q8_2", "Q8_3", "Q8_4"
)
benefit_ratings <- as.data.frame(
lapply(
answered_responses[rating_columns],
function(x) as.numeric(trimws(x))
)
)
str(benefit_ratings)
## 'data.frame': 49 obs. of 4 variables:
## $ Q8_1: num NA 0 3 4 6 0 2 7 5 7 ...
## $ Q8_2: num NA 0 2 2 3 7 5 4 2 9 ...
## $ Q8_3: num NA 6 6 1 7 5 2 3 8 8 ...
## $ Q8_4: num NA 2 5 5 8 1 2 6 8 10 ...
colSums(is.na(benefit_ratings))
## Q8_1 Q8_2 Q8_3 Q8_4
## 1 1 2 2
I subtracted each original rating from 10. In the recoded variables, higher scores mean greater importance.
For example, an original score of 0 becomes 10, and an original score of 10 becomes 0.
valid_scale <- vapply(
benefit_ratings,
function(x) {
all(is.na(x) | (x >= 0 & x <= 10))
},
logical(1)
)
stopifnot(all(valid_scale))
analysis_candidates <- data.frame(
discount_importance = 10 - benefit_ratings$Q8_1,
delivery_importance = 10 - benefit_ratings$Q8_2,
loyalty_importance = 10 - benefit_ratings$Q8_3,
personalized_importance = 10 - benefit_ratings$Q8_4
)
summary(analysis_candidates)
## discount_importance delivery_importance loyalty_importance
## Min. : 0.000 Min. : 0.000 Min. : 0.000
## 1st Qu.: 2.000 1st Qu.: 4.750 1st Qu.: 3.500
## Median : 5.000 Median : 6.500 Median : 6.000
## Mean : 5.479 Mean : 5.958 Mean : 5.511
## 3rd Qu.: 9.000 3rd Qu.: 8.000 3rd Qu.: 8.000
## Max. :10.000 Max. :10.000 Max. :10.000
## NAs :1 NAs :1 NAs :2
## personalized_importance
## Min. : 0.000
## 1st Qu.: 4.000
## Median : 6.000
## Mean : 5.766
## 3rd Qu.: 8.000
## Max. :10.000
## NAs :2
I excluded responses missing any of the four selected ratings rather than replacing them with average values.
Both regressions use the same complete respondents. This makes the comparison reflect the additional predictors rather than a change in sample size. However, excluding missing responses could introduce bias if those respondents differ from the retained respondents.
sum(!complete.cases(analysis_candidates))
## [1] 3
analysis_data <- analysis_candidates[
complete.cases(analysis_candidates),
,
drop = FALSE
]
dim(analysis_data)
## [1] 46 4
colSums(is.na(analysis_data))
## discount_importance delivery_importance loyalty_importance
## 0 0 0
## personalized_importance
## 0
cleaning_summary <- data.frame(
Stage = c(
"Original response records",
"Completed standard-status records",
"Records with survey answers",
"Complete cases for both models"
),
Responses = c(
nrow(survey_responses),
nrow(completed_responses),
nrow(answered_responses),
nrow(analysis_data)
)
)
knitr::kable(cleaning_summary)
| Stage | Responses |
|---|---|
| Original response records | 51 |
| Completed standard-status records | 51 |
| Records with survey answers | 49 |
| Complete cases for both models | 46 |
descriptive_table <- data.frame(
Variable = names(analysis_data),
Mean = sapply(analysis_data, mean),
Standard_deviation = sapply(analysis_data, sd),
Minimum = sapply(analysis_data, min),
Maximum = sapply(analysis_data, max)
)
rownames(descriptive_table) <- NULL
knitr::kable(descriptive_table, digits = 2)
| Variable | Mean | Standard_deviation | Minimum | Maximum |
|---|---|---|---|---|
| discount_importance | 5.54 | 3.48 | 0 | 10 |
| delivery_importance | 6.17 | 3.14 | 0 | 10 |
| loyalty_importance | 5.63 | 3.02 | 0 | 10 |
| personalized_importance | 5.78 | 2.92 | 0 | 10 |
The outcome is discount importance. The predictor is free-delivery importance.
simple_model <- lm(
discount_importance ~ delivery_importance,
data = analysis_data
)
summary(simple_model)
##
## Call:
## lm(formula = discount_importance ~ delivery_importance, data = analysis_data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -8.0189 -1.5491 0.2456 1.9811 6.5100
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.5491 0.9342 1.658 0.104
## delivery_importance 0.6470 0.1351 4.787 1.94e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.85 on 44 degrees of freedom
## Multiple R-squared: 0.3425, Adjusted R-squared: 0.3275
## F-statistic: 22.92 on 1 and 44 DF, p-value: 1.941e-05
A one-point increase in free-delivery importance is associated with approximately 0.647 points higher predicted discount importance.
The model explains approximately 34.2% of the observed variation in discount importance.
I added loyalty-point importance and personalized-offer importance to the same outcome.
The assignment calls this multivariate regression. With one outcome and several predictors, the model is more specifically a multiple linear regression.
multiple_model <- lm(
discount_importance ~ delivery_importance +
loyalty_importance + personalized_importance,
data = analysis_data
)
summary(multiple_model)
##
## Call:
## lm(formula = discount_importance ~ delivery_importance + loyalty_importance +
## personalized_importance, data = analysis_data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -6.6535 -1.8049 0.6408 1.3952 4.9952
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.04183 1.15434 -0.036 0.9713
## delivery_importance 0.56870 0.13027 4.366 8.1e-05 ***
## loyalty_importance -0.06052 0.14876 -0.407 0.6862
## personalized_importance 0.41763 0.15636 2.671 0.0107 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.676 on 42 degrees of freedom
## Multiple R-squared: 0.4465, Adjusted R-squared: 0.4069
## F-statistic: 11.29 on 3 and 42 DF, p-value: 1.459e-05
Each coefficient describes the association between that predictor and discount importance while holding the other included predictors constant.
multiple_coefficients <- coef(summary(multiple_model))
knitr::kable(
multiple_coefficients,
digits = 4,
caption = "Multiple Regression Coefficients"
)
| Estimate | Std. Error | t value | Pr(>|t|) | |
|---|---|---|---|---|
| (Intercept) | -0.0418 | 1.1543 | -0.0362 | 0.9713 |
| delivery_importance | 0.5687 | 0.1303 | 4.3656 | 0.0001 |
| loyalty_importance | -0.0605 | 0.1488 | -0.4068 | 0.6862 |
| personalized_importance | 0.4176 | 0.1564 | 2.6708 | 0.0107 |
R-squared describes the proportion of outcome variation explained by a fitted model. Adjusted R-squared accounts for model size and can decrease when additional predictors provide insufficient improvement (Penn State, n.d.).
multiple_results <- summary(multiple_model)
comparison <- data.frame(
Model = c("Simple", "Multiple"),
Respondents = c(
nobs(simple_model),
nobs(multiple_model)
),
Delivery_coefficient = c(
unname(coef(simple_model)["delivery_importance"]),
unname(coef(multiple_model)["delivery_importance"])
),
R_squared = c(
simple_results$r.squared,
multiple_results$r.squared
),
Adjusted_R_squared = c(
simple_results$adj.r.squared,
multiple_results$adj.r.squared
)
)
knitr::kable(comparison, digits = 3)
| Model | Respondents | Delivery_coefficient | R_squared | Adjusted_R_squared |
|---|---|---|---|---|
| Simple | 46 | 0.647 | 0.342 | 0.328 |
| Multiple | 46 | 0.569 | 0.446 | 0.407 |
stopifnot(nobs(simple_model) == nobs(multiple_model))
The delivery coefficient changes after adjusting for the other benefit preferences. This adjustment separates the modeled associations, but it does not establish causal effects.
I standardized the variables and compared the absolute standardized coefficients. This describes relative association within this particular model rather than universal importance.
standardized_data <- as.data.frame(
scale(analysis_data)
)
standardized_model <- lm(
discount_importance ~ delivery_importance +
loyalty_importance + personalized_importance,
data = standardized_data
)
standardized_coefficients <- coef(
standardized_model
)[-1]
predictor_comparison <- data.frame(
Predictor = names(standardized_coefficients),
Standardized_coefficient = unname(
standardized_coefficients
)
)
predictor_comparison <- predictor_comparison[
order(-abs(
predictor_comparison$Standardized_coefficient
)),
]
rownames(predictor_comparison) <- NULL
knitr::kable(predictor_comparison, digits = 3)
| Predictor | Standardized_coefficient |
|---|---|
| delivery_importance | 0.514 |
| personalized_importance | 0.351 |
| loyalty_importance | -0.053 |
The points represent respondents. Small amounts of jitter separate overlapping scores for display only. The regression line uses the original values.
set.seed(123)
plot(
jitter(
analysis_data$delivery_importance,
amount = 0.10
),
jitter(
analysis_data$discount_importance,
amount = 0.10
),
xlab = "Free-delivery importance",
ylab = "Immediate-discount importance",
main = "How Delivery and Discount Preferences Relate",
pch = 19,
col = adjustcolor("#286B75", alpha.f = 0.6),
xlim = c(-0.3, 10.3),
ylim = c(-0.3, 10.3)
)
abline(
simple_model,
col = "#B54B35",
lwd = 2
)
The residual-versus-fitted plot helps identify systematic patterns or changes in residual spread. The Q-Q plot helps assess departures from normally distributed residuals.
par(mfrow = c(1, 2))
plot(multiple_model, which = 1)
plot(multiple_model, which = 2)
par(mfrow = c(1, 1))
The sample is small, and all variables are bounded survey ratings. Linear regression treats adjacent rating differences as comparable. The models describe stated preferences rather than actual purchase behavior and do not demonstrate causation.
The cleaned file contains the four recoded analysis variables without respondent identifiers. The original raw CSV remains unchanged.
write.csv(
analysis_data,
"Ava_Shopping_Preferences_Clean.csv",
row.names = FALSE
)
file.exists("Ava_Shopping_Preferences_Clean.csv")
## [1] TRUE
I removed the two Qualtrics metadata rows, leaving 51 response records. All records passed the completion and standard-status checks, but two contained no survey answers and were removed. I selected four promotion-benefit ratings and converted them to numeric values. I reversed each rating using 10 minus the original score so higher values indicated greater importance. Three additional respondents were missing at least one selected rating, leaving 46 complete cases. I used those same respondents in both regressions and saved a separate cleaned CSV containing only the analysis variables.
Free-delivery importance had the strongest association with discount importance, with a standardized coefficient of approximately 0.514. In the simple model, a one-point increase in delivery importance was associated with a 0.647-point increase in discount importance. After adding loyalty-point and personalized-offer importance, the delivery coefficient decreased to 0.569. This suggests that the other preferences share some explanatory information with delivery importance. R-squared increased from 0.342 to 0.446, and adjusted R-squared increased from 0.328 to 0.407. Personalized-offer importance had a positive adjusted association, while loyalty-point importance showed little evidence of an independent association. The plotted relationship was positive, although respondents varied considerably around the fitted line. Both models used the same 46 complete responses. These findings describe associations rather than causes. Next time, I would collect a larger, more diverse sample, clarify rating instructions, investigate response quality, and establish a missing-data plan before administering the survey.
Penn State. (n.d.). Multiple linear regression. STAT 501: Regression Methods. https://online.stat.psu.edu/stat501/Lesson05