This post may be wishful thinking, I wanted to ask here before I attempt to reinvent a wheel that may already be made.
I have been asked to report on thresholds on a distribution of spend data which is log normally distributed. I would like to plot the distribution and then annotate it with the Zscores along with the corresponding exponentiated actual values of the original, non log transformed distribution.
I did some image searching online and could not find anything showing exactly what I need, but I'll try with this image from wikicommons:
I can get the curve itself using ggplot::geom_density. Is there a pre built way to also overlay the Zscores and then, perhaps in a table underneath, the corresponding actual values of those Zscores based on the underlying distribution?
mtcars %>% ggplot(aes(x = log(mpg))) + geom_density()
s <- mtcars$mpg %>% log %>% summary s Min. 1st Qu. Median Mean 3rd Qu. Max. 2.342 2.736 2.955 2.958 3.127 3.523
With the above, I know that the mean corresponds to
s[['Mean']] %>% exp = 19.25006 so I would like a vertical line down the middle showing the value 19.2. That would correspond with a Zscore of 0 based on the first image I pasted above. But I would also like the corresponding values for the +- 1, 2 and 3 z-scores.
Is there a conventional way of annotating a distribution plot in this way? Is there a out of the box function, like
summary() that can show me the z-scores of a distribution and their corresponding values?
some_function_i_hope_exists(mtcars$mpg %>% log) # returns a table showing zscores and corresponding actual values