[R] NLM OUTPUT

robertagnew at discover.com robertagnew at discover.com
Fri Nov 6 01:15:27 CET 2009


I would appreciate your insights on the attached session.

Bob




Robert Agnew | Discover
Director Acquisition Analytics
Marketing – Analysis & Pricing
2500 Lake Cook Road
Riverwoods, IL 60015
Tel 224-405-1425 Fax 224-405-4971
robertagnew at discover.com
                                                                                                                        




Steve Lianoglou <mailinglist.honeypot at gmail.com> 
11/05/2009 04:56 PM

To
"<robertagnew at discover.com>" <robertagnew at discover.com>
cc
r-help at r-project.org
Subject
Re: [R] NLM OUTPUT






Hi Bob,

On Nov 5, 2009, at 3:04 PM, <robertagnew at discover.com> 
<robertagnew at discover.com 
 > wrote:

> I am missing something fundamental.  I ran the function nlm, but I 
> don't
> understand how to extract the optimal solution as a numeric vector. 
> The
> function produces it as one element of a list.  I don't see anything 
> in
> the R documentation about converting such a list element to the 
> vector it
> displays.

Are you just asking how to pull out the appropriate parts of the 
returned value from the nlm function call?

Taking code from the Example section of ?nlm, run this:

R> f <- function(x, a) sum((x-a)^2)
R> r <- nlm(f, c(10,10), a=c(3,5))

Now look at "r"
R> r
$minimum
[1] 3.371781e-25

$estimate
[1] 3 5

$gradient
[1]  6.750156e-13 -9.450218e-13

$code
[1] 1

$iterations
[1] 2

To get the minimum, or estimate you just access it like:
R> r$minimum
[1] 3.371781e-25

R> r$estimate
[1] 3 5

Is this what you're asking?

-steve

ps:
r[['minimum']] and r[['estimate']] would also work, as would r[[1]] 
and r[[2]]

--
Steve Lianoglou
Graduate Student: Computational Systems Biology
   |  Memorial Sloan-Kettering Cancer Center
   |  Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact





Please consider the environment before printing this email.


More information about the R-help mailing list