search for: lmix2a

Displaying 2 results from an estimated 2 matches for "lmix2a".

Did you mean: lmix2
2007 Apr 20
1
Estimating a Normal Mixture Distribution
...) # defining the objective function (=log-likelihood function). mix.obj<-function(p,x) { e<-p[1]*dnorm((x-p[2])/p[3])/p[3] + (1-p[1])*dnorm((x-p[4])/p[5])/p[5] if (any(e<=0)) Inf else -sum(log(e)) } # define two functions to calculate the first derivatives of the objective function. lmix2a<-deriv(~ -log(p*dnorm((x-u1)/s1)/s1 + (1-p)*dnorm((x-u2)/s2)/ s2), c("p","u1","s1","u2","s2"), function(x,p,u1,s1,u2,s2) NULL) mix.gr<-function(p,x){ p<-p[1] u1<-p[2] s1<-p[3] u2<-p[4] s2<-p[5] colSums(attr(lmix2a(x,p,u1...
2009 Feb 12
1
Optim
...ective function mix.obj = function(p,x) { e =p[3]*(pnorm((x+1/2-p[1])/sqrt(p[1]))-pnorm((x-1/2-p[1])/sqrt(p[1]))) + (1-p[3])*(pnorm((x-1/2-p[2])/sqrt(p[2]))-pnorm((x-3/2-p[2])/sqrt(p[2]))) if (any(e<=0)) Inf else -sum(log(e)) } ### Calculate the first derivatives of the objective function. lmix2a = deriv(~ -log(p3*pnorm((x+1/2-p1)/sqrt(p1))-pnorm((x-1/2-p1)/sqrt(p1)) + (1-p3)*pnorm((x-1/2-p2)/sqrt(p2))-pnorm((x-3/2-p2)/sqrt(p2))), c("p3","p2","p1"), function(x,p1,p2,p3) NULL) mix.gr = function(p,x) { p3 = p[3] p2 = p[2] p1 = p[1] colSums(attr(lmix2a(...