[R] Optimzing a nested function

Mario Valle mvalle at cscs.ch
Tue Apr 12 09:07:31 CEST 2011


P.S.: It is bad taste to call a variable 'sum' because it is a R function.

Ciao!
                     mario

On 12-Apr-11 08:33, 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.
>
> 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
> and provide commented, minimal, self-contained, reproducible code.

-- 
Ing. Mario Valle
Data Analysis and Visualization Group            | 
http://www.cscs.ch/~mvalle
Swiss National Supercomputing Centre (CSCS)      | Tel:  +41 (91) 610.82.60
v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax:  +41 (91) 610.82.82



More information about the R-help mailing list