This report is Project 3 for MKTG3P98
getwd()
## [1] "/Users/charlesmba"
setwd("/Users/charlesmba")
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(ggplot2)
Dataset_Financials <- read.csv("/Users/charlesmba/Desktop/Movie Dataset_Financials.csv")
Dataset_General <- read.csv("/Users/charlesmba/Desktop/Movie Dataset_General Audience.csv")
Dataset_merged <- merge(Dataset_Financials, Dataset_General, by= "original_title")
str(Dataset_merged)
## 'data.frame': 665 obs. of 17 variables:
## $ original_title : chr "10,000 B.C. " "102 Dalmatians " "2 Fast 2 Furious " "2012 " ...
## $ budget..Millions. : num 12.6 45 16 3.5 16 50 50 26 65 8.5 ...
## $ revenue..Millions.: num 18.66 60.22 31.56 0.75 19.68 ...
## $ language : chr "" "English" "English" "English" ...
## $ country : chr "" "USA" "USA" "USA" ...
## $ type : chr "Feature Film" "Feature Film" "Feature Film" "Feature Film" ...
## $ genre : chr "Drama" "Drama" "Mystery & Suspense" "Comedy" ...
## $ runtime : int 134 108 97 98 111 106 87 83 100 86 ...
## $ mpaa_rating : chr "R" "PG" "PG-13" "PG-13" ...
## $ imdb_rating : num 6.8 4.9 6.3 6.3 6 7.8 5.4 7.6 7 4.1 ...
## $ imdb_num_votes : int 9025 5136 54771 8646 103789 12450 6811 78862 8320 739 ...
## $ critics_rating : chr "Fresh" "Rotten" "Rotten" "Certified Fresh" ...
## $ critics_score : int 60 5 40 44 51 75 35 50 70 53 ...
## $ audience_rating : chr "Upright" "Spilled" "Spilled" "Spilled" ...
## $ audience_score : int 76 13 49 54 51 85 31 81 74 42 ...
## $ best_pic_nom : chr "no" "no" "no" "no" ...
## $ Facebook_Likes : int 23343 84182 35296 445 21583 20965 12952 52827 48878 5481 ...
Dataset_clean <- na.omit(Dataset_merged)
Dataset_clean <- Dataset_clean %>%
mutate(genre_category = case_when(
genre %in% c("Action & Adventure", "Animation") ~ "action_thrills",
genre %in% c("Comedy", "Documentary") ~ "Humor_fam",
genre %in% c("Drama", "Art House & International", "Musical & Performing Arts") ~ "Emotional_music",
genre %in% c("Science Fiction & Fantasy", "Horror", "Mystery & Suspense") ~ "Imaginative_chill",
TRUE ~ "Other"
))
str(Dataset_clean)
## 'data.frame': 664 obs. of 18 variables:
## $ original_title : chr "10,000 B.C. " "102 Dalmatians " "2 Fast 2 Furious " "2012 " ...
## $ budget..Millions. : num 12.6 45 16 3.5 16 50 50 26 65 8.5 ...
## $ revenue..Millions.: num 18.66 60.22 31.56 0.75 19.68 ...
## $ language : chr "" "English" "English" "English" ...
## $ country : chr "" "USA" "USA" "USA" ...
## $ type : chr "Feature Film" "Feature Film" "Feature Film" "Feature Film" ...
## $ genre : chr "Drama" "Drama" "Mystery & Suspense" "Comedy" ...
## $ runtime : int 134 108 97 98 111 106 87 83 100 86 ...
## $ mpaa_rating : chr "R" "PG" "PG-13" "PG-13" ...
## $ imdb_rating : num 6.8 4.9 6.3 6.3 6 7.8 5.4 7.6 7 4.1 ...
## $ imdb_num_votes : int 9025 5136 54771 8646 103789 12450 6811 78862 8320 739 ...
## $ critics_rating : chr "Fresh" "Rotten" "Rotten" "Certified Fresh" ...
## $ critics_score : int 60 5 40 44 51 75 35 50 70 53 ...
## $ audience_rating : chr "Upright" "Spilled" "Spilled" "Spilled" ...
## $ audience_score : int 76 13 49 54 51 85 31 81 74 42 ...
## $ best_pic_nom : chr "no" "no" "no" "no" ...
## $ Facebook_Likes : int 23343 84182 35296 445 21583 20965 12952 52827 48878 5481 ...
## $ genre_category : chr "Emotional_music" "Emotional_music" "Imaginative_chill" "Humor_fam" ...
## - attr(*, "na.action")= 'omit' Named int 392
## ..- attr(*, "names")= chr "392"
ggplot(Dataset_clean, aes(x = genre_category, y = revenue..Millions.)) +
geom_boxplot() +
labs(title = "Revenue by Genre Category", x = "Genre Category", y = "Revenue")
ggplot(Dataset_clean, aes(x = genre_category, y = critics_score)) +
geom_boxplot() +
labs(title = "Critics' Scores by Genre Category", x = "Genre Category", y = "Critics' Score")
ggplot(Dataset_clean, aes(x = critics_score, y = revenue..Millions., color = genre_category)) +
geom_point() +
labs(title = "Revenue vs. Critics' Score by Genre Category", x = "Critics' Score", y = "Revenue")
ggplot(Dataset_clean, aes(x = audience_score, y = revenue..Millions., color = genre_category)) +
geom_point() +
labs(title = "Revenue vs. Audience Score by Genre Category", x = "Audience Score", y = "Revenue")
t_tests <- Dataset_clean %>%
group_by(genre_category) %>%
summarise(t_test = list(t.test(critics_score, audience_score)))
t_tests
## # A tibble: 5 × 2
## genre_category t_test
## <chr> <list>
## 1 Emotional_music <htest>
## 2 Humor_fam <htest>
## 3 Imaginative_chill <htest>
## 4 Other <htest>
## 5 action_thrills <htest>
anova_revenue <- aov(revenue..Millions. ~ genre_category, data = Dataset_clean)
summary(anova_revenue)
## Df Sum Sq Mean Sq F value Pr(>F)
## genre_category 4 9684 2421 0.054 0.995
## Residuals 659 29679899 45038
anova_critics <- aov(critics_score ~ genre_category, data = Dataset_clean)
summary(anova_critics)
## Df Sum Sq Mean Sq F value Pr(>F)
## genre_category 4 6568 1642.1 3.099 0.0153 *
## Residuals 659 349217 529.9
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova_audience <- aov(audience_score ~ genre_category, data = Dataset_clean)
summary(anova_audience)
## Df Sum Sq Mean Sq F value Pr(>F)
## genre_category 4 5812 1452.9 3.315 0.0106 *
## Residuals 659 288864 438.3
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
regression_results <- lm(revenue..Millions. ~ genre_category + critics_score + audience_score + imdb_rating + imdb_num_votes + runtime + mpaa_rating, data = Dataset_clean)
summary(regression_results)
##
## Call:
## lm(formula = revenue..Millions. ~ genre_category + critics_score +
## audience_score + imdb_rating + imdb_num_votes + runtime +
## mpaa_rating, data = Dataset_clean)
##
## Residuals:
## Min 1Q Median 3Q Max
## -331.52 -87.71 -29.95 34.59 1800.98
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -1.570e+02 6.131e+01 -2.560 0.0107 *
## genre_categoryEmotional_music -2.903e+01 2.612e+01 -1.111 0.2668
## genre_categoryHumor_fam -2.745e+01 2.884e+01 -0.952 0.3416
## genre_categoryImaginative_chill 1.551e+01 3.119e+01 0.497 0.6193
## genre_categoryOther 9.920e+00 5.312e+01 0.187 0.8519
## critics_score 1.165e+00 5.162e-01 2.258 0.0243 *
## audience_score 3.647e+00 6.058e-01 6.020 2.91e-09 ***
## imdb_rating 6.062e-01 2.839e+00 0.214 0.8310
## imdb_num_votes -1.993e-04 8.206e-05 -2.429 0.0154 *
## runtime -1.355e-03 4.171e-01 -0.003 0.9974
## mpaa_ratingNC-17 9.226e+00 1.422e+02 0.065 0.9483
## mpaa_ratingPG 8.558e+01 4.824e+01 1.774 0.0765 .
## mpaa_ratingPG-13 5.151e+01 4.886e+01 1.054 0.2922
## mpaa_ratingR 4.032e+01 4.717e+01 0.855 0.3929
## mpaa_ratingUnrated 4.143e+01 5.362e+01 0.773 0.4400
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 189.7 on 649 degrees of freedom
## Multiple R-squared: 0.2136, Adjusted R-squared: 0.1966
## F-statistic: 12.59 on 14 and 649 DF, p-value: < 2.2e-16
ggplot(Dataset_clean, aes(x = audience_score, y = revenue..Millions., color = genre_category)) +
geom_point() +
facet_wrap(~ genre_category) +
labs(title = "Revenue vs Audience Score by Genre Category", x = "Audience Score", y = "Revenue (Millions)")
ggplot(Dataset_clean, aes(x = critics_score, y = revenue..Millions., color = genre_category)) +
geom_point() +
facet_wrap(~ genre_category) +
labs(title = "Revenue vs Critics Score by Genre Category", x = "Critics Score", y = "Revenue (Millions)")
regression_model <- lm(revenue..Millions. ~ critics_score + Facebook_Likes, data = Dataset_clean)
summary(regression_model)
##
## Call:
## lm(formula = revenue..Millions. ~ critics_score + Facebook_Likes,
## data = Dataset_clean)
##
## Residuals:
## Min 1Q Median 3Q Max
## -605.54 -69.83 -20.96 34.87 1741.20
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -5.700e+01 1.516e+01 -3.758 0.000186 ***
## critics_score 1.957e+00 2.654e-01 7.376 4.9e-13 ***
## Facebook_Likes 1.364e-03 6.535e-05 20.866 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 151.9 on 661 degrees of freedom
## Multiple R-squared: 0.486, Adjusted R-squared: 0.4844
## F-statistic: 312.5 on 2 and 661 DF, p-value: < 2.2e-16
new_movie <- data.frame(critics_score = 55, Facebook_Likes = 1250)
predicted_revenue <- predict(regression_model, new_movie)
predicted_revenue
## 1
## 52.35604
new_facebook_likes <- 1250 * 101
new_movie <- data.frame(critics_score = 55, Facebook_Likes = new_facebook_likes)
new_revenue <- predict(regression_model, new_movie)
new_revenue
## 1
## 222.8069
improvement <- new_revenue - predicted_revenue
improvement
## 1
## 170.4508