* do-file for lecture 8 of VHM 802, Winter 2021
version 16 /* works also with versions 14-15 */
set more off
cd "r:\"

* Manly Example 1.1
import delimited r:\sparrow.csv, clear
tabstat total_length-l_keel_sternum, statistics( mean sd ) by(survivorship)
pwcorr total_length-l_keel_sternum
bysort survivorship: pwcorr total_length-l_keel_sternum
graph matrix total_length-l_keel_sternum
graph matrix total_length-l_keel_sternum, by(survivorship)
* not obvious how to get different symbols by survivorship

* Manly Example 1.4
import delimited r:\prehist_dog.csv, clear
* uses add-on package chernoff
chernoff, isize(mandbreadth) nose(mandheight) bdens(mol1length) fline(mol1breadth) msize(mol13length) mcurv(mol14length) order(group) ilabel(group) legend(3) rows(2)
* bar chart
gen species=_n
label define sgroup 1 "Modern dog" 2 "Golden jackal" 3 "Chinese wolf" 4 "Indian wolf" 5 "Cuon" 6 "Dingo" 7 "Prehistoric dog"
label values species sgroup
graph bar (asis) mol1breadth mandbreadth mol1length mandheight mol13length mol14length, over(species, label(labsize(small)))
* profile plot, using xtline command; first reshape to long data format
rename mol1breadth value1
rename mandbreadth value2
rename mol1length value3
rename mandheight value4
rename mol13length value5
rename mol14length value6
reshape long value, i(group) j(ordvar)
xtline value, i(group) t(ordvar) overlay