I decided to observe 48 movies from 2023 with the genre comedy and drama and see if there is any difference between the movie ratings if we look at these two genres. Data for this analysis was sourced from the CinePulse 2023 dataset available on Kaggle (https://www.kaggle.com/datasets/kashishparmar02/cinepulse-2023), although I used only movies that fall under either drama or comedy genre.
#install.packages("readxl")
library(readxl)
mydata <- read_xlsx("~/Desktop/MVA/movies.xlsx")
colnames(mydata) <- c("ID","Name","Rating", "Votes" , "RunTime", "Genre")
mydata$Genre <- factor(mydata$Genre,
levels = c("Drama", "Comedy"),
labels =c("Drama", "Comedy"))
head(mydata)
## # A tibble: 6 × 6
## ID Name Rating Votes RunTime Genre
## <dbl> <chr> <chr> <dbl> <dbl> <fct>
## 1 1 Oppenheimer 8.4 565. 180 Drama
## 2 2 Sound of Freedom 7.7 91.8 131 Drama
## 3 3 Saltburn 7.3 38.6 131 Comedy
## 4 4 Tetris 7.4 75.6 118 Drama
## 5 5 Jesus Revolution 7.1 12.6 120 Drama
## 6 6 Siya 7.7 6.50 117 Drama
mydata$Votes <- as.numeric(mydata$Votes)
mydata$Rating <- as.numeric(mydata$Rating) #changing data to numeric values
summary(mydata[,c(-1,-2)])
## Rating Votes RunTime Genre
## Min. :5.400 Min. : 1.539 Min. : 87.0 Drama :29
## 1st Qu.:6.775 1st Qu.: 14.130 1st Qu.:105.0 Comedy:19
## Median :7.050 Median : 30.521 Median :117.5
## Mean :7.054 Mean :103.903 Mean :119.3
## 3rd Qu.:7.400 3rd Qu.: 87.925 3rd Qu.:128.2
## Max. :8.500 Max. :877.000 Max. :206.0
Rating: The ratings vary from a minimum of 5.4 to a maximum of 8.5, with a median and mean closely aligned at around 7.05. This suggests a fairly consistent rating pattern across the movies. The ratings are moderately spread, as indicated by the first and third quartiles (6.775 and 7.4, respectively).
Votes: The number of votes per movie shows significant variability, ranging from as few as about 1.54 votes to as many as 877 votes. The average number of votes is around 103.90, but this average could be influenced by movies with exceptionally high vote counts, as suggested by the wide spread between the first quartile (14.130) and the third quartile (87.925).
RunTime: The length of the movies varies from 87 minutes to 206 minutes, with an average runtime of approximately 119 minutes. This indicates a diverse range of movie durations in my dataset.
Genre: In my dataset, drama and comedy are the two genres analyzed, with drama movies being more prevalent (29 out of 48) than comedies (19 out of 48).
library(psych)
describe(mydata)
## vars n mean sd median trimmed mad min max range skew
## ID 1 48 24.50 14.00 24.50 24.50 17.79 1.00 48.0 47.00 0.00
## Name* 2 48 23.81 13.63 23.50 23.77 17.05 1.00 47.0 46.00 0.03
## Rating 3 48 7.05 0.61 7.05 7.05 0.52 5.40 8.5 3.10 -0.11
## Votes 4 48 103.90 186.61 30.52 58.77 35.61 1.54 877.0 875.46 2.62
## RunTime 5 48 119.27 20.89 117.50 117.30 18.53 87.00 206.0 119.00 1.77
## Genre* 6 48 1.40 0.49 1.00 1.38 0.00 1.00 2.0 1.00 0.41
## kurtosis se
## ID -1.28 2.02
## Name* -1.27 1.97
## Rating 0.79 0.09
## Votes 6.21 26.93
## RunTime 5.17 3.02
## Genre* -1.87 0.07
library(ggplot2)
##
## Attaching package: 'ggplot2'
## The following objects are masked from 'package:psych':
##
## %+%, alpha
ggplot(mydata, aes(x = Rating, fill = factor(Genre))) +
geom_histogram(position = "dodge", bins = 10) +
scale_fill_manual(values = c("purple", "yellow"),
labels = c("Drama", "Comedy")) +
labs(title = "Distribution of Movie Ratings by Genre",
x = "Rating", y = "Frequency", fill = "Genre") +
theme_bw()
# Filtering data for Drama and Comedy
drama_data <- mydata[mydata$Genre == "Drama", ]
comedy_data <- mydata[mydata$Genre == "Comedy", ]
# Shapiro-Wilk Test for Normality
# For Drama
shapiro.test(drama_data$Rating)
##
## Shapiro-Wilk normality test
##
## data: drama_data$Rating
## W = 0.97566, p-value = 0.7196
# For Comedy
shapiro.test(comedy_data$Rating)
##
## Shapiro-Wilk normality test
##
## data: comedy_data$Rating
## W = 0.92117, p-value = 0.119
The p-values from the Shapiro-Wilk tests for drama and comedy genres (0.7196 and 0.119) suggest that ratings for both genres follow a normal distribution, as they exceed the 0.05 threshold. This supports the assumption of normality, which is crucial for conducting the t-test.
H0: The IMDb ratings for Comedy and Drama are normally distributed
H1: The IMDb ratings for Comedy and Drama are not normally distributed
t.test(Rating ~ Genre, data = mydata, subset = Genre %in% c("Drama", "Comedy"))
##
## Welch Two Sample t-test
##
## data: Rating by Genre
## t = 0.5846, df = 36.966, p-value = 0.5624
## alternative hypothesis: true difference in means between group Drama and group Comedy is not equal to 0
## 95 percent confidence interval:
## -0.2640590 0.4782151
## sample estimates:
## mean in group Drama mean in group Comedy
## 7.096552 6.989474
The Welch Two Sample t-test results show a p-value of 0.5624, indicating no evidence of average ratings differing significantly between the drama and comedy genres so I can not reject the null hypotheses. The means of the two genres are similar (7.10 for drama and 6.99 for comedy), and the confidence interval includes zero, reinforcing the similarity in ratings.
H0: The average ratings for movies in comedy and drama genre are the same.
H1: The average ratings for movies in comedy and drama genre are not the same.
wilcox.test(Rating ~ Genre, data = mydata, exact = FALSE, subset = Genre %in% c("Drama", "Comedy")) #Non-Parametric Test (Robustness Check): using a Mann-Whitney U test as a non-parametric alternative
##
## Wilcoxon rank sum test with continuity correction
##
## data: Rating by Genre
## W = 310.5, p-value = 0.4651
## alternative hypothesis: true location shift is not equal to 0
The Wilcoxon test’s p-value of 0.4651 also supports the lack of average difference in ratings between the genres and we can not reject the null hypothesis, because of the p-value (p>0.05).
H0: Location distribution of ratings in movies in Comedy genre is the same as location distribution of ratings in Drama genre.
H1: Location distribution of ratings in movies in Comedy genre is not the same as location distribution of ratings in Drama genre.
#install.packages("effectsize")
library(effectsize)
##
## Attaching package: 'effectsize'
## The following object is masked from 'package:psych':
##
## phi
# Calculate Cohen's d for Rating scores between drama and comedy genres
cohens_d_result <- cohens_d(mydata$Rating ~ mydata$Genre, pooled = TRUE)
cohens_d_result
## Cohen's d | 95% CI
## -------------------------
## 0.17 | [-0.41, 0.75]
##
## - Estimated using pooled SD.
In my analysis, focusing on whether the average ratings for drama and comedy genres are the same, the data supported that we can not reject the null hypothesis, which proposed no difference in average ratings. The t-test and Wilcoxon test, both reinforcing this finding with their respective p-values, suggest that the variations in ratings are likely due to random chance rather than a genuine difference between the genres. The small effect size further points to a minimal difference in ratings. Therefore, within my dataset, genre does not appear to have a significant impact on the average movie ratings.
Data for this analysis was sourced from the CinePulse 2023 dataset available on Kaggle (https://www.kaggle.com/datasets/kashishparmar02/cinepulse-2023).