The y-axis of geom_density is not a probability

The y-axis of geom_density is not a probability.
Do you know why?

library(tidymodels)

set.seed(2)

null_fits <- gss %>%
  specify(hours ~ age + college) %>%
  hypothesize(null = "independence") %>%
  generate(reps = 1000, type = "permute") %>%
  fit()


null_fits %>% 
  filter(term == "age") %>% 
  ggplot(aes(x=estimate))+
  geom_density()

image

thank you

The y-axis is the density so if you integrated the area under the entire curve, this will sum to 1. Since the numbers only go from about -0.2 to 0.2, the y value is larger than 1.

For example, a uniform distribution ranging from -0.2 to 0.2 will be at y=2.5 between those values and 0 elsewhere.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.