Bob,
I very strongly suggest that you do two things:
1. look at help("str"); then get in the habit of using
the str() function frequently.
2. peruse "An Introduction to R, especially Chapter 6
which would have solved your problem.
Regards,
-Peter Ehlers
robertag...@discover.com wrote:
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
robertag...@discover.com
Steve Lianoglou <mailinglist.honey...@gmail.com>
11/05/2009 04:56 PM
To
"<robertag...@discover.com>" <robertag...@discover.com>
cc
r-help@r-project.org
Subject
Re: [R] NLM OUTPUT
Hi Bob,
On Nov 5, 2009, at 3:04 PM, <robertag...@discover.com>
<robertag...@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]]
------------------------------------------------------------------------
______________________________________________
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.
______________________________________________
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.