[R] Error using a data frame as the "start" parameter in mle()

From: Coryn Bailer-Jones <calj_at_mpia-hd.mpg.de>
Date: Fri 30 Sep 2005 - 01:24:52 EST


Dear R-Users,

I am trying to use mle() to optimize two (or more) parameters, but I want to specify those parmeters in a data frame rather than having to spell them out separately in the "start" variable of mle().

My call is

> mle(negll, start=list(aps=init), fixed=list(measphot=newphot,

    formod=formod, Nbands=Nbands), method="BFGS")

where negll is a function I have written which uses the function predict.loess(). negll works fine when called directly. The parameter I am trying to optimize, "aps", is a data frame containing two parameters, e.g.

> init

  teff logg
1 8000 4.5

When I run mle I get the following error message

Error in predict.loess(formod[[band]], aps) :

        Argument "aps" is missing, with no default

As negll does work fine, I presume I am incorrectly passing "aps" into mle(). Note that mle() works fine if I rewrite negll to work on a scalar "aps" and then I use start=list(aps=500), for example. Can anyone help me with this?

Incidentally, I am only using a data frame for "aps" because I am using loess(), and this seems to require a formula with named variables in a data frame (here "logg" and "teff"). I can't get it work with arrays:

> temp <- loess(formula = photd[, band] ~ gridaps[, 1] * gridaps[, 2])
> predict(temp, c(4,8000))

Error in predict.loess(temp, c(4, 8000)) :

        newdata does not contain the variables needed

Thanks in advance for any clues.

Coryn.


Coryn Bailer-Jones                    calj@mpia-hd.mpg.de
Max-Planck-Institut fuer Astronomie   http://www.mpia-hd.mpg.de/homes/calj/
Koenigstuhl 17                        tel: +49 6221 528-224        (direct)
D-69117 Heidelberg                         +49 6221 528-0       (reception)
Germany                               fax: +49 6221 528-246

______________________________________________
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 Fri Sep 30 01:28:15 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:40:29 EST