Hello everybody,
It’s Michael, and today’s post will be the 6th R analysis; the focus of this analysis, as you might have guessed from the title, will be ANOVA. The topic of this ANOVA analysis will be American cartoons.
Here’s the dataset-Cartoons.
Now, as always, let’s load our dataset into R and learn about each variable:

As you can see, we’ve got 78 cartoons (the observations) listed along with 9 other variables that describe the cartoons (such as the name, rating, network, etc.). Here’s a variable-by-variable breakdown:
Name-The name of the cartoonDebut.Year-The year the cartoon premieredSeasons-The number of seasons the cartoon lasted or, if the show is still on the air, the amount of seasons that have aired as of July 1, 2019.Episodes-The number of episodes the cartoon lasted, or, of the show is still on the air, the amount of episodes that have aired as of July 1, 2019.Creator-The creator(s) of the cartoon.Network-The network that currently airs new episodes of the cartoon. Some of the cartoons on this list, such as American Dad, switched networks (in that case, from FOX to TBS), so I list the network that currently airs new episodes.Ended-Whether or not the show ended; this can either be a “Yes” or “No”.Contract.Length-IfEndedis a no, then this denotes the length of a show’s current contract. IfEndedis a yes, then this field is blank.Rating-The shows TV rating, which can be one of these five:- TV-Y
- TV-Y7
- TV-PG
- TV-14
- TV-MA
Now, let’s check for missing values (remember to install the Amelia package). Also remember to use the line missmap(name of file variable) to see the missmap:
Interestingly, the graph doesn’t list any of our variables as missing, even though the Contract.Length variable has several blank spots. However, those blank spots might’ve counted as a value.
Now, let’s do some one-way ANOVA:
In this model, I used Episodes as the dependent variable and Rating as the independent variable. I am trying to analyze the relationship (if there is any) between how many episodes a cartoon has aired and the cartoon’s TV rating (in other words, whether or not the cartoon is for kids). As you can see, Rating has 3 asterisks beside it, meaning that it is a very significant variable.
Now, let’s do a Tukey’s HSD Test to analyze pair-wise differences:
This Tukey’s HSD Test gives us the pair-wise differences among pairs of TV content ratings. Remember that a pair-wise difference with a p adj that is less than 0.01 is statistically significant. There are three statistically significant pair-wise differences, which include:
TV-PG; TV-14-this one is interesting because cartoons withTV-PGandTV-14ratings often air on network TV. For example, FOX airs theTV-PGSimpsons and Bob’s Burgers along with theTV-14Family Guy.TV-PG; TV-MA-this one isn’t as interesting. Well, cartoons with both of these ratings air on cartoon network, though you’ll find plenty more cartoons with aTV-MArating on Cartoon Network’s Adult Swim block (e.g. Robot Chicken, Aqua Teen Hunger Force)TV-Y7; TV-PG-this one is quite interesting, since Cartoon Network has aired several shows with both of these ratings, such as theTV-Y7Ed, Edd n Eddy and Camp Lazlo along with theTV-PGRegular Show and Adventure Time.
Now let’s create a two-way ANOVA model:
In this model, I once again used Episodes as a dependent variable and Rating as an independent variable. However, I also included Network (the network a show airs on) as another independent variable.
Just as with the previous model, Rating is a statistically significant variable, except this time it has slightly less significance, as there are two asterisks instead of three. Network, on the other hand, isn’t significant at all, as its p-value is much greater than 0.01.
Now let’s do a Tukey’s HSD test to analyze pair-wise differences. Since this is a two-way ANOVA, we will see pair-wise differences for :
Tukey multiple comparisons of means
99% family-wise confidence levelFit: aov(formula = file$Episodes ~ file$Network + file$Rating)
$`file$Network`
diff lwr upr p adj
Comedy Central-Cartoon Network -18.6166667 -217.13053 179.89720 1.0000000
Crackle-Cartoon Network -79.3666667 -458.47404 299.74071 0.9997177
Disney Channel-Cartoon Network -39.8666667 -312.22545 232.49211 0.9999939
FOX-Cartoon Network 84.7583333 -63.63972 233.15638 0.5350384
FX-Cartoon Network -0.3666667 -379.47404 378.74071 1.0000000
G4-Cartoon Network 25.6333333 -353.47404 404.74071 1.0000000
Hulu-Cartoon Network -77.3666667 -456.47404 301.74071 0.9997826
Netflix-Cartoon Network -80.3666667 -222.10667 61.37334 0.5465350
Nickelodeon-Cartoon Network 0.6333333 -141.10667 142.37334 1.0000000
PBS-Cartoon Network 0.7444444 -140.99556 142.48445 1.0000000
Showtime-Cartoon Network -85.3666667 -464.47404 293.74071 0.9994113
TBS-Cartoon Network 33.6333333 -238.72545 305.99211 0.9999991
Crackle-Comedy Central -60.7500000 -477.71252 356.21252 0.9999942
Disney Channel-Comedy Central -21.2500000 -344.22778 301.72778 1.0000000
FOX-Comedy Central 103.3750000 -125.00478 331.75478 0.8359614
FX-Comedy Central 18.2500000 -398.71252 435.21252 1.0000000
G4-Comedy Central 44.2500000 -372.71252 461.21252 0.9999998
Hulu-Comedy Central -58.7500000 -475.71252 358.21252 0.9999960
Netflix-Comedy Central -61.7500000 -285.86062 162.36062 0.9959708
Nickelodeon-Comedy Central 19.2500000 -204.86062 243.36062 1.0000000
PBS-Comedy Central 19.3611111 -204.74951 243.47173 1.0000000
Showtime-Comedy Central -66.7500000 -483.71252 350.21252 0.9999835
TBS-Comedy Central 52.2500000 -270.72778 375.22778 0.9999815
Disney Channel-Crackle 39.5000000 -417.25956 496.25956 1.0000000
FOX-Crackle 164.1250000 -231.44038 559.69038 0.9020872
FX-Crackle 79.0000000 -448.42051 606.42051 0.9999921
G4-Crackle 105.0000000 -422.42051 632.42051 0.9998317
Hulu-Crackle 2.0000000 -525.42051 529.42051 1.0000000
Netflix-Crackle -1.0000000 -394.11604 392.11604 1.0000000
Nickelodeon-Crackle 80.0000000 -313.11604 473.11604 0.9997889
PBS-Crackle 80.1111111 -313.00492 473.22715 0.9997858
Showtime-Crackle -6.0000000 -533.42051 521.42051 1.0000000
TBS-Crackle 113.0000000 -343.75956 569.75956 0.9985243
FOX-Disney Channel 124.6250000 -170.21203 419.46203 0.8900907
FX-Disney Channel 39.5000000 -417.25956 496.25956 1.0000000
G4-Disney Channel 65.5000000 -391.25956 522.25956 0.9999951
Hulu-Disney Channel -37.5000000 -494.25956 419.25956 1.0000000
Netflix-Disney Channel -40.5000000 -332.04266 251.04266 0.9999966
Nickelodeon-Disney Channel 40.5000000 -251.04266 332.04266 0.9999966
PBS-Disney Channel 40.6111111 -250.93154 332.15377 0.9999965
Showtime-Disney Channel -45.5000000 -502.25956 411.25956 0.9999999
TBS-Disney Channel 73.5000000 -299.44262 446.44262 0.9998485
FX-FOX -85.1250000 -480.69038 310.44038 0.9996265
G4-FOX -59.1250000 -454.69038 336.44038 0.9999922
Hulu-FOX -162.1250000 -557.69038 233.44038 0.9094227
Netflix-FOX -165.1250000 -346.34254 16.09254 0.0287424
Nickelodeon-FOX -84.1250000 -265.34254 97.09254 0.8118260
PBS-FOX -84.0138889 -265.23143 97.20365 0.8131464
Showtime-FOX -170.1250000 -565.69038 225.44038 0.8778977
TBS-FOX -51.1250000 -345.96203 243.71203 0.9999609
G4-FX 26.0000000 -501.42051 553.42051 1.0000000
Hulu-FX -77.0000000 -604.42051 450.42051 0.9999940
Netflix-FX -80.0000000 -473.11604 313.11604 0.9997889
Nickelodeon-FX 1.0000000 -392.11604 394.11604 1.0000000
PBS-FX 1.1111111 -392.00492 394.22715 1.0000000
Showtime-FX -85.0000000 -612.42051 442.42051 0.9999823
TBS-FX 34.0000000 -422.75956 490.75956 1.0000000
Hulu-G4 -103.0000000 -630.42051 424.42051 0.9998622
Netflix-G4 -106.0000000 -499.11604 287.11604 0.9966917
Nickelodeon-G4 -25.0000000 -418.11604 368.11604 1.0000000
PBS-G4 -24.8888889 -418.00492 368.22715 1.0000000
Showtime-G4 -111.0000000 -638.42051 416.42051 0.9997021
TBS-G4 8.0000000 -448.75956 464.75956 1.0000000
Netflix-Hulu -3.0000000 -396.11604 390.11604 1.0000000
Nickelodeon-Hulu 78.0000000 -315.11604 471.11604 0.9998375
PBS-Hulu 78.1111111 -315.00492 471.22715 0.9998351
Showtime-Hulu -8.0000000 -535.42051 519.42051 1.0000000
TBS-Hulu 111.0000000 -345.75956 567.75956 0.9987571
Nickelodeon-Netflix 81.0000000 -94.80684 256.80684 0.8192765
PBS-Netflix 81.1111111 -94.69572 256.91795 0.8179377
Showtime-Netflix -5.0000000 -398.11604 388.11604 1.0000000
TBS-Netflix 114.0000000 -177.54266 405.54266 0.9335787
PBS-Nickelodeon 0.1111111 -175.69572 175.91795 1.0000000
Showtime-Nickelodeon -86.0000000 -479.11604 307.11604 0.9995591
TBS-Nickelodeon 33.0000000 -258.54266 324.54266 0.9999997
Showtime-PBS -86.1111111 -479.22715 307.00492 0.9995533
TBS-PBS 32.8888889 -258.65377 324.43154 0.9999997
TBS-Showtime 119.0000000 -337.75956 575.75956 0.9975931$`file$Rating`
diff lwr upr p adj
TV-MA-TV-14 46.329035 -63.199178 155.85725 0.6047355
TV-PG-TV-14 147.497292 8.667629 286.32695 0.0052996
TV-Y-TV-14 56.355123 -77.349896 190.06014 0.6079772
TV-Y7-TV-14 51.949774 -50.169122 154.06867 0.4226375
TV-PG-TV-MA 101.168257 -32.481774 234.81829 0.0874937
TV-Y-TV-MA 10.026088 -118.292607 138.34478 0.9988693
TV-Y7-TV-MA 5.620739 -89.336747 100.57822 0.9996220
TV-Y-TV-PG -91.142168 -245.229589 62.94525 0.2719733
TV-Y7-TV-PG -95.547518 -223.196137 32.10110 0.0934011
TV-Y7-TV-Y -4.405350 -126.460775 117.65008 0.9999471
Just like the Tukey’s Test for the model I created in R Lesson 18: ANOVA part 2, each variable’s pair-wise differences are analyzed separately. In other words, the pair-wise differences for Network are analyzed separately from the pair-wise differences for Rating.
Another thing I want to note is that since all of the p-values for the Network pair-wise differences are well above 0.01, there aren’t any statistically significant pair-wise differences for Network. On the other hand, there is a statistically significant pair-wise difference for Rating, which would be the TV-PG - TV-14 pair. Unlike the one-way ANOVA, Rating has a lower statistical significance (since there are two asterisks by Rating instead of three) and thus has fewer statistically significant pair-wise differences.
From the data, I can conclude that a cartoon’s rating (if you don’t factor in any other variables) is a good indicator as to how many episodes that cartoon will air. However, the combination of a cartoon’s rating and the network it airs on makes it less certain to predict how many episodes might air.
Thanks for reading,
Michael