This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #' Extract information about two-way terms in a loglinear model | |
| #' | |
| #' This function is designed for use with an association graph showing the pairwise | |
| #' dependencies among categorical variables in a loglinear model for frequencies | |
| #' fit using \code{\link[MASS]{loglm}} or \code{\link[stats]{glm}} in a poisson family. | |
| #' The goal is to show | |
| #' an association graph diagram with edges indicating the strength of associations | |
| #' between each pair of variables. | |
| #' | |
| #' The weight for two-way terms can be found using the deviance or LRT or AIC statistic |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head> | |
| <meta charset="utf-8"> | |
| <meta name="generator" content="quarto-1.0.37"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes"> | |
| <title>Quarto: Test LaTeX newcommands in HTML doc</title> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Demonstrate Lord's Paradox example, following Michael Clarke | |
| # https://m-clark.github.io/docs/lord/index.html | |
| library(ggplot2) | |
| library(dplyr) | |
| #' ## Data example: Initial and final weight for boys & girls | |
| #' | |
| #' Make a plot showing the distribution of gain scores perpendicular to the line of slope = 1 | |
| #' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @comment{Physical analogs for statistical models} | |
| @article{GainesPalphrey:1932, | |
| ISSN = {00368075, 10959203}, | |
| URL = {http://www.jstor.org/stable/1658643}, | |
| author = {W. L. Gaines and J. R. Palfrey}, | |
| journal = {Science}, | |
| number = {1977}, | |
| pages = {472--474}, | |
| publisher = {American Association for the Advancement of Science}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Stacked Barplot of Support for Political Parites by Province in 2019 Canadian Federal Election | |
| # written by Christopher D. Green | |
| # 22 October 2019 | |
| # additions by MF 31 Oct 2019 | |
| provs<-c("BC","AB","SK","MB","ON","QC","NB","NS","PE","NF") # names of the provinces | |
| pops<-c(5.0,4.3,1.2,1.4,14.4,8.4,0.8,1.0,0.2,0.5) # populations in millions | |
| con<-c(34.1,69.2,64.3,45.4,33.2,16.0,32.8,25.7,27.4,28.0) # % support for Conservatives | |
| lib<-c(26.1,13.7,11.6,26.3,41.5,34.2,37.6,41.3,43.6,44.7) # % support for Liberals |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #' # Reproduce Minard's March on Moscow Graphic using ggplot2 | |
| #' This gist extends the examples given in the HistData package. It explicitly | |
| #' shows the construction of the plot as layers, and adds the plot of temperature | |
| #' vs. longitude below the plot of troop strength. | |
| #' ## Load data and required packages | |
| data(Minard.troops, package="HistData") | |
| data(Minard.cities, package="HistData") | |
| data(Minard.temp, package="HistData") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Taken from: http://janhove.github.io/teaching/2016/11/21/what-correlations-look-like | |
| # source: http://janhove.github.io/RCode/plot_r.R | |
| # | |
| # plot_r | |
| # | |
| # Given a correlation coefficient and a sample size, | |
| # this function draws 16 scatterplots | |
| # whose shapes differ greatly | |
| # but all of which are consistent with the correlation coefficient. | |
| # |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #' Wavelength to RGB | |
| #' | |
| #' This function converts a given wavelength of light to an | |
| #' approximate RGB color value. | |
| #' | |
| #' @param wavelength A wavelength value, in nanometers, in the human visual range from 380 nm through 750 nm. | |
| #' These correspond to frequencies in the range from 789 THz through 400 THz. | |
| #' @param gamma The \eqn{\gamma} correction for a given display device. The linear RGB values will require | |
| #' gamma correction if the display device has nonlinear response. | |
| #' @return a color string, corresponding to the result of \code{\link[grDevices]{rgb}} on the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #' --- | |
| #' title: "3D demonstrations of linear transformations and matrix inverse" | |
| #' author: "Michael Friendly" | |
| #' date: "30 Sep 2016" | |
| #' --- | |
| #' Start with a unit cube, representing the identity matrix. Show its transformation | |
| #' by a matrix $A$ as the corresponding transformation of the cube. | |
| #' | |
| #' This also illustrates the determinant, det(A), as the volume of the transformed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Box's M-test for Homogeneity of Covariance Matrices | |
| boxM <- | |
| function(mod, ...) UseMethod("boxM") | |
| boxM.default <- function(Y, group) | |
| { | |
| dname <- deparse(substitute(Y)) | |
| if (!inherits(Y, c("data.frame", "matrix"))) |