2024-02-11

Twitch Streaming Statistical Analytics

There is a new streamer who wants to really invest himself into the trade. He’s recruited us to find ways for him to have a larger insight on the streaming platform so he can gain an upper edge by finding out where, when and how the viewers are spending their time. We’ve been given the task to find out how games rank over time. The Problem is theres too many games and way too much data to go through and the client needs to spend their time Streaming. It is important to show everything else the data is telling us. Along side various stats, the client also wants to know what the competition is up to. The plan is to visualize the data by showing:
- Top ranked games with the most streamers
- What months and games have the highest hours watched
- Show where and on what games the avg viewer is spending their time
- Show him what all the streamers collectively are doing, what games they are playing along with their average viewers and how much they are being watched.
So lets start exploring the data!

Lets Start Here

To begin we must first download our data set, Locate, and have R read in the file(S). Once this is accomplished lets take a peak at how our data is structured so we can begin visualizing our data and begin finding answers to our problems.

twitch <- read.csv("Twitch_game_data.csv") %>% 
  filter(Game != "Just Chatting")
str(twitch)
## 'data.frame':    18539 obs. of  12 variables:
##  $ Rank            : int  1 2 3 4 5 6 7 8 9 10 ...
##  $ Game            : chr  "League of Legends" "Counter-Strike: Global Offensive" "Dota 2" "Hearthstone" ...
##  $ Month           : int  1 1 1 1 1 1 1 1 1 1 ...
##  $ Year            : int  2016 2016 2016 2016 2016 2016 2016 2016 2016 2016 ...
##  $ Hours_watched   : int  94377226 47832863 45185893 39936159 16153057 10231056 8771452 7894571 7688369 6988475 ...
##  $ Hours_streamed  : int  1362044 830105 433397 235903 1151578 490002 342978 205569 53235 203646 ...
##  $ Peak_viewers    : int  530270 372654 315083 131357 71639 64432 46130 41588 84051 145728 ...
##  $ Peak_channels   : int  2903 2197 1100 517 3620 1538 1180 460 148 756 ...
##  $ Streamers       : int  129172 120849 44074 36170 214054 88820 33375 21396 10779 46462 ...
##  $ Avg_viewers     : int  127021 64378 60815 53749 21740 13769 11805 10625 10347 9405 ...
##  $ Avg_channels    : int  1833 1117 583 317 1549 659 461 276 71 274 ...
##  $ Avg_viewer_ratio: num  69.3 57.6 104.3 169.3 14 ...

Top Ranked Games Statistics

Okay now that we know what are data looks like lets dive in. After a quick peak into the data we notice we needed to do some filtering. Here we are going to explore a bit and display what the top games are and show how many streamers are streaming and how much they are being watched. Lets take a look:

topgame_size <- 10
top_games <- twitch %>% 
             filter(Year == max(Year)-1) %>%
             group_by(Month) %>%
             slice_max(Hours_watched, n = topgame_size) %>%
             mutate(Rank = Rank -1)
