[R] Minimization problem

Bernardo Rangel Tura tura at centroin.com.br
Thu May 20 12:01:38 CEST 2010


On Thu, 2010-05-20 at 01:35 -0700, Fred wrote:
> Dear R users,
> 
> I am trying to minimize two function simultaneously in R,
> 
> function(x)
> 
> minimize x[1],x[2],x[3]
> 
> mean(distribution(x1,x2,x3) ) - observed mean
> 
> std(distribution(x1,x2,x3)) - observed std
> 
> What I want to achieve is that simulated mean and standard deviation
> of distribution related to x1 x2 x3  would be close to observed mean
> and observed standard deviation.
> 
> 
> is there any function in R can reach this?
> 
> Thank you for the help first .
> 
> F.

Hi!
Do you need use optim, something like this

test <- function(parameters){
m.error <- mean(distribution(x1,x2,x3) ) - observed mean
m.sd <- std(distribution(x1,x2,x3)) - observed std
res <- cbind(m.error,sd.error)
return(res)
}
-- 
Bernardo Rangel Tura, M.D,MPH,Ph.D
National Institute of Cardiology
Brazil



More information about the R-help mailing list