Project details

Group: Add group number
Members: Genesis, Diane, Lauryn, Viviana
Data folder: Add the authorized OneDrive or Box folder link in the final submission.

This is a working draft. It contains the survey EDA and regression workflow. The text-analysis section will populate after the three weekly Bluesky files are added. The current draft does not invent findings for missing data.

1. Survey data and checks

The survey section uses the cleaned Qualtrics export. It describes the observed sample and treats response codes as numeric only where required for the assigned regression. The survey export does not include the answer labels for the age-group and theater-frequency codes, so those codes are shown without guessing their meanings.

~{r setup, include=FALSE} knitr::opts_chunk$set( echo = TRUE, message = FALSE, warning = FALSE, fig.width = 8, fig.height = 4.8 ) required_packages <- c(“readr”, “dplyr”, “tidyr”, “ggplot2”, “knitr”, “broom”, “stringr”, “tidytext”) missing_packages <- required_packages[ !vapply(required_packages, requireNamespace, logical(1), quietly = TRUE)] if (length(missing_packages)) { stop(“Install these packages in the Console first:”, paste(missing_packages, collapse = “,”)) } library(readr) library(dplyr) library(tidyr) library(ggplot2) library(knitr) library(broom) library(stringr) library(tidytext) theme_set(theme_minimal(base_size = 12)) ~

~{r install-instructions, eval=FALSE} install.packages(c(“rmarkdown”, “readr”, “dplyr”, “tidyr”, “ggplot2”, “knitr”, “broom”, “stringr”, “tidytext”, “textdata”)) ~

~{r import-survey} if (!file.exists(params\(survey_file)) { stop("Place the cleaned survey CSV beside this Rmd and set survey_file in the YAML header.") } survey <- readr::read_csv( params\)survey_file, show_col_types = FALSE, na = c(““,”NA”) )

point_columns <- c( “Pts_low_price”, “Pts_premium”, “Pts_concessions”, “Pts_showtimes”, “Pts_proximity” ) required_columns <- c( “ID”, “Age_group”, “Ent_spend”, “Theater_freq”, “Buy_methods_n”, “Home_better”, “Price_influence”, point_columns ) missing_columns <- setdiff(required_columns, names(survey)) if (length(missing_columns)) { stop(“Survey columns missing:”, paste(missing_columns, collapse = “,”)) } if (!all(vapply(survey[required_columns], is.numeric, logical(1)))) { stop(“Expected numeric analysis columns in the cleaned survey file.”) } ~

The cleaned file contains the respondent count shown in the audit below.

~{r survey-audit} point_totals <- rowSums(survey[, point_columns], na.rm = FALSE) audit <- tibble( Check = c(“Respondents”, “Duplicate IDs”, “Rows with any missing analysis value”, “Minimum point-allocation total”, “Maximum point-allocation total”), Result = c( nrow(survey), sum(duplicated(survey$ID)), sum(!complete.cases(survey[, required_columns])), min(point_totals, na.rm = TRUE), max(point_totals, na.rm = TRUE) ) ) knitr::kable(audit) ~

Each respondent’s five feature allocations should total 100 points. The audit reports the actual range so any data-entry issues are visible.

~{r descriptive-statistics} descriptive_variables <- c( “Age_group”, “Ent_spend”, “Theater_freq”, “Buy_methods_n”, “Home_better”, “Price_influence”, point_columns ) descriptives <- survey |> select(all_of(descriptive_variables)) |> pivot_longer(cols = everything(), names_to = “Variable”, values_to = “Value”) |> group_by(Variable) |> summarise( n = sum(!is.na(Value)), Mean = mean(Value, na.rm = TRUE), Median = median(Value, na.rm = TRUE), SD = sd(Value, na.rm = TRUE), Minimum = min(Value, na.rm = TRUE), Maximum = max(Value, na.rm = TRUE), .groups = “drop” ) |> mutate(across(where(is.numeric), ~ round(.x, 2))) knitr::kable(descriptives) ~

2. Exploratory data analysis

Theater-frequency response codes

