<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="https://www.r-bloggers.com/a-political-cartoon-and-a-markov-chain/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://ntguardian.wordpress.com/2016/12/16/political-cartoon-markov-chain/"> R – Curtis Miller's Personal Website</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p><a target="_blank" rel="nofollow" href="http://www.sltrib.com/staff/pat-bagley/">Pat Bagley</a> is easily my favorite political cartoonist, period. For the politically aware in Utah, he is almost legendary, enjoying superstar status. I’ve been aware of him since I was a kid, and I always loved his cartoons. Not only does his artistic style appeal to me, he has a way of illustrating a situation in politics that explains it more clearly than a thousand words. His cartoons are humorous, though darkly so. And with every one, you can’t help but feel he’s had the last word.</p>
<p><span></span></p>
<p>I was very lucky to meet Mr. Bagley in 2016. It was at PechaKucha Night 2016, hosted by the Salt Lake City chapter of <a target="_blank" rel="nofollow" href="https://wiaslc.com/">Women in Architecture</a>, a professional organization promoting the advancement of women in architecture (a profession <a target="_blank" rel="nofollow" href="http://www.latimes.com/opinion/op-ed/la-oe-stratigakos-missing-women-architects-20160421-story.html">dominated by men</a>). My <a target="_blank" rel="nofollow" href="https://ntguardian.files.wordpress.com/2016/08/gendergap1.pdf">gender gap</a> <a target="_blank" rel="nofollow" href="https://ntguardian.files.wordpress.com/2016/08/gendergapthesis.pdf">studies</a> were making headlines throughout 2015 (you can find a list <a target="_blank" rel="nofollow" href="https://ntguardian.wordpress.com/professional-information/">here</a>), and the group wanted me to give a very short talk on the topic. Pat Bagley was also a speaker that night, and clearly the star attraction both to the audience and the other speakers as well. Everyone wanted a picture with Pat Bagley.</p>
<p>And we got one:</p>
<p><img src="https://i1.wp.com/ntguardian.files.wordpress.com/2016/12/bag1.jpg?w=456&ssl=1" data-recalc-dims="1"></p>
<p>I did not say much to Mr. Bagley. I told him he was my favorite political cartoonist bar none. He thanked me for the compliment (I got the impression that it was one he heard frequently), and he did not mind that I would be using one of his cartoons in my presentation, <a target="_blank" rel="nofollow" href="http://www.sltrib.com/opinion/3095442-155/bagley-cartoon-pay-notch-in-the">one inspired by my research</a>. But otherwise we did not talk much; mostly I just listened to him shoot the breeze with one of the other speakers, discussing politics both national and local and his disgust with the behavior of the Utah state legislature, along with life at the Salt Lake Tribune. (You can guess what he said by <a target="_blank" rel="nofollow" href="https://www.youtube.com/watch?v=bq2_wSsDwkQ">watching this clip from Last Week Tonight with John Oliver on the plight of local newspapers</a>; both he and the editor of the Tribune, who I sat with at an Honor’s College fundraising dinner in 2015, have said the Tribune has felt those pressures, along with those brought on by a business deal with the LDS Church-owned Deseret News that, thankfully, no longer exists.) Every once in a while I would make a comment, but otherwise I was on the periphery. During my presentation, I gave him the shoutout he deserved, and he told me as I walked off the stage that he thought my presentation was excellent. That meant a lot to me.</p>
<p>Mr. Bagley, being the star attraction, presented last. His presentation consisted of describing life as a political cartoonist and showing some of his favorite cartoons, which commented on Utah political and Mormon culture and the uncomfortable relationship between the legislature and the LDS Church. (I don’t think a video of his talk exists online, unfortunately.) It was simple but enjoyable, a great end to a great night, and I am just as big a fan as ever (as is obvious by the signed cartoon below).<br>
<img src="https://i1.wp.com/ntguardian.files.wordpress.com/2016/12/wp-1481949359337.jpg?w=456&ssl=1" data-recalc-dims="1"></p>
<p>On October 27th of this year, the Tribune <a target="_blank" rel="nofollow" href="http://www.sltrib.com/opinion/4515747-155/bagley-cartoon-game-of-life">published this Bagley cartoon:</a></p>
<p><img src="https://i0.wp.com/ntguardian.files.wordpress.com/2016/12/bag2.jpg?w=456&ssl=1" data-recalc-dims="1"></p>
<p>The game is clearly playable, even though it’s no more fun than a game of Shoots and Ladders (and it’s obviously not supposed to be fun; it’s supposed to make a depressing point about life for those in poverty). I saw the cartoon/board game while the students in my R lab were working on their assignments. I spent a few minutes analyzing the game, and realized its simple structure could easily be analyzed via a Markov chain. Upon that realization I had no choice but to follow through with the analysis; it was an itch that had to be scratched.</p>
<p>The game terminates when the player gets evicted. One could also consider “winning” the game being a state that ends the game. Eviction and a “win” can be considered absorbing states in the chain. Furthermore, other than the blue, yellow, and orange spaces, every colored space ends in eviction. The only way to “win” is to land on every grey space after the orange space (seven heads in a row, which has a probability of <img title="\frac{127}{128} \approx 0.992" alt="\frac{127}{128} \approx 0.992" class="latex" src="https://s0.wp.com/latex.php?latex=%5Cfrac%7B127%7D%7B128%7D+%5Capprox+0.992&bg=ffffff&%23038;fg=444444&%23038;s=0"> of occurring).</p>
<p>Analyzing the above board, I came up with the following transition matrix, which I program into R:</p>
<pre><code>gmat &lt;- rbind(c(0, .5, .5, 0, 0, 0, 0, 0, 0, 0),
              c(0, 0, .5, .5, 0, 0, 0, 0, 0, 0),
              c(1, 0, 0, 0, 0, 0, 0, 0, 0, 0),
              c(0, 0, 0, 0, .5, .5, 0, 0, 0, 0),
              c(0, 0, 0, 0, 0, .5, .5, 0, 0, 0),
              c(0, 0, 0, 0, 0, 1, 0, 0, 0, 0),
              c(0, 0, 0, 0, 0, .5, 0, .5, 0, 0),
              c(0, 0, 0, 0, 0, .5, 0, 0, .5, 0),
              c(0, 0, 0, 0, 0, .5, 0, 0, 0, .5),
              c(0, 0, 0, 0, 0, 0, 0, 0, 0, 1))
