Hi everyone,
i need to obtain a distribution, for exmple under a gamma shape.
I already try to use rgamma(x,shape,rate), but when i see the result it is not what i want, i need somethings like in figure below, I drew this graph with paint, is only to give an idea
I think you're looking for the dgamma function. In the example below, I specify a shape and rate. I then find the 99.9th percentile to set as the maximum x value
library(tidyverse)
shape <- 5
rate <- 1/3
maxx <- qgamma(.999, shape=shape, rate=rate) #99.9th percentile as max x to plot
datgamma <-tibble(x=seq(0, maxx, by=.1)) %>%
mutate(y=dgamma(x, shape, rate=rate))
datgamma %>%
ggplot(aes(x=x, y=y)) +
geom_line()