Sebastian Sauer

April 19, 2017

Reading time ~3 minutes

Let’s plot some skewed stuff, aehm, distributions!

Actually, the point I - initially - wanted to make is that in skewed distribution, don’t use means. Or at least, be very aware that (arithmetic) means can be grossly misleading. But for today, let’s focus on drawing skewed distributions.

Some packages:

library(tidyverse)library(fGarch)# for snorm

Some skewed distribution include:

“polluted” normal distributions, ie., mixtures of two normals

Exponential distributions

Gamma distributions

Beta distributions

One way to visualize them is to draw their curve, ie., their functional (analytical) form:

mypal<-df%>%gather(key=distribution,value=value)%>%ggplot+aes(x=value)+geom_histogram(aes(fill=distribution))+facet_wrap(~distribution)+scale_fill_manual(values=c("red","green","blue","orange"))+scale_color_manual(values=c("red","green","blue","orange"))+labs(title="Histogram of random draws from different distributions",subtitle="test")

Note that the domain of the beta distribution is [0,1], that’s why a narrow red bar pops out as histogram (the other distribution spread out much more explicitly). See:

df%>%gather(key=distribution,value=value)%>%dplyr::filter(distribution=="beta_distrib")%>%ggplot+aes(x=value)+geom_histogram(aes(fill=distribution))+#facet_wrap(~distribution) +scale_fill_manual(values=c("red","green","blue","orange"))+scale_color_manual(values=c("red","green","blue","orange"))+labs(title="Histogram of random draws from a Beta distribution")