* do-file for Additional exercise 10.2, VHM 802, Winter 2016
version 14 /* works also with version 13 */
set more off
cd "h:\vhm\vhm802"

import delimited data_csv\hs10_2.csv, clear
anova moisture lot
* fixed and random effects 1-way ANOVA tables coincide

mixed moisture || lot:, reml /* xtmixed in Stata 11-12 */
predict pred, fitted
predict stdres, rstandard
scatter stdres pred
qnorm stdres
swilk stdres
predict pred_ref, reffects
bysort lot: gen within_n=_n
qnorm pred_ref if within_n==1
swilk pred_ref if within_n==1
