Re: [R] Optimzing a nested function

From: Ravishankar Rajagopalan <vioravis_at_gmail.com>
Date: Tue, 12 Apr 2011 15:36:59 +0530

Thanks Duncan and Mario. It works fine now.

On Tue, Apr 12, 2011 at 3:11 PM, Duncan Murdoch <murdoch.duncan_at_gmail.com>wrote:

> On 11-04-12 2:33 AM, vioravis wrote:
>
>> I am trying to optimize a nested function using nlminb. This throws out an
>> error that y is missing. Can someone help me with the correct syntax??
>> Thank
>> you.
>>
>
> See ?nlminb. The parameters to optimize should be given as a vector in a
> single parameter. Other parameters are kept fixed through the optimization,
> and need to be passed in the nlminb call.
>
> Duncan Murdoch
>
>
>> test1<- function(x,y)
>> {
>> sum<- x + y
>> return(sum)
>> }
>>
>> test2<- function(x,y)
>> {
>> sum<- test1(x,y)
>> sumSq<- sum*sum
>> return(sumSq)
>> }
>>
>> nlminb(start = c(1,1), test2,lower = c(0,0), upper = c(5,5))
>>
>>
>>
>> --
>> View this message in context:
>> http://r.789695.n4.nabble.com/Optimzing-a-nested-function-tp3443825p3443825.html
>> Sent from the R help mailing list archive at Nabble.com.
>>
>> ______________________________________________
>> R-help_at_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<http://www.r-project.org/posting-guide.html>
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>

        [[alternative HTML version deleted]]



R-help_at_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. Received on Tue 12 Apr 2011 - 10:15:31 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 12 Apr 2011 - 10:30:29 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive