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 ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.