This report examines whether agreement that watching movies at home
is better is associated with theater-going frequency. I first fit a
simple linear regression, then add price sensitivity and monthly
entertainment spending to see whether the relationship changes. The
report follows the workflow in the assigned tutorial (Xu, n.d.) and uses
the classmate RPubs post as a format example (Abundo, n.d.). The
regression formula follows R’s lm() documentation (R Core
Team, n.d.).
The survey outcome, Theater_freq, is recorded as four
numeric response codes. The models below treat those codes as numeric,
so coefficients describe changes in the code. Before publishing, confirm
the original response labels to explain whether a higher code means more
or fewer theater visits.
The Qualtrics export contains two extra rows below the column
headers: the question-label row and the ImportId row. I remove those
rows, keep completed non-preview records with a monthly
entertainment-spending response, convert analysis fields to numeric, and
create a smaller analysis dataset. Q5 allows multiple
ticket-buying methods, so I recode its comma-separated selections as a
count. Missing values in the two rating questions are replaced by their
means. Qualtrics metadata and the Q8 scenario-choice questions are not
included in the final analysis file.
Place this R Markdown file and
Qualtrics_Movie_Survey_Data.csv in the same folder before
knitting.
raw_export <- read.csv(
"Qualtrics_Movie_Survey_Data.csv",
stringsAsFactors = FALSE,
check.names = FALSE,
na.strings = c("", "NA"),
fileEncoding = "UTF-8"
)
# Remove the question-label and ImportId rows under the column headings.
raw_responses <- raw_export[-c(1L, 2L), , drop = FALSE]
# Convert fields needed for cleaning and analysis from text to numbers.
numeric_columns <- c(
"Status", "Finished", "Q2", "Q3", "Q4", "Q6_1", "Q7_1",
paste0("Q9_", 1:5)
)
raw_responses[numeric_columns] <- lapply(
raw_responses[numeric_columns],
function(x) suppressWarnings(as.numeric(trimws(x)))
)
# Keep completed, non-preview responses with a reported monthly spend value.
keep_response <- with(
raw_responses,
Status == 0 & Finished == 1 & !is.na(Q3)
)
analysis_raw <- raw_responses[which(keep_response), , drop = FALSE]
# Count selected methods in the comma-separated Q5 field.
count_methods <- function(x) {
if (is.na(x) || !nzchar(trimws(x))) return(NA_integer_)
selections <- strsplit(gsub(" ", "", x, fixed = TRUE), ",", fixed = TRUE)[[1]]
length(selections)
}
clean <- data.frame(
ID = seq_len(nrow(analysis_raw)),
Age_group = analysis_raw$Q2,
Ent_spend = analysis_raw$Q3,
Theater_freq = analysis_raw$Q4,
Buy_methods_n = vapply(analysis_raw$Q5, count_methods, integer(1)),
Home_better = analysis_raw$Q6_1,
Price_influence = analysis_raw$Q7_1,
Pts_low_price = analysis_raw$Q9_1,
Pts_premium = analysis_raw$Q9_2,
Pts_concessions = analysis_raw$Q9_3,
Pts_showtimes = analysis_raw$Q9_4,
Pts_proximity = analysis_raw$Q9_5
)
# Mean-impute the missing rating responses, rounded to the precision in the clean file.
home_mean <- round(mean(clean$Home_better, na.rm = TRUE), 1)
price_mean <- round(mean(clean$Price_influence, na.rm = TRUE), 2)
clean$Home_better[is.na(clean$Home_better)] <- home_mean
clean$Price_influence[is.na(clean$Price_influence)] <- price_mean
# Save the analysis-ready file as a separate CSV.
write.csv(clean, "Movie_Survey_Clean.csv", row.names = FALSE, na = "")
cat("Respondent rows after removing the two Qualtrics metadata rows:", nrow(raw_responses), "\n")
## Respondent rows after removing the two Qualtrics metadata rows: 33
cat("Rows retained for the clean dataset:", nrow(clean), "\n")
## Rows retained for the clean dataset: 21
cat("Mean used for Home_better:", home_mean, "\n")
## Mean used for Home_better: 3.4
cat("Mean used for Price_influence:", price_mean, "\n")
## Mean used for Price_influence: 3.33
missing_by_column <- data.frame(
Variable = names(clean),
Missing = as.integer(colSums(is.na(clean)))
)
knitr::kable(missing_by_column, caption = "Missing values in the cleaned data")
| Variable | Missing |
|---|---|
| ID | 0 |
| Age_group | 0 |
| Ent_spend | 0 |
| Theater_freq | 0 |
| Buy_methods_n | 0 |
| Home_better | 0 |
| Price_influence | 0 |
| Pts_low_price | 0 |
| Pts_premium | 0 |
| Pts_concessions | 0 |
| Pts_showtimes | 0 |
| Pts_proximity | 0 |
point_columns <- c(
"Pts_low_price", "Pts_premium", "Pts_concessions",
"Pts_showtimes", "Pts_proximity"
)
point_totals <- rowSums(clean[point_columns])
point_total_counts <- as.data.frame(table(point_totals))
names(point_total_counts) <- c("Points total", "Number of respondents")
knitr::kable(point_total_counts, caption = "Check that each respondent allocated 100 points")
| Points total | Number of respondents |
|---|---|
| 100 | 21 |
age_counts <- as.data.frame(table(clean$Age_group))
names(age_counts) <- c("Age-group code", "Number of respondents")
knitr::kable(age_counts, caption = "Respondents by age-group code")
| Age-group code | Number of respondents |
|---|---|
| 1 | 19 |
| 5 | 2 |
frequency_counts <- as.data.frame(table(clean$Theater_freq))
names(frequency_counts) <- c("Theater-frequency code", "Number of respondents")
knitr::kable(frequency_counts, caption = "Respondents by theater-frequency code")
| Theater-frequency code | Number of respondents |
|---|---|
| 1 | 2 |
| 2 | 6 |
| 3 | 10 |
| 4 | 3 |
The clean file contains 21 respondents. The two rating columns include mean-imputed values. The point-allocation columns should total 100 for each respondent; the table above checks that condition. The age codes and theater-frequency codes should be interpreted using the original survey answer labels, because those labels are not included in the clean CSV.
The simple model predicts the numeric Theater_freq code
from Home_better alone.
simple_model <- lm(Theater_freq ~ Home_better, data = clean)
summary(simple_model)
##
## 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(
x = clean$Home_better,
y = clean$Theater_freq,
pch = 19,
col = "#2166AC",
xlab = "Agreement that home viewing is better (coded rating)",
ylab = "Theater-going frequency (coded response)",
main = "Home-viewing preference and theater-frequency code"
)
abline(simple_model, col = "#B2182B", lwd = 2)
grid(col = "gray85")
The plot shows the relationship between the two coded variables.
Because Theater_freq has only four response values,
observations fall into horizontal bands. The positive slope is an
association between numeric codes; use the original answer choices to
explain its direction in everyday terms.
The multivariate model adds price sensitivity and monthly entertainment spending while keeping the same outcome.
multivariate_model <- lm(
Theater_freq ~ Home_better + Price_influence + Ent_spend,
data = clean
)
summary(multivariate_model)
##
## 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
coefficient_table <- function(model) {
model_summary <- coef(summary(model))
data.frame(
Term = rownames(model_summary),
Estimate = model_summary[, "Estimate"],
Std_Error = model_summary[, "Std. Error"],
t_value = model_summary[, "t value"],
p_value = model_summary[, "Pr(>|t|)"],
row.names = NULL
)
}
knitr::kable(
coefficient_table(simple_model),
digits = 4,
caption = "Simple-model coefficients"
)
| Term | Estimate | Std_Error | t_value | p_value |
|---|---|---|---|---|
| (Intercept) | 1.4741 | 0.5354 | 2.7535 | 0.0126 |
| Home_better | 0.3507 | 0.1494 | 2.3473 | 0.0299 |
knitr::kable(
coefficient_table(multivariate_model),
digits = 4,
caption = "Multivariate-model coefficients"
)
| Term | Estimate | Std_Error | t_value | p_value |
|---|---|---|---|---|
| (Intercept) | 1.2146 | 0.7706 | 1.5760 | 0.1334 |
| Home_better | 0.3535 | 0.1528 | 2.3134 | 0.0335 |
| Price_influence | 0.1266 | 0.1405 | 0.9009 | 0.3802 |
| Ent_spend | -0.0007 | 0.0007 | -0.9368 | 0.3620 |
model_comparison <- data.frame(
Model = c("Simple", "Multivariate"),
N = c(nobs(simple_model), nobs(multivariate_model)),
R_squared = c(summary(simple_model)$r.squared, summary(multivariate_model)$r.squared),
Adjusted_R_squared = c(
summary(simple_model)$adj.r.squared,
summary(multivariate_model)$adj.r.squared
)
)
knitr::kable(model_comparison, digits = 3, caption = "Fit statistics")
| Model | N | R_squared | Adjusted_R_squared |
|---|---|---|---|
| Simple | 21 | 0.225 | 0.184 |
| Multivariate | 21 | 0.288 | 0.162 |
coded_correlation <- cor(clean$Home_better, clean$Theater_freq)
cat("Pearson correlation between the coded variables:", round(coded_correlation, 3))
## Pearson correlation between the coded variables: 0.474
In the cleaned data, Home_better is the only predictor
that remains statistically significant in the multivariate model. Its
coefficient is nearly the same as in the simple model.
Price_influence and Ent_spend are not
statistically significant in this sample. R-squared increases after
adding predictors, but adjusted R-squared falls, so the extra variables
do not improve the model enough to offset the added complexity. This
small observational survey does not establish cause and effect.
In the simple model, Home_better was positively associated with the Theater_freq code (b = 0.351, p = .030, R² = .225). After adding Price_influence and Ent_spend, Home_better remained similar (b = 0.353, p = .033); neither added predictor was significant. R² rose to .288, but adjusted R² fell from .184 to .162, suggesting the added variables did not improve explanatory value. The scatterplot shows a moderate positive association (r = .474) and horizontal bands because Theater_freq has four response codes. If higher Theater_freq codes mean fewer visits, stronger preference for home viewing is associated with less frequent theater attendance; verify the labels first. The results are associational, not causal, in this sample. The sample includes 21 people, is concentrated in age code 1, and has one $1,000 monthly-spending response that may affect the spending estimate. I would recruit a larger, more age-balanced sample and measure monthly visits as a count.
Abundo, G. (n.d.). Discussion 12 RPubs example [RPubs post]. https://rpubs.com/gbeezy/1479098
R Core Team. (n.d.). lm: Fitting linear models. R Documentation. https://stat.ethz.ch/R-manual/R-devel/library/stats/html/lm.html
Xu, Z. (n.d.). Discussion 12 R regression tutorial [Video]. YouTube. https://www.youtube.com/watch?v=5NI7V4NQghg
I used ChatGPT to help draft the R Markdown code and organize the model interpretation. Before submitting, I will knit the file, verify that the code runs with my survey data, confirm the response-code labels in Qualtrics, and revise any errors or interpretations that need correction.