Re: [R] Simple optim - question

From: Dieter Menne <dieter.menne_at_menne-biomed.de>
Date: Thu 09 Feb 2006 - 19:17:38 EST

Carsten Steinhoff <carsten.steinhoff <at> gmx.de> writes:

> 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))
> }
> -----------------
>
....

Try optim or nlminb, both can be used with constraints. Or, as your example looks like a least-square problem, reformulate optim and use nls.

Dieter



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri Feb 10 15:36:54 2006

This archive was generated by hypermail 2.1.8 : Mon 13 Feb 2006 - 22:28:23 EST