draw.norm()
draw.norm(below=-1.5)
draw.norm(below=-1.5,justbelow=TRUE)
draw.norm(above=1.5, justabove=TRUE)
draw.norm(below=-1.5,above=1.5)
draw.norm(between=c(-4,0),color="black")
draw.norm(between=c(0,4),color="black")
draw.norm(between=c(-1,+1),color="darkgray")
title("P[-1 < z < 1] = 68%")
draw.norm(between=c(-2,+2),color="darkgray")
title("P[-2 < z < 2] = 95%")
draw.norm(between=c(-3,+3),color="darkgray")
title("P[-3 < z < 3] = 99.7%")
draw.norm(between = c(-1.75, 0, 2, 0.5, -1)) ## Plots between specified points
draw.norm(below=50,justbelow=TRUE,color="black",mu=47.3,sigma=9.3)
## Can plot one and then another on top of it using lines = TRUE
draw.norm(mu=2, sigma=10, outside=c(-3, 12), dens=15)
draw.norm(mu=2, sigma=15, between=c(-3, 12),lines=TRUE, col="blue",dens=15)
## Example: Plotting a Hypothesis Test for the mean
## Truth: mu.true = 8
## Hypothesis: mu.ho = 6
## Generate Data Under Truth
mu.true = 5 ## Alternative Mean
mu.ho = 6
sig = 8
N = 250 ## Sample Size
std.err = sig/sqrt(N)
crits = qnorm(c(0.025,0.975),mean=mu.ho, sd = std.err)
draw.norm(outside = crits, mu = mu.ho, sigma = std.err,dens=15)
draw.norm(between = crits, mu = mu.true, sigma = std.err, lines=TRUE, color="green",dens=15)
Run the code above in your browser using DataLab