My goal is approximate the distribution of a sum of binomial variables. I use the following paper The Distribution of a Sum of Binomial Random Variables by Ken Butler and Michael Stephens.
I want to write an R script to find Pearson approximation to the sum of binomials. There is an R-package PearsonDS that allows do this in a simple way.
So I take the first example from the paper and try to find density of the Pearson distribution for this case. Finally i get an error message "There are no probability distributions with these moments".
Could you please explain me what's wrong in the below code?
library(PearsonDS)
# define parameters for five binomial random varibles
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 the skewness and kurtosis parameters
beta.1<-k.3^2/k.2^3
beta.2<-k.4/k.2^2
# define 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".