* ======================================================================= * File: plot_t_distributions.SPS . * Date: 21-Feb-2003 . * Author: Bruce Weaver, weaverb@mcmaster.ca . * Notes: Plot PDFs of standard normal and selected t-distributions . * ======================================================================= . * Plot PDFs of standard normal distribution, and t-distributions * with df = 2, 10, and 30. INPUT PROGRAM. LOOP case=0 TO 8000. compute x = (case-4000)/1000. END CASE. END LOOP. END FILE. END INPUT PROGRAM. EXECUTE. COMPUTE t.2 = PDF.T(x,2) . COMPUTE t.10 = PDF.T(x,10) . COMPUTE t.30 = PDF.T(x,30) . COMPUTE z = PDF.NORMAL(x,0,1) . EXECUTE . format t.2 to z (f8.5). var lab t.2 't (df=2)' t.10 't (df=10)' t.30 't (df=30)' z 'Standard normal'. GRAPH /SCATTERPLOT(OVERLAY)= x x x x WITH t.2 t.10 t.30 z (PAIR) /MISSING=LISTWISE /TITLE= 'Probability density functions'. GRAPH /SCATTERPLOT(OVERLAY)= x x x WITH z t.2 t.10 (PAIR) /MISSING=LISTWISE /TITLE= 'Probability density functions'. * Red curve: Standard normal distribution . * Blue curve: t-distribution with df = 10 . * Yellow curve: t-distribution with df = 2 . * Create table that shows area beyond critical values of -1.96 and +1.96 * for the standard normal, and t-disributions with varying degrees of freedom. DATA LIST LIST /t df (2F5.0). BEGIN DATA. 0 0 1 1 1 2 1 3 1 4 1 5 1 10 1 15 1 20 1 25 1 30 1 40 1 50 1 100 1 200 1 300 1 400 1 500 1 1000 1 5000 1 10000 END DATA. do if t. - COMPUTE alpha2 = CDF.T(-1.96,df) * 2 . else. - COMPUTE alpha2 = CDF.NORMAL(-1.96,0,1) * 2. end if. exe. format alpha2 (f8.5). var lab t 'Type of Distribution' df 'Degrees of freedom' alpha2 '2-tailed alpha'. val lab t 0 'Standard Normal' 1 't-distribution' / df 0 'N/A'. summarize table = all /title = 'Proportion of area beyond critical values of - and + 1.96' /cells = none /format = list nocasenum /stat = none. * ======================================================================= .