*** To start with, I will delete all graphics. If you look at your SAS/GRAPH window you will see, at the top, the graph names and you will see they are all in the catalog GSEG (WORK.GSEG) **; PROC greplay igout = work.gseg nofs; delete _all_ ; **** Example 4.2 dmdt - which table, Chisq(4) or Chisq(14) has smallest P? both show <.0001. Use normal approximation? How well does that work at small P-values? We check it out here; goptions reset=all; **(1) Naive approximation ***; Data a; do J= 1 to 40; P = .5**j; C4 = Cinv(1-P,4); C4 = (c4-4)/sqrt(8); Z = probit(1-P); C14 = Cinv(1-p,14); C14 = (c14-14)/sqrt(28); output; end; Title "Percentile vs. Tail Probability"; TItle2 "Naive approximation"; Proc gplot; plot (C4 C14 Z)*P/overlay legend; symbol1 v=none i=join; proc gplot; plot (C4 C14 Z)*P/overlay legend; where P<.0001; run; ** (2) Taylor + CLT(See Spiegel, Schaum's Outlines - Statistics); ** Spiegel states that sqrt(2 Chisq) - sqrt(2 df -1) is approx. N(0,1); Data B; Do J=1 to 40; P = .5**j; C4 = Cinv(1-P,4); Z4 = sqrt(2*C4)-sqrt(7); Z = probit(1-P); C14 = Cinv(1-p,14); Z14 = sqrt(2*C14)-sqrt(27); output; end; Title2 "Taylor + CLT"; Proc gplot; plot (Z4 Z14 Z)*P/overlay legend; proc gplot; plot (Z4 Z14 Z)*P /overlay legend; symbol1 v=none i=join; where P<.0001; Proc gplot; plot Z4*Z Z14*Z; Title "Quantile - Quantile Plot"; run; *** This part of the program generates the densities **; %let lamb = 4; %let d=.02; Data Chi; do Z = -4 to 4 by &d; fz = (1/sqrt(2*3.14159))*exp(-Z*Z/2); ** Area is this /0.05 **; x1 = (z-&d/2+sqrt(2*&lamb-1))**2/2; * (1); x2 = (z+&d/2+sqrt(2*&lamb-1))**2/2; * (2); if x1>x2 then Area=0; * Happens iff (1),(2) < 0 *; else Area = probchi(x2,&lamb)-probchi(x1,&lamb); fc = Area/&d; output; end; proc means; ** mean times 8 is area under curve over [-4,4]**; var fz fc; Title "Transformed Chi-square(&lamb) and N(0,1)"; proc gplot; plot fz*z fc*z/overlay legend; run;