~{r theater-frequency-chart} frequency_counts <- survey |> count(Theater_freq, name = “Respondents”) |> mutate(Theater_freq = factor(Theater_freq)) ggplot(frequency_counts, aes(x = Theater_freq, y = Respondents)) + geom_col(fill = “#287D8E”, width = 0.72) + geom_text(aes(label = Respondents), vjust = -0.35, size = 4) + labs( title = “Survey respondents by theater-frequency code”, x = “Theater-frequency response code”, y = “Respondents” ) + expand_limits(y = max(frequency_counts$Respondents) * 1.15) ~

The response codes are displayed as recorded. The original answer labels are needed before describing a code as “often,” “rarely,” or similar.

Importance assigned to movie-theater features

~{r feature-allocation-chart} feature_labels <- c( Pts_low_price = “Low ticket price”, Pts_premium = “Premium format”, Pts_concessions = “Concession deals”, Pts_showtimes = “Convenient showtimes”, Pts_proximity = “Proximity to home” ) feature_means <- survey |> summarise(across(all_of(point_columns), ~ mean(.x, na.rm = TRUE))) |> pivot_longer(everything(), names_to = “Feature”, values_to = “Mean_points”) |> mutate(Feature = factor(Feature, levels = names(feature_labels), labels = unname(feature_labels))) |> arrange(Mean_points) ggplot(feature_means, aes(x = reorder(Feature, Mean_points), y = Mean_points)) + geom_col(fill = “#287D8E”, width = 0.72) + coord_flip() + labs( title = “Average points assigned to theater features”, subtitle = “Each respondent allocated 100 points across five features”, x = NULL, y = “Mean points” ) knitr::kable( feature_means |> arrange(desc(Mean_points)) |> mutate(Mean_points = round(Mean_points, 2)), col.names = c(“Feature”, “Mean points”) ) ~

Home-viewing preference and theater-frequency code

~{r home-viewing-plot} ggplot(survey, aes(x = Home_better, y = Theater_freq)) + geom_jitter(width = 0.08, height = 0.08, alpha = 0.72, color = “#287D8E”, size = 2.4) + geom_smooth(method = “lm”, formula = y ~ x, se = TRUE, color = “#B23A48”, linewidth = 1) + scale_y_continuous(breaks = sort(unique(survey$Theater_freq))) + labs( title = “Home-viewing preference and theater-frequency code”, x = “Agreement that home viewing is better (0–5 scale)”, y = “Theater-frequency response code” ) ~

This chart describes a relationship between coded responses. It does not establish that one preference causes a change in theater attendance.

EDA summary

~{r eda-summary, results=‘asis’} top_feature <- feature_means |> slice_max(Mean_points, n = 1, with_ties = FALSE) most_common_frequency <- frequency_counts |> slice_max(Respondents, n = 1, with_ties = FALSE) cat(sprintf( “The highest average feature allocation was %s (%.1f points). The most common theater-frequency response was code %s (%d respondents). These describe this sample; category labels are needed to interpret the response code.”, as.character(top_feature\(Feature), top_feature\)Mean_points, as.character(most_common_frequency\(Theater_freq), most_common_frequency\)Respondents )) ~

3. Regression analysis

The response variable has four ordered codes. The assigned linear regressions treat these codes as numeric so that coefficients describe changes in the code, not changes in a measured number of visits. Interpret the direction only after checking the survey’s original response labels.

~{r fit-models} simple_model <- lm( Theater_freq ~ Home_better, data = survey, na.action = na.omit ) multiple_model <- lm( Theater_freq ~ Home_better + Price_influence + Ent_spend, data = survey, na.action = na.omit ) ~

Model comparison

~{r model-comparison} model_fit <- bind_rows( broom::glance(simple_model) |> mutate(Model = “Simple: Home-viewing preference”), broom::glance(multiple_model) |> mutate(Model = “Multiple: preference, price, spending”) ) |> select(Model, nobs, r.squared, adj.r.squared, AIC) |> mutate(across(where(is.numeric), ~ round(.x, 3))) knitr::kable( model_fit, col.names = c(“Model”, “N”, “R-squared”, “Adjusted R-squared”, “AIC”) ) ~

Coefficient estimates

~{r coefficient-tables} simple_coefficients <- broom::tidy(simple_model, conf.int = TRUE) |> mutate(Model = “Simple”) multiple_coefficients <- broom::tidy(multiple_model, conf.int = TRUE) |> mutate(Model = “Multiple”) coefficients <- bind_rows(simple_coefficients, multiple_coefficients) |> select(Model, term, estimate, std.error, conf.low, conf.high, p.value) |> mutate(across(where(is.numeric), ~ round(.x, 3))) knitr::kable( coefficients, col.names = c(“Model”, “Term”, “Estimate”, “SE”, “95% CI low”, “95% CI high”, “p-value”) ) ~

Regression interpretation

~{r regression-summary, results=‘asis’} simple_home <- broom::tidy(simple_model) |> filter(term == “Home_better”) multiple_home <- broom::tidy(multiple_model) |> filter(term == “Home_better”) multiple_price <- broom::tidy(multiple_model) |> filter(term == “Price_influence”) multiple_spend <- broom::tidy(multiple_model) |> filter(term == “Ent_spend”) simple_fit <- broom::glance(simple_model) multiple_fit <- broom::glance(multiple_model) cat(sprintf( “In the simple model, the Home_better coefficient was %.3f (p = %.3f; R-squared = %.3f). In the multiple model, its coefficient was %.3f (p = %.3f); the Price_influence and Ent_spend p-values were %.3f and %.3f. The multiple model R-squared was %.3f and adjusted R-squared was %.3f. These are associations in a sample of %d respondents, not causal effects or population estimates.”, simple_home\(estimate, simple_home\)p.value, simple_fit\(r.squared, multiple_home\)estimate, multiple_home\(p.value, multiple_price\)p.value, multiple_spend\(p.value, multiple_fit\)r.squared, multiple_fit$adj.r.squared, nrow(survey) )) ~

Regression limitations

  • The survey has a small sample, and the age-group codes are concentrated in one category.
  • The cleaned file uses mean-imputed values for some rating responses; this can affect standard errors and p-values.
  • Theater-frequency codes are ordinal. Ordinary least squares is used here to match the assigned analysis, with that limitation stated.
  • The response labels for age group and theater frequency should be checked in the original Qualtrics survey before using plain-language interpretations.
  • The results are associations in this sample and do not show cause and effect.

4. Bluesky text analysis

The report expects three weekly CSV files in the same folder. Each file should include a post URI column named uri and a full post-text column named text. The code removes blank rows and repeated post URIs, and avoids printing post text or account handles in the published report.

~{r bluesky-analysis, results=‘asis’} weekly_files <- as.character(unlist(params\(bluesky_files)) if (length(weekly_files) < 3L || any(!file.exists(weekly_files))) { cat( "**Pending:** Add the group's three weekly Bluesky CSV files and set their names in the YAML header. The text-analysis findings and 500-word project summary will be completed from those files." ) } else { weekly_data <- lapply(seq_along(weekly_files), function(i) { dat <- readr::read_csv( weekly_files[i], col_types = readr::cols(.default = readr::col_character()), show_col_types = FALSE, progress = FALSE ) needed <- c("uri", "text") if (!all(needed %in% names(dat))) { stop( "Each Bluesky CSV must include columns named uri and text. File: ", weekly_files[i] ) } dat\)collection_week <- paste0(“Week”, i) dat }) raw_posts <- bind_rows(weekly_data) |> mutate( post_id = row_number(), text_raw = coalesce(text, ““), post_key = if_else( is.na(uri) | str_trim(uri) ==”“, paste0(”missing-uri-row-“, post_id), uri ) ) nonblank_posts <- raw_posts |> filter(str_squish(text_raw) !=”“) posts <- nonblank_posts |> distinct(post_key, .keep_all = TRUE) |> mutate( text_clean = text_raw |> str_remove_all(regex(”https?://\S+|www\.\S+“, ignore_case = TRUE)) |> str_remove_all(”@[[:alnum:]_.-]+“) |> str_to_lower() |> str_squish() ) audit <- tibble( Measure = c(”Rows supplied”, “Blank text rows removed”, “Duplicate post URIs removed”, “Posts retained”, “Posts with no text after URL/mention cleaning”), Count = c( nrow(raw_posts), nrow(raw_posts) - nrow(nonblank_posts), nrow(nonblank_posts) - nrow(posts), nrow(posts), sum(posts$text_clean == ““) ) ) print(knitr::kable(audit)) print(knitr::kable(posts |> count(collection_week, name =”Retained posts”)))

tokens <- posts |> select(post_id, collection_week, text_clean) |> tidytext::unnest_tokens(word, text_clean) |> filter(str_detect(word, “[[:alpha:]]”), str_length(word) >= 2)

frequency_tokens <- tokens |> anti_join(tidytext::stop_words, by = “word”) word_counts <- frequency_tokens |> count(word, sort = TRUE, name = “Occurrences”) if (nrow(word_counts)) { print(knitr::kable(head(word_counts, 20))) top_words <- head(word_counts, 15) print( ggplot(top_words, aes(x = reorder(word, Occurrences), y = Occurrences)) + geom_col(fill = “#287D8E”) + coord_flip() + labs( title = “Most frequent words in the Bluesky sample”, x = NULL, y = “Word occurrences” ) ) }

bing <- tidytext::get_sentiments(“bing”) matched <- tokens |> inner_join(bing, by = “word”) sentiment_counts <- matched |> group_by(post_id) |> summarise( positive = sum(sentiment == “positive”), negative = sum(sentiment == “negative”), .groups = “drop” ) post_sentiment <- posts |> select(post_id, collection_week) |> left_join(sentiment_counts, by = “post_id”) |> mutate( positive = replace_na(positive, 0L), negative = replace_na(negative, 0L), matched_words = positive + negative, score = positive - negative, category = case_when( matched_words == 0L ~ “No dictionary matches”, score > 0L ~ “Positive score”, score < 0L ~ “Negative score”, TRUE ~ “Balanced matches” ) ) sentiment_summary <- post_sentiment |> count(category, name = “Posts”) |> mutate(Percent = round(100 * Posts / sum(Posts), 1)) print(knitr::kable(sentiment_summary)) coverage <- mean(post_sentiment\(matched_words > 0L) * 100 cat(sprintf( "At least one Bing dictionary word matched in **%.1f%%** of retained posts. No dictionary matches does not mean neutral sentiment; the dictionary also misses negation, sarcasm, slang, and opinion targets.", coverage )) stopifnot( nrow(post_sentiment) == nrow(posts), sum(sentiment_summary\)Posts) == nrow(posts), all(post_sentiment\(score == post_sentiment\)positive - post_sentiment$negative) ) } ~

5. Project summary

Complete the 500-word summary after the three-week Bluesky data are added and the text-analysis findings populate. The summary should describe the survey sample, the main EDA result, the regression results, the text-analysis patterns, and the limitations of both datasets.

6. Reproducibility

~{r session-info} sessionInfo() ~