Thanks, Steve.  I believe that's all I needed.  I couldn't find that 
r$estimate syntax anywhere in the manual.  I'm new to R, having used SAS 
exclusively in the past.  I was able to run the optimizing functions nlm 
and optim successfully, but I couldn't figure out how to access the 
estimates.  I tried another function constroptim rather unsuccessfully; it 
ran but did very little so I took a different approach.

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@discover.com
                                                                                                                        




Steve Lianoglou <mailinglist.honeypot@gmail.com> 
11/05/2009 04:56 PM

To
"<robertagnew@discover.com>" <robertagnew@discover.com>
cc
r-help@r-project.org
Subject
Re: [R] NLM OUTPUT






Hi Bob,

On Nov 5, 2009, at 3:04 PM, <robertagnew@discover.com> 
<robertagnew@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.

	[[alternative HTML version deleted]]

