| |
| library(ggplot2) |
|
|
| |
| mesokurtic <- function(x) { |
| dnorm(x, mean = 0, sd = 1) |
| } |
|
|
| leptokurtic <- function(x) { |
| dnorm(x, mean = 0, sd = 0.8) * 1.3 |
| } |
|
|
| platykurtic <- function(x) { |
| dnorm(x, mean = 0, sd = 1.6) * 0.85 |
| } |
|
|
| |
| x <- seq(-4, 4, length.out = 200) |
|
|
| |
| plot_data <- data.frame( |
| x = rep(x, 3), |
| y = c( |
| leptokurtic(x), |
| mesokurtic(x), |
| platykurtic(x) |
| ), |
| Distribution = factor( |
| rep( |
| c( |
| "Leptokurtic", |
| "Mesokurtic", |
| "Platykurtic" |
| ), |
| each = length(x) |
| ), |
| levels = c( |
| "Leptokurtic", |
| "Mesokurtic", |
| "Platykurtic" |
| ) |
| ) |
| ) |
|
|
| |
| plt <- ggplot() + |
| |
| geom_line( |
| data = plot_data, |
| aes(x = x, y = y, color = Distribution), |
| size = 1 |
| ) + |
| |
| |
| scale_color_manual(values = c( |
| "Leptokurtic" = "#007bff", |
| "Mesokurtic" = "#28a745", |
| "Platykurtic" = "#e83e8c" |
| )) + |
| |
| labs( |
| x = "X", |
| y = "Probability density", |
| color = NULL |
| ) + |
| theme_minimal() + |
| theme( |
| axis.title.y = element_text(angle = 90), |
| legend.position = "bottom", |
| legend.text = element_text(size = 12), |
| ) + |
| |
| coord_cartesian(xlim = c(-3.5, 3.5), ylim = c(0, 0.65)) |
|
|
| ggsave( |
| "pdfs/kurtosis.pdf", |
| plot = plt, |
| create.dir = TRUE, |
| height = 4, |
| width = 5 |
| ) |
|
|