garciap <garciap <at> usal.es> writes:
> this is my first time, and just begin to use R. But I've a question
about
> optimization using optimx library. It could sound stupid by I'm a bit
> affraid with the problem, because anything I try, anything Error.
> The procedure was:
> optimx(par="10,71,1",fn=(Prey*Provisioning)/Risk,
control=list("maximize))
>
> well the problem lies in the initial value parameters, again and again, R
> tells me that it is not possible to optimize the function at this values,
> even though these are real estimations.
>
I'm afraid there are quite a few things wrong with your approach.
* parameters need to be a **numeric vector** (e.g. c(10,71,1)) rather
than characters
* you haven't defined a function that takes the vector of parameters
as an argument and returns a goodness-of-fit measure or other objective
function value. This is the biggest problem
(the rest are just basic misunderstandings of R syntax, easily corrected).
* if you want the function to maximize you need control=list(maximize=TRUE).
* I think you have not given us exactly the command you entered. If I enter
what you have typed above, the unmatched quotation mark before
'maximize'
means that R doesn't even accept my command: it gives me a 'continuation
character' (+) telling me that it is waiting for further input. It's
very
important to specify *exactly* the commands you typed; cutting and pasting
from the R session (or better, keeping a script file and copying from there)
is a good way to ensure this.
I would suggest that you work carefully through the examples
in the optimx help page, making sure that you understand them
(or if you get totally stuck there, you can post to the help list
with a *specific* question about what you haven't understood).
I might also recommend that you try starting with the optim()
help page, which is a little bit simpler than the optimx() page.
optimx has better optimization routines, but for getting a basic
understanding of how R does optimization optim() should suffice.
Don't forget to read the posting guide before you come back with
more questions.
good luck,
Ben Bolker