[R] Simple optim - question

From: Carsten Steinhoff <carsten.steinhoff_at_gmx.de>
Date: Thu 09 Feb 2006 - 08:50:12 EST

Hello,

I want to find the parameters mu and sigma that minimize the following function.
It's important, that mu and sigma are strictly positive.

optimiere = function(fmean,smean,d,x,mu,sigma) {
merk = c()
for (i in 1:length(d))
merk=c(merk,1/(d[i]^2)*(d[i]-1/(fmean*(1-plnorm(x[i],mu,sigma))))^2) return(sum(merk))
}

To do that I'm using the nlm function, but I only get results for ONE of the two parameters.
I cannot cope with optimizing the two parameter problem simultaneously. I've started with:

nlm(optimiere,p=5,fmean=10,smean=10000,d=c(40,10),x=c(500000,50000),sigma=3. 5)

Then I tried to combine mu and sigma in one Vector. I get back two parameters but the results are unreasonable since mu and sigma are -0.3247726 and 4.7905308 but have to be strictly positive.

I've given up after hours and hope to get your help.. I'm sure the problem should be easily solved by one of the experts.

R-help@stat.math.ethz.ch mailing list