{"id":962,"date":"2018-05-15T15:30:16","date_gmt":"2018-05-15T20:30:16","guid":{"rendered":"http:\/\/www.hargaden.com\/enda\/?p=962"},"modified":"2021-04-15T16:56:39","modified_gmt":"2021-04-15T16:56:39","slug":"colouring-table-cells-to-indicate-statistical-significance","status":"publish","type":"post","link":"https:\/\/hargaden.com\/enda\/colouring-table-cells-to-indicate-statistical-significance\/","title":{"rendered":"Colouring table cells to indicate statistical significance"},"content":{"rendered":"<p>Over on <a href=\"https:\/\/twitter.com\/graykimbrough\/status\/989878469713694720?lang=en\" target=\"_blank\" rel=\"noopener\">Twitter<\/a>, Gray Kimbrough suggests using colour to indicate statistical significance\/p-values instead of the traditional stars. This was part of a broader argument for Powerpoint over Beamer.<\/p>\n<p>I much prefer Beamer to Powerpoint, and I knew it would be very easy to implement coloured cells in regression tables directly from Stata into LaTeX\/beamer.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium\" src=\"https:\/\/hargaden.com\/enda\/wp-content\/green.PNG\" width=\"741\" height=\"827\" \/><\/p>\n<p>I use the wonderful <a href=\"http:\/\/repec.sowi.unibe.ch\/stata\/estout\/\" target=\"_blank\" rel=\"noopener\">estout<\/a> to produce regression tables (and have <a href=\"https:\/\/hargaden.com\/enda\/fitting-tables-to-the-width-of-a-page\/\">modified it<\/a> in the past) so here&#8217;s how to produce the table above with one extra line in your do-file.<\/p>\n<style>\npre, code{<br \/>\n\tdirection: ltr;<br \/>\n\ttext-align: left;<br \/>\n}<br \/>\npre {border: solid 1px blue;<br \/>\n\tfont-size: 0.7 em;<br \/>\n \tcolor: blue;<br \/>\n\tmargin: 8px;<br \/>\n\tpadding:8px;<br \/>\n\tbackground: #FFFFB3}<br \/>\ncode {font-size:0.7em;<br \/>\n\tcolor: #008099}<br \/>\n<\/style>\n<pre><code>clear\nsysuse auto\n\n** This line generates a local named siggreen, defining significance with green opacity\nlocal siggreen \"star(\\cellcolor{green!10} 0.10 \\cellcolor{green!35} 0.05 \\cellcolor{green!95} 0.01) nonotes\"\n\n** Run a few sample regressions\nqui eststo: reg price foreign mpg weight\nqui eststo: reg price foreign mpg weight turn\nqui eststo: reg price foreign mpg weight turn gear_ratio displacement headroom\n\n** Using esttab, produce the output with Enda's preferred options\nesttab using myoutput.tex, replace booktabs nodepvars nomtitle se label ar2 `siggreen' title(\"Green Regression\")\n<\/code><\/pre>\n<p>Then, to include that table into your TeX document:<\/p>\n<pre><code>\\documentclass{article}\n\\usepackage[table]{xcolor}\n\\usepackage{booktabs}\n\\begin{document}\n\\input{myoutput}\n\\end{document} \n<\/code><\/pre>\n<p>If you want to include this tables in your Beamer slides, <a href=\"https:\/\/hargaden.com\/enda\/?p=981\">see this post<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Over on Twitter, Gray Kimbrough suggests using colour to indicate statistical significance\/p-values instead of the traditional stars. This was part of a broader argument for Powerpoint over Beamer. I much prefer Beamer to Powerpoint, and&hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,8,10],"tags":[],"class_list":["post-962","post","type-post","status-publish","format-standard","hentry","category-economics","category-latex","category-stata"],"_links":{"self":[{"href":"https:\/\/hargaden.com\/enda\/wp-json\/wp\/v2\/posts\/962","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hargaden.com\/enda\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hargaden.com\/enda\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hargaden.com\/enda\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/hargaden.com\/enda\/wp-json\/wp\/v2\/comments?post=962"}],"version-history":[{"count":1,"href":"https:\/\/hargaden.com\/enda\/wp-json\/wp\/v2\/posts\/962\/revisions"}],"predecessor-version":[{"id":1163,"href":"https:\/\/hargaden.com\/enda\/wp-json\/wp\/v2\/posts\/962\/revisions\/1163"}],"wp:attachment":[{"href":"https:\/\/hargaden.com\/enda\/wp-json\/wp\/v2\/media?parent=962"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hargaden.com\/enda\/wp-json\/wp\/v2\/categories?post=962"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hargaden.com\/enda\/wp-json\/wp\/v2\/tags?post=962"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}