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."
source
share