</code></pre>
<p>Ten states are possible, with the sixth state representing eviction and the last a “win”, both of which are absorbing states. The chain will end in either of the two states with some probability. The questions are:</p>
<ol>
<li>What is the probability of ending in each of these absorbing states?</li>
<li>How long will it take to complete the game?</li>
</ol>
<p>These are well-known problems and the solution is easy to find; in my case, I just looked up the <a target="_blank" rel="nofollow" href="https://en.wikipedia.org/wiki/Absorbing_Markov_chain#Absorbing_probabilities">solution on Wikipedia</a>.</p>
<p>First, I extract the matrices <img title="Q" alt="Q" class="latex" src="https://s0.wp.com/latex.php?latex=Q&bg=ffffff&%23038;fg=444444&%23038;s=0"> and <img title="R" alt="R" class="latex" src="https://s0.wp.com/latex.php?latex=R&bg=ffffff&%23038;fg=444444&%23038;s=0">, as described in the Wikipedia article:</p>
<pre><code>(Q  &lt;- gmat[c(1:5,7:9), c(1:5, 7:9)])
</code></pre>
<pre>##      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
## [1,]    0  0.5  0.5  0.0  0.0  0.0  0.0  0.0
## [2,]    0  0.0  0.5  0.5  0.0  0.0  0.0  0.0
## [3,]    1  0.0  0.0  0.0  0.0  0.0  0.0  0.0
## [4,]    0  0.0  0.0  0.0  0.5  0.0  0.0  0.0
## [5,]    0  0.0  0.0  0.0  0.0  0.5  0.0  0.0
## [6,]    0  0.0  0.0  0.0  0.0  0.0  0.5  0.0
## [7,]    0  0.0  0.0  0.0  0.0  0.0  0.0  0.5
## [8,]    0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
</pre>
<pre><code>(R &lt;- gmat[c(1:5, 7:9), c(6,10)])
</code></pre>
<pre>##      [,1] [,2]
## [1,]  0.0  0.0
## [2,]  0.0  0.0
## [3,]  0.0  0.0
## [4,]  0.5  0.0
## [5,]  0.5  0.0
## [6,]  0.5  0.0
## [7,]  0.5  0.0
## [8,]  0.5  0.5
</pre>
<p>I also need the matrix <img title="N = (I - Q)^{-1}" alt="N = (I - Q)^{-1}" class="latex" src="https://s0.wp.com/latex.php?latex=N+%3D+%28I+-+Q%29%5E%7B-1%7D&bg=ffffff&%23038;fg=444444&%23038;s=0">:</p>
<pre><code>(N &lt;- solve(diag(1, 8) - Q))
</code></pre>
<pre>##      [,1] [,2] [,3] [,4] [,5] [,6]  [,7]   [,8]
## [1,]    4    2    3    1  0.5 0.25 0.125 0.0625
## [2,]    2    2    2    1  0.5 0.25 0.125 0.0625
## [3,]    4    2    4    1  0.5 0.25 0.125 0.0625
## [4,]    0    0    0    1  0.5 0.25 0.125 0.0625
## [5,]    0    0    0    0  1.0 0.50 0.250 0.1250
## [6,]    0    0    0    0  0.0 1.00 0.500 0.2500
## [7,]    0    0    0    0  0.0 0.00 1.000 0.5000
## [8,]    0    0    0    0  0.0 0.00 0.000 1.0000
</pre>
<p>This is all we need to get the information we want. The matrix containing the probability of absorption is <img title="B = NR" alt="B = NR" class="latex" src="https://s0.wp.com/latex.php?latex=B+%3D+NR&bg=ffffff&%23038;fg=444444&%23038;s=0">, found below:</p>
<pre><code>N %*% R
</code></pre>
<pre>##         [,1]    [,2]
## [1,] 0.96875 0.03125
## [2,] 0.96875 0.03125
## [3,] 0.96875 0.03125
## [4,] 0.96875 0.03125
## [5,] 0.93750 0.06250
## [6,] 0.87500 0.12500
## [7,] 0.75000 0.25000
## [8,] 0.50000 0.50000
</pre>
<p>The first column represents the state of being “evicted”, the second “winning”. The first number in the first column represents the probability of being evicted at the start of the game. There is a better chance than it initially seemed to “win” the game, thanks to the impossibility of being evicted for a few rounds in the game; it’s after one passes the eviction square that the “point of no return” is crossed. That said, a 97% chance of losing the game every time you play hardly makes for a fun experience.</p>
<p>The expected number of steps until absorption is found below:</p>
<pre><code>N %*% rep(1, times = 8)
</code></pre>
<pre>##         [,1]
## [1,] 10.9375
## [2,]  7.9375
## [3,] 11.9375
## [4,]  1.9375
## [5,]  1.8750
## [6,]  1.7500
## [7,]  1.5000
## [8,]  1.0000
</pre>
<p>Well, that was fun. But is the game’s depiction realistic? No, not really. I have no data to back this up, but I’m sure that more than 3% of families in poverty keep their home by the end of the month. That said, having come from a family where life went from lower-middle-class to <em>de facto</em> poverty in a few years, I can say he effectively captured the unfairness.</p>
<p> <a target="_blank" rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ntguardian.wordpress.com/2043/"><img alt="" src="http://feeds.wordpress.com/1.0/comments/ntguardian.wordpress.com/2043/" border="0"></a> <img alt="" src="https://i1.wp.com/pixel.wp.com/b.gif?resize=1%2C1&ssl=1" border="0" data-recalc-dims="1"></p>
<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://ntguardian.wordpress.com/2016/12/16/political-cartoon-markov-chain/"> R – Curtis Miller's Personal Website</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a title="The R Project for Statistical Computing" rel="nofollow" href="https://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="https://www.r-bloggers.com/search/data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="https://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="https://www.r-bloggers.com/search/map">maps</a>, <a title="Animation in R" rel="nofollow" href="https://www.r-bloggers.com/search/animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="https://www.r-bloggers.com/search/sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="https://www.r-bloggers.com/search/SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="https://www.r-bloggers.com/search/git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="https://www.r-bloggers.com/search/hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="https://www.r-bloggers.com/search/PCA">PCA</a>, <a title="Time series" rel="nofollow" href="https://www.r-bloggers.com/search/time+series">time series</a>, <a title="finance trading" rel="nofollow" href="https://www.r-bloggers.com/search/trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/xUUVttuvN0A"></a></div>