[R] Memory leak in R v1.5.1? (how to use optim)

Huntsinger, Reid reid_huntsinger at merck.com
Tue Aug 6 18:56:33 CEST 2002


You need to have the variables over which you want to minimize
passed as a single argument (the first). Try

silly.fn <- function(params) ( (params[1] - 5)^2 + (params[2] - 2)^2 )

Reid Huntsinger

-----Original Message-----
From: Adaikalavan Ramasamy [mailto:ramasamy at stats.ox.ac.uk]
Sent: Tuesday, August 06, 2002 12:26 PM
To: R-help at stat.math.ethz.ch
Cc: stone at stats.ox.ac.uk
Subject: Re: [R] Memory leak in R v1.5.1?


Hi ! I am trying to minimise a function over 2 variables simultaneously. Is
this possible ? I have only recently been introduced to optim() and
optimise() function. Here is simple example of what I tried to do :

silly.fn <- function(x,y) { (x-5)^2 + (y-2)^2 }
optim( par=c(3,1) , silly.fn )

Analytically, the answer should be (5,2) but the computer is asking for the
y value. Is there a function to do the minimisation simultaneously in S-PLUS
or R ?

Many thanks, Adai.

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.
_._

------------------------------------------------------------------------------
Notice: This e-mail message, together with any attachments, contains information of Merck & Co., Inc. (Whitehouse Station, New Jersey, USA) that may be confidential, proprietary copyrighted and/or legally privileged, and is intended solely for the use of the individual or entity named on this message. If you are not the intended recipient, and have received this message in error, please immediately return this by e-mail and then delete it.

==============================================================================

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list