Diamond Goh (Jia Goh) s4138267
22/10/2024
Data Source: Link to data source on Kaggle
Rank (Factor): Represents the popularity ranking based on the overall sales made for the video game. Ordinal Variable: Each unique rank (e.g. 1, 2, 99, etc.) represents a meaningful order.
Name (Character): Represents the name of the video game.
Year (Numeric): Represents the year of the video game’s release.
Genre (Character): Represents the genre of the video game (Action, Sports, RPG, etc.).
Platform (Factor): Represents the platform on which the video game was released (e.g., PlayStation, Xbox, PC). Levels: Each unique platform (e.g., PS4, Xbox One, PC) represents a level.
Genre (Factor): Represents the genre of the game (e.g., Action, Sports, RPG). Levels: Each unique game genre (Action, Adventure, Sports, etc.) represents a level in this factor. Like Platform, this variable will need to be treated as a factor.
Global_Sales, NA_Sales, EU_Sales, JP_Sales, Other_Sales (Numeric): Represents the total worldwide sales of the game (in millions). For instance, if Global_Sales is 1.5, it means the game sold 1.5 million units globally.
# Import data
vgSales <- read_csv('vgsales.csv', show_col_types = FALSE)
# Convert Platform and Genre to factors
vgSales$Platform <- as.factor(vgSales$Platform)
vgSales$Genre <- as.factor(vgSales$Genre)
# Check for missing Values
colSums(is.na(vgSales[, c("Platform", "Genre", "Global_Sales")]))## Platform Genre Global_Sales
## 0 0 0
##
## 2600 3DO 3DS DC DS GB GBA GC GEN GG N64 NES NG PC PCFX PS
## 133 3 509 52 2163 98 822 556 27 1 319 98 12 960 1 1196
## PS2 PS3 PS4 PSP PSV SAT SCD SNES TG16 Wii WiiU WS X360 XB XOne
## 2161 1329 336 1213 413 173 6 239 2 1325 143 6 1265 824 213
##
## Action Adventure Fighting Misc Platform Puzzle
## 3316 1286 848 1739 886 582
## Racing Role-Playing Shooter Simulation Sports Strategy
## 1249 1488 1310 867 2346 681
# Group by Platform and summarize Global Sales statistics
platform_sales_summary <- vgSales %>%
group_by(Platform) %>%
summarise(
Min = min(Global_Sales, na.rm = TRUE),
Q1 = quantile(Global_Sales, probs = 0.25, na.rm = TRUE),
Median = median(Global_Sales, na.rm = TRUE),
Q3 = quantile(Global_Sales, probs = 0.75, na.rm = TRUE),
Max = max(Global_Sales, na.rm = TRUE),
Mean = mean(Global_Sales, na.rm = TRUE),
SD = sd(Global_Sales, na.rm = TRUE),
n = n(),
Missing = sum(is.na(Global_Sales))
)
# Display the summary statistics in a table format
kable(platform_sales_summary)| Platform | Min | Q1 | Median | Q3 | Max | Mean | SD | n | Missing |
|---|---|---|---|---|---|---|---|---|---|
| 2600 | 0.07 | 0.2900 | 0.460 | 0.7800 | 7.81 | 0.7299248 | 0.9172410 | 133 | 0 |
| 3DO | 0.02 | 0.0200 | 0.020 | 0.0400 | 0.06 | 0.0333333 | 0.0230940 | 3 | 0 |
| 3DS | 0.01 | 0.0500 | 0.120 | 0.3400 | 14.35 | 0.4861690 | 1.3904305 | 509 | 0 |
| DC | 0.02 | 0.0775 | 0.135 | 0.2975 | 2.42 | 0.3071154 | 0.4699117 | 52 | 0 |
| DS | 0.01 | 0.0500 | 0.110 | 0.2800 | 30.01 | 0.3802543 | 1.4346158 | 2163 | 0 |
| GB | 0.06 | 0.3025 | 1.165 | 2.1650 | 31.37 | 2.6066327 | 5.3652870 | 98 | 0 |
| GBA | 0.01 | 0.0600 | 0.165 | 0.3900 | 15.85 | 0.3874696 | 0.8965171 | 822 | 0 |
| GC | 0.01 | 0.0700 | 0.150 | 0.3525 | 7.07 | 0.3585612 | 0.6854875 | 556 | 0 |
| GEN | 0.03 | 0.0700 | 0.150 | 1.7100 | 6.03 | 1.0503704 | 1.4922169 | 27 | 0 |
| GG | 0.04 | 0.0400 | 0.040 | 0.0400 | 0.04 | 0.0400000 | NA | 1 | 0 |
| N64 | 0.01 | 0.1350 | 0.270 | 0.5950 | 11.89 | 0.6861442 | 1.3159653 | 319 | 0 |
| NES | 0.06 | 1.0000 | 1.375 | 2.2225 | 40.24 | 2.5619388 | 5.1081953 | 98 | 0 |
| NG | 0.02 | 0.0550 | 0.100 | 0.2000 | 0.25 | 0.1200000 | 0.0822413 | 12 | 0 |
| PC | 0.01 | 0.0200 | 0.040 | 0.1800 | 8.11 | 0.2696042 | 0.6814934 | 960 | 0 |
| PCFX | 0.03 | 0.0300 | 0.030 | 0.0300 | 0.03 | 0.0300000 | NA | 1 | 0 |
| PS | 0.01 | 0.1075 | 0.260 | 0.6600 | 10.95 | 0.6109197 | 1.0546872 | 1196 | 0 |
| PS2 | 0.01 | 0.0800 | 0.230 | 0.5600 | 20.81 | 0.5810458 | 1.1379896 | 2161 | 0 |
| PS3 | 0.01 | 0.1100 | 0.280 | 0.7700 | 21.40 | 0.7207223 | 1.4128497 | 1329 | 0 |
| PS4 | 0.01 | 0.0600 | 0.220 | 0.8200 | 14.24 | 0.8276786 | 1.6189658 | 336 | 0 |
| PSP | 0.01 | 0.0300 | 0.090 | 0.2300 | 7.72 | 0.2442539 | 0.5224603 | 1213 | 0 |
| PSV | 0.01 | 0.0200 | 0.060 | 0.1600 | 2.25 | 0.1499516 | 0.2527451 | 413 | 0 |
| SAT | 0.02 | 0.0800 | 0.120 | 0.2600 | 1.93 | 0.1941618 | 0.2178489 | 173 | 0 |
| SCD | 0.05 | 0.0525 | 0.065 | 0.1225 | 1.50 | 0.3116667 | 0.5831438 | 6 | 0 |
| SNES | 0.01 | 0.1350 | 0.320 | 0.7050 | 20.61 | 0.8370293 | 1.8690588 | 239 | 0 |
| TG16 | 0.02 | 0.0500 | 0.080 | 0.1100 | 0.14 | 0.0800000 | 0.0848528 | 2 | 0 |
| Wii | 0.01 | 0.0900 | 0.200 | 0.4900 | 82.74 | 0.6994038 | 3.1380555 | 1325 | 0 |
| WiiU | 0.01 | 0.0750 | 0.230 | 0.5300 | 6.96 | 0.5724476 | 1.0696796 | 143 | 0 |
| WS | 0.03 | 0.1725 | 0.215 | 0.2725 | 0.51 | 0.2366667 | 0.1594574 | 6 | 0 |
| X360 | 0.01 | 0.1100 | 0.280 | 0.7700 | 21.82 | 0.7746719 | 1.6189057 | 1265 | 0 |
| XB | 0.01 | 0.0700 | 0.140 | 0.3500 | 8.49 | 0.3134223 | 0.5343016 | 824 | 0 |
| XOne | 0.01 | 0.0700 | 0.240 | 0.6800 | 7.30 | 0.6622535 | 1.0392984 | 213 | 0 |
# Visualize Global Sales by Platform using a boxplot
ggplot(vgSales, aes(x = Platform, y = Global_Sales)) +
geom_boxplot() +
labs(title = "Distribution of Global Sales by Platform", x = "Platform", y = "Global Sales (in millions)") +
theme_minimal() +
theme(plot.title = element_text(size = 18),
axis.text.x = element_text(size = 6),
axis.text.y = element_text(size = 12),
axis.title = element_text(size = 14))# Group by Genre and summarize Global Sales statistics
genre_sales_summary <- vgSales %>%
group_by(Genre) %>%
summarise(
Min = min(Global_Sales, na.rm = TRUE),
Q1 = quantile(Global_Sales, probs = 0.25, na.rm = TRUE),
Median = median(Global_Sales, na.rm = TRUE),
Q3 = quantile(Global_Sales, probs = 0.75, na.rm = TRUE),
Max = max(Global_Sales, na.rm = TRUE),
Mean = mean(Global_Sales, na.rm = TRUE),
SD = sd(Global_Sales, na.rm = TRUE),
n = n(),
Missing = sum(is.na(Global_Sales))
)
# Display the summary statistics for Genre
kable(genre_sales_summary)| Genre | Min | Q1 | Median | Q3 | Max | Mean | SD | n | Missing |
|---|---|---|---|---|---|---|---|---|---|
| Action | 0.01 | 0.07 | 0.190 | 0.5000 | 21.40 | 0.5281001 | 1.1564272 | 3316 | 0 |
| Adventure | 0.01 | 0.02 | 0.060 | 0.1600 | 11.18 | 0.1858787 | 0.5132800 | 1286 | 0 |
| Fighting | 0.01 | 0.08 | 0.210 | 0.5500 | 13.04 | 0.5293750 | 0.9559647 | 848 | 0 |
| Misc | 0.01 | 0.06 | 0.160 | 0.4100 | 29.02 | 0.4657619 | 1.3148859 | 1739 | 0 |
| Platform | 0.01 | 0.09 | 0.280 | 0.7900 | 40.24 | 0.9383409 | 2.5852543 | 886 | 0 |
| Puzzle | 0.01 | 0.04 | 0.110 | 0.3075 | 30.26 | 0.4208763 | 1.5617163 | 582 | 0 |
| Racing | 0.01 | 0.07 | 0.190 | 0.5300 | 35.82 | 0.5861009 | 1.6624370 | 1249 | 0 |
| Role-Playing | 0.01 | 0.07 | 0.185 | 0.5225 | 31.37 | 0.6232325 | 1.7079089 | 1488 | 0 |
| Shooter | 0.01 | 0.08 | 0.230 | 0.7275 | 28.31 | 0.7918855 | 1.8172633 | 1310 | 0 |
| Simulation | 0.01 | 0.05 | 0.160 | 0.4200 | 24.76 | 0.4523645 | 1.1952546 | 867 | 0 |
| Sports | 0.01 | 0.09 | 0.220 | 0.5600 | 82.74 | 0.5673188 | 2.0897159 | 2346 | 0 |
| Strategy | 0.01 | 0.04 | 0.090 | 0.2700 | 5.45 | 0.2571512 | 0.5209082 | 681 | 0 |
# Visualize Global Sales by Genre using a boxplot
ggplot(vgSales, aes(x = Genre, y = Global_Sales)) +
geom_boxplot() +
labs(title = "Distribution of Global Sales by Genre", x = "Genre", y = "Global Sales (in millions)") +
theme_minimal() +
theme(plot.title = element_text(size = 18),
axis.text.x = element_text(size = 8),
axis.text.y = element_text(size = 12),
axis.title = element_text(size = 14))# Subset the data for PS4 and Xbox 360
ps4_xbox <- vgSales[vgSales$Platform %in% c("PS4", "X360"), ]
# Perform Levene's test to check for equal variances
leveneTest(Global_Sales ~ Platform, data = ps4_xbox)Levene’s Test for Equal Variance:
If p > 0.05, we assume equal variances and proceed with a regular
t-test.
If p < 0.05, we assume unequal variances and use the Welch’s t-test
(which adjusts for unequal variances).
We can see from the Levene’s Test, p = 0.3068 > 0.05. Therefore, we can assume equal variance between Global Sales of PS4 and Global Sales of Xbox 360. So we can proceed with a regular t-test.
# Perform t-test assuming equal variances
t.test(Global_Sales ~ Platform, data = ps4_xbox, var.equal = TRUE)##
## Two Sample t-test
##
## data: Global_Sales by Platform
## t = 0.53349, df = 1599, p-value = 0.5938
## alternative hypothesis: true difference in means between group PS4 and group X360 is not equal to 0
## 95 percent confidence interval:
## -0.1418803 0.2478935
## sample estimates:
## mean in group PS4 mean in group X360
## 0.8276786 0.7746719
Interpretation of the T-Test Results:
From the output shown:
t-statistic (t = 0.53349): This value represents the number of standard deviations the difference between the means is from 0.
Degrees of freedom (df = 1599): This indicates the number of independent data points that went into calculating the t-statistic.
p-value (p = 0.5938): The p-value is 0.5938, which is greater than 0.05. This means we fail to reject the null hypothesis, indicating that there is no statistically significant difference in global sales between PS4 and Xbox 360.
Confidence Interval (-0.1418803 to 0.2478935): This shows the range in which the true difference in means lies with 95% confidence. Since the interval includes 0, it further confirms that there is no significant difference between the global sales of the two platforms.
Conclusion: The results indicate that the difference in global sales between PS4 and Xbox 360 is not statistically significant. The p-value of 0.5938 suggests that any observed difference in the means is likely due to random variation rather than a true underlying difference between the two platforms.
Reminder that: Null Hypothesis (H0): The average
global sales of video games on PS4 is equal to the average global sales
on Xbox 360.
Alternative Hypothesis (Ha): The average global sales of video games on
PS4 is different from the average global sales on Xbox 360.
We fail to reject the null hypothesis, which indicates that there is no significant difference in global sales between PS4 and Xbox 360.
Therefore, the data do not provide sufficient evidence to support that the global sales of video games on PS4 are different from those on Xbox 360.
Hypothesis 1 (T-Test):
For a two-sample t-test, the formula for the t-statistic is:
\[ t = \frac{\bar{X}_1 - \bar{X}_2}{\sqrt{s_p^2 \left( \frac{1}{n_1} + \frac{1}{n_2} \right)}} \] The pooled variance, \(s_p^2\), is a weighted average of the variances of the two groups, assuming equal variances between the groups. It is calculated as:
\[s_p^2 = \frac{(n_1 - 1)s_1^2 + (n_2 - 1)s_2^2}{n_1 + n_2 - 2}\]
where \(s_1^2\) and \(s_2^2\) are the sample variances of each group, and \(n_1\) and \(n_2\) are the sample sizes of each group.
With Degrees of freedom: \[ df = n_1 + n_2 - 2 \]
# Contingency table of Genre and Platform
contingency_table <- table(vgSales$Genre, vgSales$Platform)
# Chi-squared test
chisq.test(contingency_table)##
## Pearson's Chi-squared test
##
## data: contingency_table
## X-squared = 5910, df = 330, p-value < 2.2e-16
Interpretation of the Chi-Squared Test
Results:
From the output shown:
Chi-Squared Statistic (\(X^2 = 5910)\): This value represents the sum of the squared differences between the observed and expected frequencies, normalized by the expected frequencies. It indicates how far the observed data deviate from the expected data under the null hypothesis of no association.
Degrees of Freedom (df = 330): The degrees of freedom for this test, calculated as \((r - 1)(c - 1)\), where \( r \) is the number of rows (genres) and \( c \) is the number of columns (platforms). This represents the number of independent comparisons that can be made in the contingency table.
p-value (p < 2.2e-16): The p-value is extremely small, effectively 0, which is much less than the significance level of 0.05. This means we reject the null hypothesis, indicating that there is a statistically significant association between Genre and Platform.
Conclusion: The results indicate a significant association between the genre of a video game and the platform it is released on. The p-value of p < 2.2e-16 suggests that the observed differences in the distribution of genres across platforms are unlikely to have occurred by chance alone. Therefore, we conclude that certain genres are more likely to be associated with specific platforms.
Reminder that: Null Hypothesis (H0): There is no
association between the genre of a video game and the platform it is
released on.
Alternative Hypothesis (HA): There is an association between the genre
of a video game and the platform it is released on.
We reject the null hypothesis, which indicates that there is a
significant association between genre and platform.
Therefore, the data provide strong evidence to suggest that the genre of a video game is associated with the platform it is released on, meaning that certain platforms may favor specific genres or vice versa.
Hypothesis 2 (Chi-Squared Test of Independence) Formula:
\[ \chi^2 = \sum \frac{(O_{ij} -
E_{ij})^2}{E_{ij}} \] With Degrees of freedom:
\[ df = (r - 1)(c - 1) \]
Major Findings:
This investigation explored the relationship between
Platforms and Global Sales of video
games, as well as the association between Genre and
Platform. For Hypothesis 1, comparing
PS4 and Xbox 360 sales, we found no
statistically significant difference in average global sales between the
two platforms. For Hypothesis 2, the chi-squared test
revealed a statistically significant association between
Genre and Platform, indicating that
certain genres are more likely to be associated with specific
platforms.
Strengths and Limitations:
- Strengths: This analysis used a large dataset,
providing robust insights into video game sales across multiple
platforms and genres. The use of both t-tests and chi-squared tests
allowed us to examine relationships between different variables
effectively.
- Limitations: The analysis focused only on select
platforms for the t-test, limiting broader insights across all
platforms. Additionally, the chi-squared test does not reveal the nature
of the association (i.e., which specific genres are most popular on
which platforms), only that an association exists. Additionally, the
dataset might be slightly outdated and new data needs/should be
collected to reflect the current state of the video game industry.
Future Directions:
Future research could involve:
1. Expanded platform comparisons: Conducting an
analysis across multiple platforms (using ANOVA or
similar methods) to provide a more comprehensive view of sales
patterns.
2. Genre popularity by region: Examining whether
certain genres are more popular in specific regions or among specific
demographics.
3. Temporal trends: Analyzing how platform and genre
associations change over time to understand trends in the gaming
industry.
Conclusion:
The key takeaway from this investigation is that while global
sales do not significantly differ between PS4 and Xbox 360,
game genre is significantly associated
with the platform it is released on. This suggests that
platform choice may be influenced by
genre-specific trends or audience preferences. Future
investigations should explore these genre-platform relationships in
greater depth to guide industry decisions on game development and
platform-specific releases.
Base R: R Core Team (2024). R: A Language and Environment for Statistical Computing. R Foundation for Statistical Computing, Vienna, Austria. https://www.R-project.org/.
dplyr: Wickham H, François R, Henry L, Müller K, Vaughan D (2023). dplyr: A Grammar of Data Manipulation. R package version 1.1.4, https://CRAN.R-project.org/package=dplyr.
readr: Wickham H, Hester J, Bryan J (2024). readr: Read Rectangular Text Data. R package version 2.1.5, https://CRAN.R-project.org/package=readr.
magrittr: Bache S, Wickham H (2022). magrittr: A Forward-Pipe Operator for R. R package version 2.0.3, https://CRAN.R-project.org/package=magrittr.
knitr: Xie Y (2024). knitr: A General-Purpose Package for Dynamic Report Generation in R. R package version 1.48, https://yihui.org/knitr/.
Yihui Xie (2015) Dynamic Documents with R and knitr. 2nd edition. Chapman and Hall/CRC. ISBN 978-1498716963
Yihui Xie (2014) knitr: A Comprehensive Tool for Reproducible Research in R. In Victoria Stodden, Friedrich Leisch and Roger D. Peng, editors, Implementing Reproducible Computational Research. Chapman and Hall/CRC. ISBN 978-1466561595
tibble: Müller K, Wickham H (2023). tibble: Simple Data Frames. R package version 3.2.1, https://CRAN.R-project.org/package=tibble.
kable: Zhu H (2024). kableExtra: Construct Complex Table with ‘kable’ and Pipe Syntax. R package version 1.4.0, https://CRAN.R-project.org/package=kableExtra.
car: Fox J, Weisberg S (2019). An R Companion to Applied Regression, Third edition. Sage, Thousand Oaks CA. https://www.john-fox.ca/Companion/.