I want to approximate a known distribution with another distribution. For example, suppose the known distribution is a negative binomial distribution whose mean and size parameters are 10 and 3 respectively (i.e., dnbinom(x,mu=10,size=3)
in R). Suppose I want to approximate this distribution by a mixture of two poisson distributions, i.e., p*dpois(x,lambda1)+(1-p)*dpois(x,lambda2)
. I want to know the parameters of the mixture distribution: p
, lambda1
, lambda2
. If I simulate data, I can estimate the parameters:
n <- 10000
y <- rnbinom(n,mu=10,size=3)
dmixpois <- function(y,lambda1,lambda2,pmix){
pmix*dpois(y,lambda1)+(1-pmix)*dpois(y,lambda2)
}
loglik <- function(p,y){
lambda1 <- p[1]
lambda2 <- p[2]
pmix <- p[3]
-sum(log(dmixpois(y,lambda1,lambda2,pmix))) # not nice
}
model <- optim(c(11,9,0.5),loglik,y=y,method="L",lower=c(0,0,0),upper=c(NA,NA,1))
model$par
I think by increasing the sample size n
, the estimates become better. My question is that is there better way to do this? Because the target distribution is known, is there a way to do this without simulating data, for example?
In this question, I do not care if the approximation is good or not, but I want to find the best parameters (i.e., I think what I mean by best is to maximize the likelihood like in the example) for a given candidate distribution. Also I used a specific example (negative binomial and mixture poisson), but my question is not specific to these distributions. So a solution that works only for these distributions would not work.
UPDATE
For example, it may be silly, but minimizing the sum of squares was an idea, but the results are very different from MLEs.
ssq <- function(p){
lambda1 <- p[1]
lambda2 <- p[2]
pmix <- p[3]
x <- 0:10000 # large enough
sum((dnbinom(x,mu=10,size=3)-dmixpois(x,lambda1,lambda2,pmix))^2)
}
optim(c(11,9,0.5),ssq,method="L",lower=c(0,0,0),upper=c(NA,NA,1))