powered by
Useful for shading regions of interest (critical regions perhaps) on a theoretical pdf to illustrate concepts such as P-values.
shadeDens(x0, x1, dens, col = "lightgrey", n.points = 200, lty = 1,...)
A starting x-value for the region to be shaded
An ending x-value for the region to be shaded
A function that calculates the pdf
A color for the shaded region
The number of points to calculate the pdf at over the interval [x0,x1]
Line type
Additional arguments to be fed to dens such as degrees of freedom, mean or standard deviation
dens
Adds a filled polygon to an existing pdf plot.
# NOT RUN { x = seq(-4.5,4.5,by = 0.01) plot(x, dnorm(x), type = 'l') x0 = qnorm(0.975) x1 = 4.5 shadeDens(x0, x1, dnorm) # }
Run the code above in your browser using DataLab