class: center, middle, inverse, title-slide .title[ # An Introduction to
[ comment ]
and RStudio for Educational Researchers ] .subtitle[ ##
Descriptive and Inferential Statistics: Graphics ] .author[ ### Jorge Sinval ] .date[ ### 2025-11-18 ] --- class: inverse, center, middle <style> .orange { color: #EB811B; } .kbd { display: inline-block; padding: .2em .5em; font-size: 0.75em; line-height: 1.75; color: #555; vertical-align: middle; background-color: #fcfcfc; border: solid 1px #ccc; border-bottom-color: #bbb; border-radius: 3px; box-shadow: inset 0 -1px 0 #bbb } </style>
# 2. Descriptive Statistics and Graphics <html><div style='float:left'></div><hr color='#EB811B' size=1px width=800px></html> --- # 2.7 Graphical representations >Visual representation of descriptive and association statistics **Advantages**: easy acquisition of information -visual memory **Disadvantages**: undemanding, and can be misleading -- .pull-left[ There are many plots...  ] -- .pull-right[ But <svg viewBox="0 0 581 512" xmlns="http://www.w3.org/2000/svg" style="height:1em;position:relative;display:inline-block;top:.1em;fill:#384CB7;"> [ comment ] <path d="M581 226.6C581 119.1 450.9 32 290.5 32S0 119.1 0 226.6C0 322.4 103.3 402 239.4 418.1V480h99.1v-61.5c24.3-2.7 47.6-7.4 69.4-13.9L448 480h112l-67.4-113.7c54.5-35.4 88.4-84.9 88.4-139.7zm-466.8 14.5c0-73.5 98.9-133 220.8-133s211.9 40.7 211.9 133c0 50.1-26.5 85-70.3 106.4-2.4-1.6-4.7-2.9-6.4-3.7-10.2-5.2-27.8-10.5-27.8-10.5s86.6-6.4 86.6-92.7-90.6-87.9-90.6-87.9h-199V361c-74.1-21.5-125.2-67.1-125.2-119.9zm225.1 38.3v-55.6c57.8 0 87.8-6.8 87.8 27.3 0 36.5-38.2 28.3-87.8 28.3zm-.9 72.5H365c10.8 0 18.9 11.7 24 19.2-16.1 1.9-33 2.8-50.6 2.9v-22.1z"></path></svg>'s are more fun!  ] --- exclude: true # ... and more plots! <center>
</center> --- # Plots with `ggplot2` - Hadley Wickham's [Doctoral thesis](http://had.co.nz/thesis/practical-tools-hadley-wickham.pdf)<sup>🎓</sup>. - Based on Leland Wilkinson's *grammar of graphics* <sup>📚</sup>. > A plot is a visual representation of data that uses aesthetic attributes (position, color, shape, size, ...) of geometric shapes (points, lines, bars, ...). .footnote[ 👩🎓 Wickham, H. A. (2008). Practical tools for exploring data and models [Doctoral thesis, Iowa State University]. https://lib.dr.iastate.edu/rtd/15639 📚 Wilkinson, L. (2005). _The grammar of graphics_ (2nd ed.). Springer. https://doi.org/10.1007/0-387-28695-0 ] --- # Data visualization with `ggplot2` - Based on this definition, Hadley developed the *layered grammar of graphics*: each graphic element can be represented by a layer, and a graphic will be the overlay of these layers. -- .pull-left[ <center> <img src="assets/img/layers.png" width = 60%> </center> ] -- .pull-right[ <center>  </center> ] -- <br> However, not only from `ggplot2` do graphics live in <svg viewBox="0 0 581 512" xmlns="http://www.w3.org/2000/svg" style="height:1em;position:relative;display:inline-block;top:.1em;fill:#384CB7;"> [ comment ] <path d="M581 226.6C581 119.1 450.9 32 290.5 32S0 119.1 0 226.6C0 322.4 103.3 402 239.4 418.1V480h99.1v-61.5c24.3-2.7 47.6-7.4 69.4-13.9L448 480h112l-67.4-113.7c54.5-35.4 88.4-84.9 88.4-139.7zm-466.8 14.5c0-73.5 98.9-133 220.8-133s211.9 40.7 211.9 133c0 50.1-26.5 85-70.3 106.4-2.4-1.6-4.7-2.9-6.4-3.7-10.2-5.2-27.8-10.5-27.8-10.5s86.6-6.4 86.6-92.7-90.6-87.9-90.6-87.9h-199V361c-74.1-21.5-125.2-67.1-125.2-119.9zm225.1 38.3v-55.6c57.8 0 87.8-6.8 87.8 27.3 0 36.5-38.2 28.3-87.8 28.3zm-.9 72.5H365c10.8 0 18.9 11.7 24 19.2-16.1 1.9-33 2.8-50.6 2.9v-22.1z"></path></svg>, graphics can also be produced with the `base` package... --- # Boxplot .pull-left[ <br> <img src="data:image/png;base64,#slides5of9_files/figure-html/plot-1.png" width="100%" /> ] -- .pull-right[ <br> One of the most informative graphical representations. <sup>💡</sup> <br> The height of the box corresponds to the `\(IQR=Q_3-Q_1\)`. <br> However, the frequency of its use is less than expected. Useful for ordinal and quantitative variables. ] -- .footnote[ 💡 Very suitable for identifying .orange[outliers.] ] --- # Alternatives Other identical forms of representation (e.g. .orange[dot plots], and .orange[Highest Density Region (HDR) box Plots]... [among others](http://datavizcatalogue.com/blog/box-plot-variations/ "See here other possibilities") ) <center> <img src="data:image/png;base64,#slides5of9_files/figure-html/hdrboxplot_dotplot-1.png" width="50%" /> </center> --- # Histogram -- .pull-left[ <center> <img src="data:image/png;base64,#slides5of9_files/figure-html/histogram-1.png" width="100%" /> </center> ] -- .pull-right[ <br> Variables on the abscissa (xx) axis can be continuous (using classes built with the Sturges rule<sup>📜</sup>) or discrete. <br> Frequencies on the ordinate (yy) can be relative or absolute. ] .footnote[ 📜 Sturges, H. A. (1926). The choice of a class interval. _Journal of the American Statistical Association, 21_(153), 65–66. [https://doi.org/10.1080/01621459.1926.10502161](https://doi.org/10.1080/01621459.1926.10502161) ] --- # Bar graph -- .pull-left[ <center> <br> <br> <br> <img src="data:image/png;base64,#slides5of9_files/figure-html/barplot-1.png" width="100%" /> </center> ] -- .pull-right[ <br> <br> <br> The length of the bars on the y-axis (yy) is proportional to the dimension of the categories of the qualitative variable, represented on the abscissa axis (xx): <br> Frequencies on the ordinate (yy) axes can be absolute `\((n_i)\)` or relative `\((f_i)\)`. ] --- # Error-bar graph -- .pull-left[ <br> <br> <center> <img src="data:image/png;base64,#slides5of9_files/figure-html/barplot_error-1.png" width="100%" /> </center> ] -- .pull-right[ <br> <br> <br> <br> The bar represents `\(\bar x\)`. <br> The "whiskers" represents the `\(SEM\)` (or `\(S’\)`). ] --- # Circle chart -- .pull-left[ <center> <br> <br> <img src="data:image/png;base64,#slides5of9_files/figure-html/pie_plot-1.png" width="100%" /> </center> ] -- .pull-right[ <br> <br> <br> <br> Circular representation of absolute `\((n_i)\)` or relative `\((f_i)\)` frequencies. ] --- # Scatter plot -- .pull-left[ <center> <img src="data:image/png;base64,#slides5of9_files/figure-html/scaterplot-1.png" width="100%" /> </center> ] -- .pull-right[ <br> <br> <br> Useful to illustrate bivariate relationships between variables. <br> Two quantitative variables are needed. ] --- # Summary The graphical analysis depends on the information that the variables present, i.e. on the .orange[measurement scale]. <br> | Measurement scale | Graphical representation | |------------------|-----------------------| | Qualitative:<br>Nominal | Bar graph <br> Circle chart | | Qualitative:<br>Ordinal| Bar graph <br> Circle chart<br> Boxplot | | Quantitative:<br>Interval<br>Ratio| Error-bar graph <br> Boxplot <br> Histogram <br> Scatter plot| --- # Creativity -- .pull-left[ Make use of creativity without losing rigor. <br> Remembering that... <br> <br> _You can put lipstick on a pig..._ ] -- .pull-right[ <center>  <br> .font40[© Mick Coulas] </center> ] <center> <i>but it’s still a pig.</i> </center> --- # Creativity <center>  </center> --- # Creativity <center> <img src="data:image/png;base64,#slides5of9_files/figure-html/multivariate_plot-1.png" width="70%" /> </center> --- class: center, bottom, inverse # More info -- Slides created with the <svg viewBox="0 0 581 512" xmlns="http://www.w3.org/2000/svg" style="height:1em;position:relative;display:inline-block;top:.1em;fill:#384CB7;"> [ comment ] <path d="M581 226.6C581 119.1 450.9 32 290.5 32S0 119.1 0 226.6C0 322.4 103.3 402 239.4 418.1V480h99.1v-61.5c24.3-2.7 47.6-7.4 69.4-13.9L448 480h112l-67.4-113.7c54.5-35.4 88.4-84.9 88.4-139.7zm-466.8 14.5c0-73.5 98.9-133 220.8-133s211.9 40.7 211.9 133c0 50.1-26.5 85-70.3 106.4-2.4-1.6-4.7-2.9-6.4-3.7-10.2-5.2-27.8-10.5-27.8-10.5s86.6-6.4 86.6-92.7-90.6-87.9-90.6-87.9h-199V361c-74.1-21.5-125.2-67.1-125.2-119.9zm225.1 38.3v-55.6c57.8 0 87.8-6.8 87.8 27.3 0 36.5-38.2 28.3-87.8 28.3zm-.9 72.5H365c10.8 0 18.9 11.7 24 19.2-16.1 1.9-33 2.8-50.6 2.9v-22.1z"></path></svg> package [`xaringan`](https://github.com/yihui/xaringan). -- <svg viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg" style="height:1em;fill:currentColor;position:relative;display:inline-block;top:.1em;"> <g label="icon" id="layer6" groupmode="layer"> <path id="path2" d="M 132.62426,316.69067 C 119.2805,301.94483 112.56962,274.5073 112.56962,234.39862 v -54.79191 c 0,-37.32217 -5.81677,-63.58084 -17.532347,-78.83466 -11.6757,-15.293118 -31.159702,-22.922596 -58.353466,-22.922596 -5.958581,0 -11.409226,0.22492 -16.45319,0.5917 -5.04455,0.427121 -9.742846,1.037046 -14.1564111,1.83092 V 95.057199 H 16.671281 c 12.325533,0 20.908335,3.82414 25.667559,11.532201 4.77973,7.74964 7.139712,25.48587 7.139712,53.14663 v 68.01321 c 0,42.12298 13.016861,74.19672 39.233939,96.16314 19.627549,16.47424 46.636229,27.23363 81.030059,32.40064 v -20.17708 c -16.3928,-4.27176 -29.04346,-10.51565 -37.11829,-19.44413 z m 246.75144,0 c 13.34377,-14.74584 20.05466,-42.18337 20.05466,-82.29205 v -54.79191 c 0,-37.32217 5.81673,-63.58084 17.53235,-78.83466 11.67568,-15.293118 31.15971,-22.922596 58.35348,-22.922596 5.95858,0 11.40922,0.22492 16.45315,0.5917 5.04457,0.427121 9.74287,1.037046 14.15645,1.83092 v 14.785125 h -10.59712 c -12.32549,0 -20.90826,3.82414 -25.66752,11.532201 -4.77974,7.74964 -7.13972,25.48587 -7.13972,53.14663 v 68.01321 c 0,42.12298 -13.01688,74.19672 -39.23394,96.16314 -19.6275,16.47424 -46.63622,27.23363 -81.03006,32.40064 v -20.17708 c 16.39279,-4.27176 29.04347,-10.51565 37.11827,-19.44413 z M 303.95857,87.165762 c 8.42049,-6.691524 25.52576,-10.536158 51.23486,-11.492333 V 63.999997 H 156.80716 v 11.673432 c 26.1755,0.956175 43.38268,4.800809 51.68248,11.492333 8.31852,6.73139 12.40691,20.033568 12.40691,39.904818 V 384.6851 c 0,20.80641 -4.08839,34.5146 -12.40691,41.02332 -8.2998,6.56905 -25.50698,10.10729 -51.68248,10.65744 V 448 h 197.71597 l 0.67087,-11.63414 c -25.50471,-0.54955 -42.56835,-4.35266 -51.07201,-11.40918 -8.4182,-6.95638 -12.73153,-20.44184 -12.73153,-40.27158 V 127.07058 c 0,-19.87125 4.16983,-33.173428 12.56922,-39.904818 z" style="stroke-width:0.0753388"></path> </g></svg> + <svg viewBox="0 0 581 512" xmlns="http://www.w3.org/2000/svg" style="height:1em;position:relative;display:inline-block;top:.1em;fill:#384CB7;"> [ comment ] <path d="M581 226.6C581 119.1 450.9 32 290.5 32S0 119.1 0 226.6C0 322.4 103.3 402 239.4 418.1V480h99.1v-61.5c24.3-2.7 47.6-7.4 69.4-13.9L448 480h112l-67.4-113.7c54.5-35.4 88.4-84.9 88.4-139.7zm-466.8 14.5c0-73.5 98.9-133 220.8-133s211.9 40.7 211.9 133c0 50.1-26.5 85-70.3 106.4-2.4-1.6-4.7-2.9-6.4-3.7-10.2-5.2-27.8-10.5-27.8-10.5s86.6-6.4 86.6-92.7-90.6-87.9-90.6-87.9h-199V361c-74.1-21.5-125.2-67.1-125.2-119.9zm225.1 38.3v-55.6c57.8 0 87.8-6.8 87.8 27.3 0 36.5-38.2 28.3-87.8 28.3zm-.9 72.5H365c10.8 0 18.9 11.7 24 19.2-16.1 1.9-33 2.8-50.6 2.9v-22.1z"></path></svg> = <svg viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg" style="height:1em;position:relative;display:inline-block;top:.1em;fill:red;"> [ comment ] <path d="M462.3 62.6C407.5 15.9 326 24.3 275.7 76.2L256 96.5l-19.7-20.3C186.1 24.3 104.5 15.9 49.7 62.6c-62.8 53.6-66.1 149.8-9.9 207.9l193.5 199.8c12.5 12.9 32.8 12.9 45.3 0l193.5-199.8c56.3-58.1 53-154.3-9.8-207.9z"></path></svg> -- <svg viewBox="0 0 581 512" xmlns="http://www.w3.org/2000/svg" style="height:1em;position:relative;display:inline-block;top:.1em;fill:#384CB7;"> [ comment ] <path d="M581 226.6C581 119.1 450.9 32 290.5 32S0 119.1 0 226.6C0 322.4 103.3 402 239.4 418.1V480h99.1v-61.5c24.3-2.7 47.6-7.4 69.4-13.9L448 480h112l-67.4-113.7c54.5-35.4 88.4-84.9 88.4-139.7zm-466.8 14.5c0-73.5 98.9-133 220.8-133s211.9 40.7 211.9 133c0 50.1-26.5 85-70.3 106.4-2.4-1.6-4.7-2.9-6.4-3.7-10.2-5.2-27.8-10.5-27.8-10.5s86.6-6.4 86.6-92.7-90.6-87.9-90.6-87.9h-199V361c-74.1-21.5-125.2-67.1-125.2-119.9zm225.1 38.3v-55.6c57.8 0 87.8-6.8 87.8 27.3 0 36.5-38.2 28.3-87.8 28.3zm-.9 72.5H365c10.8 0 18.9 11.7 24 19.2-16.1 1.9-33 2.8-50.6 2.9v-22.1z"></path></svg> has infinite possibilities. -- Practice is the best strategy for learning. -- . -- _In God we trust, all others bring data_ -- Edwards Deming -- . -- . -- . -- THE END --- class: center, bottom, inverse 