Skip to main content
Added link to previous similar question.
Source Link

This is an extension of an earlier question asked here. I have a data-set coming from a distribution given by:

$$Pr(X=k)=p \left({n\choose k}a^k(1-a)^{n-k}\right)+(1-p) \left({n\choose k}b^k(1-b)^{n-k}\right)$$

which is a mixture of two binomial distributions.

My aim is to estimate the parameter values, namely: n, p, a, b. To this I want to optimize the maximum likelihood function using "JDEoptim" package via R software.

fn<-function(x){
  #x(1)=p; x(2)=n; x(3)=a; x(4)=b;
  -prod(DensityFn(x, dataset[1:length(dataset)]))
}

DensityFn<-function(x, val){
  x[1]*dbinom(val, floor(x[2]), x[3])+(1-x[1])*dbinom(val, floor(x[2]), x[4])
}

lower=c(0, 11, 0, 0);
upper=c(0.5, 20, 1, 1);

print(JDEoptim(lower, upper, fn))

The variable "data-set" contains the values generated by this density function. The output upon running this program gives me:

$par [1]  0.07007818 11.85238114  0.86411002  0.64941201
 
$value [1] 0
 
$iter [1] 0
 
$convergence [1] 0

'iter' is 0 while 'convergence' is 0...indicating convergence has occured, however the parameter values outputted are far off from the actual values. Also, every time I run the program, the parameter estimates differ, but 'iter' and 'convergence' are always 0.

Is my code and logic correct?

I have a data-set coming from a distribution given by:

$$Pr(X=k)=p \left({n\choose k}a^k(1-a)^{n-k}\right)+(1-p) \left({n\choose k}b^k(1-b)^{n-k}\right)$$

which is a mixture of two binomial distributions.

My aim is to estimate the parameter values, namely: n, p, a, b. To this I want to optimize the maximum likelihood function using "JDEoptim" package via R software.

fn<-function(x){
  #x(1)=p; x(2)=n; x(3)=a; x(4)=b;
  -prod(DensityFn(x, dataset[1:length(dataset)]))
}

DensityFn<-function(x, val){
  x[1]*dbinom(val, floor(x[2]), x[3])+(1-x[1])*dbinom(val, floor(x[2]), x[4])
}

lower=c(0, 11, 0, 0);
upper=c(0.5, 20, 1, 1);

print(JDEoptim(lower, upper, fn))

The variable "data-set" contains the values generated by this density function. The output upon running this program gives me:

$par [1]  0.07007818 11.85238114  0.86411002  0.64941201
 
$value [1] 0
 
$iter [1] 0
 
$convergence [1] 0

'iter' is 0 while 'convergence' is 0...indicating convergence has occured, however the parameter values outputted are far off from the actual values. Also, every time I run the program, the parameter estimates differ, but 'iter' and 'convergence' are always 0.

Is my code and logic correct?

This is an extension of an earlier question asked here. I have a data-set coming from a distribution given by:

$$Pr(X=k)=p \left({n\choose k}a^k(1-a)^{n-k}\right)+(1-p) \left({n\choose k}b^k(1-b)^{n-k}\right)$$

which is a mixture of two binomial distributions.

My aim is to estimate the parameter values, namely: n, p, a, b. To this I want to optimize the maximum likelihood function using "JDEoptim" package via R software.

fn<-function(x){
  #x(1)=p; x(2)=n; x(3)=a; x(4)=b;
  -prod(DensityFn(x, dataset[1:length(dataset)]))
}

DensityFn<-function(x, val){
  x[1]*dbinom(val, floor(x[2]), x[3])+(1-x[1])*dbinom(val, floor(x[2]), x[4])
}

lower=c(0, 11, 0, 0);
upper=c(0.5, 20, 1, 1);

print(JDEoptim(lower, upper, fn))

The variable "data-set" contains the values generated by this density function. The output upon running this program gives me:

$par [1]  0.07007818 11.85238114  0.86411002  0.64941201
 
$value [1] 0
 
$iter [1] 0
 
$convergence [1] 0

'iter' is 0 while 'convergence' is 0...indicating convergence has occured, however the parameter values outputted are far off from the actual values. Also, every time I run the program, the parameter estimates differ, but 'iter' and 'convergence' are always 0.

Is my code and logic correct?

edited title
Link

Convergence Optimality of Maximum-Likelihood function for a mixture of two binomial distributions

Source Link

Convergence of Maximum-Likelihood function for a mixture of two binomial distributions

I have a data-set coming from a distribution given by:

$$Pr(X=k)=p \left({n\choose k}a^k(1-a)^{n-k}\right)+(1-p) \left({n\choose k}b^k(1-b)^{n-k}\right)$$

which is a mixture of two binomial distributions.

My aim is to estimate the parameter values, namely: n, p, a, b. To this I want to optimize the maximum likelihood function using "JDEoptim" package via R software.

fn<-function(x){
  #x(1)=p; x(2)=n; x(3)=a; x(4)=b;
  -prod(DensityFn(x, dataset[1:length(dataset)]))
}

DensityFn<-function(x, val){
  x[1]*dbinom(val, floor(x[2]), x[3])+(1-x[1])*dbinom(val, floor(x[2]), x[4])
}

lower=c(0, 11, 0, 0);
upper=c(0.5, 20, 1, 1);

print(JDEoptim(lower, upper, fn))

The variable "data-set" contains the values generated by this density function. The output upon running this program gives me:

$par [1]  0.07007818 11.85238114  0.86411002  0.64941201
 
$value [1] 0
 
$iter [1] 0
 
$convergence [1] 0

'iter' is 0 while 'convergence' is 0...indicating convergence has occured, however the parameter values outputted are far off from the actual values. Also, every time I run the program, the parameter estimates differ, but 'iter' and 'convergence' are always 0.

Is my code and logic correct?