From: Tony Plate <tplate_at_acm.org>

Date: Tue 01 Aug 2006 - 05:05:15 EST

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 and provide commented, minimal, self-contained, reproducible code. Received on Tue Aug 01 05:14:24 2006

Date: Tue 01 Aug 2006 - 05:05:15 EST

I added an example of passing additional arguments through optim() to
the objective and gradient functions to the Discussion section of the
Wiki-fied R documentation. See it at

http://wiki.r-project.org/rwiki/doku.php?id=rdoc:stats:optim

- Tony Plate

PS. I had to add "&purge=true" to the end of the URL, i.e., http://wiki.r-project.org/rwiki/doku.php?id=rdoc:stats:optim&purge=true in order to see the original documentation the first time -- it's something to do with bad cache entries for the page.

Michael Papenfus wrote:

> I think I need to clarify a little further on my original question.

*>
**> I have the following two rows of data:
**> mydat<-data.frame(d1=c(3,5),d2=c(6,10),p1=c(.55,.05),p2=c(.85,.35))
**> >mydat
**> d1 d2 p1 p2
**> 1 3 6 0.55 0.85
**> 2 5 10 0.05 0.35
**>
**> I need to optimize the following function using optim for each row in mydat
**> fr<-function(x) {
**> u<-x[1]
**> v<-x[2]
**> sqrt(sum((plnorm(c(d1,d2,u,v)-c(p1,p2))^2))
**> }
**> x0<-c(1,1) # starting values for two unknown parameters
**> y<-optim(x0,fr)
**>
**> In my defined function fr, (d1 d2 p1 p2) are known values which I need
**> to read in from my dataframe and u & v are the TWO unknown parameters.
**> I want to solve this equation for each row of my dataframe.
**>
**> I can get this to work when I manually plug in the known values (d1 d2
**> p1 p2). However, I would like to apply this to each row in my dataframe
**> where the known values are automatically passed to my function which
**> then is sent to optim which solves for the two unknown parameters for
**> each row in the dataframe.
**>
**> thanks again,
**> mike
**>
*

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 and provide commented, minimal, self-contained, reproducible code. Received on Tue Aug 01 05:14:24 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 Tue 01 Aug 2006 - 06:16:40 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.
*