Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library(tidyverse)
- library(latex2exp)
- library(patchwork)
- library(animation)
- (
- ggplot(data.frame(x = 0:30), aes(x = x)) +
- stat_function(
- fun = dnorm,
- args = list(mean = 30, sd = 4),
- geom = "density",
- size = 1,
- fill = "gray20",
- alpha = 0.5,
- linetype = 0
- ) +
- stat_function(
- fun = dnorm,
- args = list(mean = 20, sd = 4),
- geom = "density",
- size = 1,
- xlim = c(0, 30 + 4 * qnorm(0.05 / 2)),
- fill = "darkred",
- linetype = 0
- ) +
- stat_function(
- fun = dnorm,
- args = list(mean = 30, sd = 4),
- geom = "density",
- size = 1,
- xlim = c(0, 30 + 4 * qnorm(0.05 / 2)),
- fill = "steelblue",
- linetype = 0
- ) +
- stat_function(
- fun = dnorm,
- args = list(mean = 30, sd = 4),
- geom = "density",
- size = 1,
- xlim = c(0, 30 + 4 * qnorm(0.0176 / 2)),
- fill = "deeppink",
- linetype = 0
- ) +
- # stat_function(fun = dnorm, args = list(mean = 30, sd = 4), geom = "col", width = 0.08, xlim = c(0, 30 + 4* qnorm(0.0176/2)), fill = "deeppink", linetype = 2) +
- stat_function(
- fun = dnorm,
- args = list(mean = 30, sd = 4),
- geom = "density",
- size = 1,
- xlim = c(30 - 4 * qnorm(0.05 / 2), 60),
- fill = "steelblue",
- linetype = 0
- ) +
- stat_function(
- fun = dnorm,
- args = list(mean = 30, sd = 4),
- geom = "density",
- size = 1,
- xlim = c(30 - 4 * qnorm(0.0176 / 2), 60),
- fill = "deeppink",
- linetype = 0
- ) +
- # stat_function(fun = dnorm, args = list(mean = 30, sd = 4), geom = "col",width = 0.08, xlim = c( 30 - 4* qnorm(0.0176/2),60), fill = "deeppink", linetype =\ 2) +
- stat_function(
- fun = dnorm,
- args = list(mean = 20, sd = 4),
- geom = "density",
- size = 1,
- linetype = 0
- ) +
- stat_function(
- fun = dnorm,
- args = list(mean = 20, sd = 4),
- geom = "density",
- size = 1,
- xlim = c(30 + 4 * qnorm(0.05 / 2), 60),
- fill = "orange",
- linetype = 0
- ) +
- annotate(
- "text",
- 25,
- 0.02,
- label = parse(text = TeX("$\\beta$")),
- size = 13,
- col = "white"
- ) +
- annotate(
- "text",
- 17,
- 0.02,
- label = parse(text = TeX("$1-\\beta$")),
- size = 13,
- col = "white"
- ) +
- annotate(
- "text",
- 21.5,
- 0.005,
- label = parse(text = TeX("$\\frac{\\alpha}{2}$")),
- size = 8,
- col = "white"
- ) +
- annotate(
- "text",
- 38.5,
- 0.005,
- label = parse(text = TeX("$\\frac{\\alpha}{2}$")),
- size = 8,
- col = "white"
- ) +
- geom_segment(
- aes(
- x = 21,
- y = 0.1,
- xend = 29,
- yend = 0.1
- ),
- arrow = arrow(length = unit(0.01, "npc")),
- size = 1
- ) +
- geom_segment(
- aes(
- xend = 21,
- yend = 0.1,
- x = 29,
- y = 0.1
- ),
- arrow = arrow(length = unit(0.01, "npc")),
- size = 1
- ) +
- theme_void()
- ) %>%
- ggsave("frequentialhypothesistesting.png",., width = 16, height = 9)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement