I've seen quicker ways to do it, but I've been using ggplot2 for this. See examples below.
On Tue, Jun 23, 2009 at 7:57 PM, AbouEl-Makarim Aboueissa<[email protected]> wrote: > Dear All: > > I need some help with graphing the critical regions of hypothesis testing. > > Consider the Z-test, assume Z=3.2, and alpha=0.05 (that is Z_(a.pha/2)=1.96. > > Then how to graph the rejection region in the following three cases: > > Left-tailed test library(ggplot2) z <- seq(-4,4, by = .01) Density <- dnorm(z) criteria <- factor(rep("retain", length(z)), levels=c("retain", "reject")) criteria[which(z < qnorm(.05))] <- "reject" qplot(z,Density, geom=c("path","area"), fill=criteria) + scale_fill_manual(values=c("grey40", "red")) > > > Right-tailed test > Same as above except do criteria[which(z > qnorm(.95))] <- "reject" > > Two tailed test > Sorry, haven't figured this one out yet. > > > Same for the T-test. t <- seq(-4,4, by = .01) Density <- dt(t,df=20) criteria <- factor(rep("retain", length(t)), levels=c("retain", "reject")) criteria[which(t > qt(.95,df=20))] <- "reject" qplot(t,Density, geom=c("path","area"), fill=criteria) + scale_fill_manual(values=c("grey40", "red")) Hope it helps, Ista > > > Thank you so much for your times. > > Abou > > > > > ========================== > AbouEl-Makarim Aboueissa, Ph.D. > Assistant Professor of Statistics > Department of Mathematics & Statistics > University of Southern Maine > 96 Falmouth Street > P.O. Box 9300 > Portland, ME 04104-9300 > > Tel: (207) 228-8389 > Email: [email protected] > [email protected] > Office: 301C Payson Smith > > [[alternative HTML version deleted]] > > _______________________________________________ > [email protected] mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-teaching > _______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-teaching
