Displaying 2 results from an estimated 2 matches for "resultsbfgs_d".
2007 Apr 20
1
Estimating a Normal Mixture Distribution
...,"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,s1,u2,s2),"gradient"))}
# finally, the optimization using the Broyden-Fletcher-Goldfarb-
Shanno method.
resultsBFGS_D=optim
(p0,mix.obj,mix.gr,x=waiting,method="BFGS",control=list(parscale=c
(0.1,rep(1,4))))
resultsBFGS_D$par
CODE END
The output is given as:
p u1 s1
u2 s2
0.361204 50.000000 5.000000 80.000000 5.000000
Unfortunately, th...
2009 Feb 12
1
Optim
...orm((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(x,p3,p2,p1),"gradient"))
}
### optim
(resultsBFGS_D=optim(pars,mix.obj,mix.gr,x=da,method="L-BFGS-B",lower=rep(0,3),upper=c(Inf,Inf,1),hessian=T)$par)
Also, sometimes it gives me the following error:
Error in optim(pars, mix.obj, mix.gr, x = da, method = "L-BFGS-B", lower =
rep(0, :
L-BFGS-B needs finite values of 'fn...