Created
September 28, 2024 21:38
-
-
Save abikoushi/fd9b5976e92e4c8053106325d4d28157 to your computer and use it in GitHub Desktop.
Plot tweedie distribution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tweedie) | |
library(dplyr) | |
library(ggplot2) | |
library(ggh4x) | |
pow <- c(1.01,1.05,1.3,1.9) | |
phi <- c(0.2,0.5,1,3) | |
mu <- c(0.1,0.3,2) | |
dens <- expand.grid(y=y,power=pow,mu=mu,phi=phi) %>% | |
group_by(power) %>% | |
mutate(density = dtweedie(y=y, power = first(power), mu=mu, phi=phi)) %>% | |
ungroup() | |
ggplot(dens, aes(x=y, y=density))+ | |
geom_area(alpha=0.3,colour="black")+ | |
facet_grid2(mu+power~phi, labeller = label_both, scales = "free_y")+ | |
theme_classic(16)+theme(strip.text.y = element_text(angle = 0)) | |
ggsave("tweedie.png") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment