Approximate distribution of the sum of binomial random variables in R

My goal is an approximate distribution of the sum of binomial variables. I use the following article Distribution of the sum of binomial random variables from Ken Butler and Michael Stevens.

I want to write an R script to find Pearson's approximation to the sum of the binomes. There is a PearsonDS R package that allows you to do this in a simple way.

So, I take the first example from the article and try to find the Pearson distribution density for this case. Finally, I get the error message "There are no probability distributions with these moments."

Could you explain to me what is wrong in the code below?

library(PearsonDS)

# define parameters for five binomial random variables

n<-rep(5,5)
p<-seq(0.02,0.10,0.02)

# find the first four cumulants

k.1<-sum(n*p)
k.2<-sum(n*p*(1-p))
k.3<-sum(n*p*(1-p)*(1-2*p))
k.4<-sum(n*p*(1-p)*(1-6*p*(1-p)))

# find asymmetry and kurtosis parameters

beta.1<-k.3^2/k.2^3
beta.2<-k.4/k.2^2

# determine the moments and calculate

moments <- c(mean=k.1,variance=k.2,skewness=sqrt(beta.1),kurtosis=beta.2)
dpearson(1:7,moments=moments)

I get the error message "There are no probability distributions with these moments."

+5
source share
1 answer

What you are trying to insert as an excess in your moments is actually an excessive excess that is simple kurtosis - 3. On the help page dpearson():

moments:
optional vector / list of mean, variance, asymmetry, excess (not excessive excess).

Thus, adding 3 to beta.2will provide you with a real excess:

beta.1 <- (k.3^2)/(k.2^3)
beta.2 <- k.4/(k.2^2)
kurt <- beta.2 + 3

moments <- c(mean = k.1, variance = k.2, skewness = beta.1, kurtosis = kurt)
dpearson(1:7, moments=moments)
# [1] 0.3438773545 0.2788412385 0.1295129534 0.0411140817 0.0099279576
# [6] 0.0019551512 0.0003294087

, , 0.5 , :

ppearson(1:7+0.5, moments = moments)
# [1] 0.5348017 0.8104394 0.9430092 0.9865434 0.9973715 0.9995578 0.9999339

:

, : : kurtosis >= (skewness)^2 - 1. , , , , .

+2

All Articles