Optimization

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Optimization

Bogaso
Hi all, I need to minimize following function :

dat <- matrix(rnorm(20000), ncol=2)
      targetFn <- function(x) {
            dat <- as.matrix(dat)
            dat1 <- 1*dat[,1] - (x^2)*dat[,2]
            return(sd(dat1)) }

i.e. I want ro find for which "x" the value of "targetFn" will be minimum,
depending on current dataset "dat". Is there any optimization routine
available for this type of optimization?

Thanks and regards,

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Optimization

Berend Hasselman
Bogaso wrote
Hi all, I need to minimize following function :

dat <- matrix(rnorm(20000), ncol=2)
      targetFn <- function(x) {
            dat <- as.matrix(dat)
            dat1 <- 1*dat[,1] - (x^2)*dat[,2]
            return(sd(dat1)) }

i.e. I want ro find for which "x" the value of "targetFn" will be minimum,
depending on current dataset "dat". Is there any optimization routine
available for this type of optimization?
Try the help

??optimization

And some mathematics will show that in your particular case x=0 is the optimal value.

Berend
Reply | Threaded
Open this post in threaded view
|

Re: Optimization

Berend Hasselman
Berend Hasselman wrote
Bogaso wrote
Hi all, I need to minimize following function :

dat <- matrix(rnorm(20000), ncol=2)
      targetFn <- function(x) {
            dat <- as.matrix(dat)
            dat1 <- 1*dat[,1] - (x^2)*dat[,2]
            return(sd(dat1)) }

i.e. I want ro find for which "x" the value of "targetFn" will be minimum,
depending on current dataset "dat". Is there any optimization routine
available for this type of optimization?
...

And some mathematics will show that in your particular case x=0 is the optimal value.
Correction:

x=0 is one of the optimal values.
Whether the other alternative for x is feasible, depends on the sign of the crossproduct of dat[,1] and dat[,2]. If the rnorm() behaves as is to be expected that crossproduct will be close to zero.

Berend