Showing posts with label plotmatrix. Show all posts
Showing posts with label plotmatrix. Show all posts

Nov 2, 2018

Random graphs (141): Heat map

matrix al = (.27, .09 ,-.01 \ .10, -.06, -.13 \ -.04 ,-0.17, -0.30)

plotmatrix, mat(al) split(-.4(0.05).4) ///
            freq formatcells(%6.2f) ///
            legend(title("Wear and tear" "(allostatic load)") ///
                   col(1) ///
                   order(1 "Less wear and tear" 5 "Average" 8 "More wear and tear") ) ///
            xlabel(1 "Working" 2 "Intermediate" 3 "Higher") ///
            ylabel(0 "Working" -1 "Intermediate" -2 "Higher") ///
            xscale(alt) yscale(rev) ///
            xtitle(Participant's social class) ///
            ytitle(Parental class) ///
            note(" " "Numbers denote the average allostatic load in that group. The overall average across all classes is 0 (SD = 1)", span)

Dec 28, 2017

Random graphs (123): Descriptive statistics

// Open Allbus 2010
use v11 v13 v15 v17 v19 using ZA4612_v1-0-1.dta, clear

// Prepare variables
recode v11 v13 v15 v17 v19 (99 = .)
label define x 1 `""1" "Unimportant""' 7 `""7 Very" "important"'

label var v11 "v11: Job security"
label var v13 "v13: High income"
label var v15 "v15: Opportunities for promotion"
label var v17 "v17: Respectable occupation"
label var v19 "v19: Lots of leisure time"

// Plot histograms
foreach x of varlist v11 v13 v15 v17 v19 {
  label val `x' x
  histogram `x', frequency ///
                 xlabel(1 (1) 7, val) ///
                 ylabel(0 (500) 1500) ///
                 ytick(0 (250) 1750) ///
                 name(`x', replace) nodraw
}

// Calculate correlation matrix
cor v11-v19
matrix correlations = r(C)

// Plot correlation matrix
plotmatrix, mat(correlations) split(-1(0.10)1) color(sienna) ///
            freq formatcells(%6.2f) nodiag legend(title(Pearson's {it:r}) col(1)) ///
            name(cormatrix, replace) nodraw 

// Combine plots
graph combine v11 v13 v15 v17 v19 cormatrix, col(2) ysize(8) xsize(6) altshrink