Re: [R] problems with optimize (again)

From: Dimitris Rizopoulos <dimitris.rizopoulos_at_med.kuleuven.be>
Date: Thu 11 May 2006 - 02:31:13 EST

you should use:

optmz <- optimize(fitIT, interval = c(0.5, 4),

       ts_wave1 = test.data[, 1], ts_template = test.data[, 1])

calcFit(test.data[, 1], stretchWaveTime(test.data[, 1], optmz$minimum)

which should give the same as optmz$objective, i.e., the optmz$minimum is the value of 'ampFac' argument for which fitIT() attains its minimum value; the value of fitIT() at optmz$minimum is optmz$objective.

I hope it helps.

Best,
Dimitris



Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium

Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://www.med.kuleuven.be/biostat/
     http://www.student.kuleuven.be/~m0390867/dimitris.htm



> Can someone please explain what the $minimum result of the optimize
> function actually is?
>
> I'm trying to optimize the function:
> fitIT<-function(ampFac,ts_wave1,ts_template){
> template<-stretchWaveTime(ts_template,ampFac)
> fit<-calcFit(ts_wave1,template)
> return(fit)
> }
>
> with
>>optimize(f=fitIT,interval=c(0.5,4),ts_wave1=test.data[,1],ts_template=test.data[,1])
> $minimum
> [1] 3.764685
>
> $objective
> [1] 1.037864
>
> however when I run
>> calcFit(test.data[,1],stretchWaveTime(test.data[,1],1.037864))
> [1] 0.3059954

>
> I thought $minimum and the result of the calcFit function should be
> the

> same.
>
> As a further question I'm going to need to nest optimize functions
> so I
> can optimize over two variables. How can I get the minimum and

> objective
> back from the nested function f, as well as the value to be
> minimised?
>
> I hope this makes sense and I apologise for the lack of reproducible
> code. If it will help I can include that in a further e-mail.
> Thanks
> Tom
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>

Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu May 11 02:50:35 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 11 May 2006 - 04:10:04 EST.

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