## to demonstrate four typical deviations from normal distribution ## chisquare distribution (skewed to the left), ## lognormal distribution (skewed to the right), ## t-distribution (heavy tails), ## uniform distribution (light tails) z <- rnorm(1000) y.chisq <- z^2 y.chisq <- (y.chisq-mean(y.chisq))/sd(y.chisq) y.lnorm <- log(z+5) y.lnorm <- (y.lnorm-mean(y.lnorm))/sd(y.lnorm) y.t <- rt(1000,3) y.t <- (y.t-mean(y.t))/sd(y.t) y.unif <- runif(1000) y.unif <- (y.unif-mean(y.unif))/sd(y.unif) postscript("qqplot.ps",horizontal=T) par(mfrow=c(2,4)) hist(y.lnorm,main="Right skewed distribution") hist(y.chisq,main="Left skewed distribution") hist(y.t,main="Heavy-tail distribution") hist(y.unif,main="Light-tail distribution") qqnorm(y.lnorm,xlim=c(-4,4),ylim=c(-4,4),main="") abline(0,1) qqnorm(y.chisq,ylim=c(-3,7),xlim = c(-3,7),main="") abline(0,1) qqnorm(y.t,xlim=c(-6,6),ylim=c(-6,6),main="") abline(0,1) qqnorm(y.unif,xlim=c(-3,3),ylim=c(-3,3),main="") abline(0,1) dev.off()