Qualtrics adds two extra header rows (question text and ImportId metadata) under the variable names.
raw <- read.csv("Qualtrics_Movie_Survey_Data.csv", stringsAsFactors = FALSE)
nrow(raw)
## [1] 35
raw <- raw[-c(1, 2), ] # drop question-text and ImportId rows
nrow(raw)
## [1] 33
Status = 1 marks survey previews (tests). I also kept
only finished responses with 100% progress and dropped one blank
row.
dat <- subset(raw, Status == 0 & Finished == 1 & as.numeric(Progress) == 100)
dat <- dat[!is.na(dat$Q2) & dat$Q2 != "" & !is.na(dat$Q3) & dat$Q3 != "", ]
nrow(dat)
## [1] 21
Q5 is multi-select (e.g., “4,5,6”), so I recoded it to the number of purchase methods selected.
clean <- data.frame(
ID = seq_len(nrow(dat)),
Age_group = as.numeric(dat$Q2),
Ent_spend = as.numeric(dat$Q3),
Theater_freq = as.numeric(dat$Q4),
Buy_methods_n = sapply(strsplit(dat$Q5, ","), length),
Home_better = as.numeric(dat$Q6_1),
Price_influence = as.numeric(dat$Q7_1),
Pts_low_price = as.numeric(dat$Q9_1),
Pts_premium = as.numeric(dat$Q9_2),
Pts_concessions = as.numeric(dat$Q9_3),
Pts_showtimes = as.numeric(dat$Q9_4),
Pts_proximity = as.numeric(dat$Q9_5)
)
str(clean)
## 'data.frame': 21 obs. of 12 variables:
## $ ID : int 1 2 3 4 5 6 7 8 9 10 ...
## $ Age_group : num 1 1 1 1 1 1 1 5 1 1 ...
## $ Ent_spend : num 90 80 50 400 300 120 90 500 200 100 ...
## $ Theater_freq : num 4 2 2 3 2 1 3 4 3 3 ...
## $ Buy_methods_n : int 1 1 2 1 1 1 1 1 1 1 ...
## $ Home_better : num 5 3 4 4 2 1 4 5 4 4 ...
## $ Price_influence: num 1 5 1 NA 5 NA 3 5 4 3 ...
## $ Pts_low_price : num 30 40 20 20 40 50 20 20 60 20 ...
## $ Pts_premium : num 10 5 10 30 10 10 20 20 10 20 ...
## $ Pts_concessions: num 20 5 20 20 30 30 10 20 10 0 ...
## $ Pts_showtimes : num 20 20 30 20 20 10 25 20 15 20 ...
## $ Pts_proximity : num 20 30 20 10 0 0 25 20 5 40 ...
colSums(is.na(clean))
## ID Age_group Ent_spend Theater_freq Buy_methods_n
## 0 0 0 0 0
## Home_better Price_influence Pts_low_price Pts_premium Pts_concessions
## 1 3 0 0 0
## Pts_showtimes Pts_proximity
## 0 0
for (v in c("Home_better", "Price_influence")) {
clean[[v]][is.na(clean[[v]])] <- round(mean(clean[[v]], na.rm = TRUE), 2)
}
colSums(is.na(clean))
## ID Age_group Ent_spend Theater_freq Buy_methods_n
## 0 0 0 0 0
## Home_better Price_influence Pts_low_price Pts_premium Pts_concessions
## 0 0 0 0 0
## Pts_showtimes Pts_proximity
## 0 0
Check that the 100-point allocation sums correctly:
rowSums(clean[, grep("^Pts_", names(clean))])
## [1] 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100
## [20] 100 100
write.csv(clean, "Movie_Survey_Clean.csv", row.names = FALSE)
Outcome: Theater_freq. Predictor:
Home_better.
m1 <- lm(Theater_freq ~ Home_better, data = clean)
summary(m1)
##
## Call:
## lm(formula = Theater_freq ~ Home_better, data = clean)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.5264 -0.5264 0.1229 0.4736 1.4736
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.4741 0.5354 2.754 0.0126 *
## Home_better 0.3507 0.1494 2.347 0.0299 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.7736 on 19 degrees of freedom
## Multiple R-squared: 0.2248, Adjusted R-squared: 0.184
## F-statistic: 5.51 on 1 and 19 DF, p-value: 0.0299
plot(clean$Home_better, clean$Theater_freq,
xlab = "Home viewing is better (0-5)", ylab = "Theater frequency",
pch = 19)
abline(m1, col = "red", lwd = 2)
Interpretation: Each 1-point increase in agreeing that home viewing is better is associated with a 0.35-point increase in theater frequency (p = .030). R-squared is .225, so the model explains about 22.5% of the variation in theater frequency.
m2 <- lm(Theater_freq ~ Home_better + Price_influence + Ent_spend, data = clean)
summary(m2)
##
## Call:
## lm(formula = Theater_freq ~ Home_better + Price_influence + Ent_spend,
## data = clean)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.15203 -0.35277 -0.00038 0.38552 1.36103
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.2145710 0.7706428 1.576 0.1334
## Home_better 0.3534771 0.1527937 2.313 0.0335 *
## Price_influence 0.1266141 0.1405410 0.901 0.3802
## Ent_spend -0.0006728 0.0007181 -0.937 0.3620
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.7839 on 17 degrees of freedom
## Multiple R-squared: 0.2877, Adjusted R-squared: 0.162
## F-statistic: 2.289 on 3 and 17 DF, p-value: 0.1151
anova(m1, m2)
## Analysis of Variance Table
##
## Model 1: Theater_freq ~ Home_better
## Model 2: Theater_freq ~ Home_better + Price_influence + Ent_spend
## Res.Df RSS Df Sum of Sq F Pr(>F)
## 1 19 11.370
## 2 17 10.447 2 0.92294 0.751 0.4869
AIC(m1, m2)
## df AIC
## m1 3 52.71035
## m2 5 54.93247
summary(m1)$adj.r.squared
## [1] 0.1839963
summary(m2)$adj.r.squared
## [1] 0.1620287
Interpretation: The Home_better
coefficient stays about 0.35 after adding Price_influence
and Ent_spend, so it is not driven by those variables.
Neither new predictor is significant. R-squared rises to .288, but
adjusted R-squared falls from .184 to .162, and the overall F-test is
not significant (p = .115). The added predictors do not improve the
model.
The sample is small (n = 21), so the models have little power. Mean
imputation understates variability (Allison, 2002). The scale direction
of Theater_freq should be checked against the survey,
because the positive Home_better slope is
counterintuitive.
I used Claude while working on this assignment. It helped me debug
errors in my R code, including a “cannot open the connection” file error
and an anova() error caused by the two models being fitted
on different numbers of rows. It also suggested a fix for my
data-cleaning filter.