#print(top_games)
top_games_ly <- plot_ly(top_games, y = ~Game, x = ~Streamers, 
                        color = ~Avg_viewers,
                        text = ~paste(Game, "<br>",month.name[Month]),
                        type = 'bar', orientation = 'h', 
                        colors = viridisLite::viridis(10)) %>%
                 layout(title = "Top Game Statistics",
                        yaxis = list(title = "Game", categoryorder = 'array', 
                        categoryarray = ~Rank),
                        xaxis = list(title = "Accumulation of Streamers 
                                     (collective over the months)"),
                        barmode = 'group')

top_games_ly


This is a visual on the bar plot showing the top ranking games(bottom to top), as the bar progresses to the right you’ll see how many streamers are streaming each month broken up by color of the bar where the color represents the average viewer over that month.

Findings

Surprisingly enough our graph is able to answer more of the problems and questions for us from just this one graph than we anticipated. Also with a few tweaks of the code we are able to peak around at different years. This would be a great time to confront the client and offer the ability to offer to build a shiny app to offer him the ability to peer into the data from his phone or computer and keep up with the data as the years progress.What we are finding is actually quite special. Our findings tell us (from also looking at a few years) That we notice the greatest peaks in viewers are happening in the the first and early months of the year and drop or stabilize as the year progresses. With this bar graph we note the names in the axis are listed highest to lower rankings from bottom to top respectively, also each bar has segments which are each month and average viewers are shown by the color scheme allowing us to see the highest hours watched for each game. Along with the zoom features of the plot we are able to dive further into the data and also pin point games by their month and ranking with the hover over feature. The total number of streamers is the accumulation of streamers over each month, the actual number of streamers each month is available upon hovering over the highlight month.

Utilizing 3D Data

After The huge findings we gained with just our bar plot_ly, lets take a look at this “lines+markers” 3d scatter plot. This will be able to show us the relationships between the number of Streamers, Hours watched and Average viewers(by color). Each point on the scatter plot is a game and if you hover it will unveil the data we’ve been craving!

top_game_3d <- plot_ly(top_games, 
                      x = ~Streamers, 
                      y = ~Avg_viewers, 
                      z = ~Hours_watched,
                      color = ~Avg_viewers,
                      text = ~paste(Game, "<br>",month.name[Month], 
                                    '<br>Rank: ',Rank),
                      type = "scatter3d",
                      mode = "lines+markers") %>%
  layout(scene = list(xaxis = list(title = "Streamers"),
                      yaxis = list(title = "Avg Viewers"),
                      zaxis = list(title = "Hours Watched")),
         title = "3D Scatter Plot of the Top Game Stats")

Time to Visualize!

top_game_3d

3D Findings

From our findings we can see that each plot is connected by line to group them by the month they are in. A simple dive into the 3d plot will expose the Name, Month, and Rank of each Game per plot, additional information we get actual numbers for the amount of Streamers, Average Viewers and Hours Watch respectively to x.y, and z postioning. Surpringly a very powerful and fun Plot_ly.

Some Linear Regression!

top_games_lm <- lm(Avg_viewers ~ Streamers + Month, data = twitch %>% 
                   filter(Game != "Just Chatting"))
top_games_lmly <- plot_ly(twitch, x = ~Streamers, y = ~Avg_viewers, 
                          text = ~paste(Game, "<br>",month.name[Month],
                                        '<br> Rank: ',Rank), 
                          type = 'scatter', 
                          mode = 'markers',
                          marker = list(color = ~Streamers, 
                                        colorscale = 'Viridis')) %>%
                                   add_trace(y = ~predict(top_games_lm, 
                                                      newdata = twitch), 
                          type = 'scatter', 
                          mode = 'lines', 
                          name = 'Linear Regression') %>%
                  layout(title = "Linear Regression of Top Streaming Stats",
                         xaxis = list(title = "Streamers"),
                         yaxis = list(title = "Average Viewers"),
                        yaxis2 = list(title = "Average Viewers", 
                    overlaying = "y", side = "right", 
                     autorange = "reversed"))

Linear Regression Model

top_games_lmly

Model Summary

summary(top_games_lm)
## 
## Call:
## lm(formula = Avg_viewers ~ Streamers + Month, data = twitch %>% 
##     filter(Game != "Just Chatting"))
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -162019   -2516   -1747    -721  402641 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 1.854e+03  2.299e+02   8.067 7.67e-16 ***
## Streamers   2.334e-01  1.743e-03 133.942  < 2e-16 ***
## Month       2.052e+01  3.143e+01   0.653    0.514    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 14570 on 18536 degrees of freedom
## Multiple R-squared:  0.4919, Adjusted R-squared:  0.4918 
## F-statistic:  8971 on 2 and 18536 DF,  p-value: < 2.2e-16

Findings and Conclusion

This linear model is used to estimate a linear relation between the number of streamers and the average number of viewers. This helps us to understand how the changes over time and with number of streamers are associated with changes in average viewers. This plot allows us to visualize how well the linear model fits the observed data. This is a best fit model.
In conclusion we can note that the number of streamers is a valid predictor of the average number of viewers, but the month might not be statistically significant in predicting views. However when you put it all together it may seem as though there are trends in the data that show us the first quarter of the year has the highest peaks in viewers and hours watched. So it may be a great idea to build your stream aesthetics over the latter half of the year and really make sure to be pushing content out during the first quarter in an attempt to make a name!