Assume that sampling from a Normal distribution with known variance, so will employ a z-test (not t-test).
mu0 <- 4 ## Null hypothesis mean value
stdev <- 3 ## Known population standard deviation
signif.level <- 0.05 ## Test significance level
sample.mean <- 6.07 ## Mean of the random sample
n <- 10 ## Sample size
mu1 <- 6.2 ## Alternative hypotesis mean value to use for error type 2
hyp.testing <- function(mu0, stdev, signif.level,
sample.mean, n, show_crit,
show_pvalue, show_alt, mu1,
show_beta, show_power, two_sided) {
}
I need a density plot showing the critical region in red stripes.
I tried using a polygon which is also known as error of type 1. Can we solve this using polygon?
hyp.testing(4,3,0.05,6.07,10) {
xval <- seq(-3.2, 3.2, length = 1000)
yval <- dnorm(xval)
plot(xval, yval, type = "l", axes = TRUE, frame = FALSE, lwd = 3,
xlab = "", ylab = "")
x <- seq(qnorm(.95), 3.2, length = 100)
polygon(c(x, rev(x)),c(dnorm(x), rep(0, length(x))), col = "salmon")
text(mean(x), mean(dnorm(x))+.02, "9%", cex = 1)
text(qnorm(.95), .01, "1.645", cex = 1) }
But, I am unable to get the desired output as follows:
The expected output is something like this:
output: