Skip to content
Prev 367135 / 398506 Next

evaluating function over seq of values

The apply() family of functions **are** loops (at the interpreted
level). They are **not vectorized** (looping at the C level). Their
typical virtue is in code clarity and (sometimes) the utiity of the
return structure, not greater efficiency. Sometimes they are a bit
faster, sometimes a bit slower, than *well-written* explicit loops.

Note that in your likelihood function, N can be a vector of values, so
you can compute the likelihood for all values of N and just access the
value you want via subscripting rather than repeatedly computing it
for different N's.  If all you want to do is maximize over a grid of
values, I don't know why you need optim() at all -- but I probably
just don't get what you're doing.

Cheers,
Bert




Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
On Mon, Feb 13, 2017 at 8:41 AM, Evan Cooch <evan.cooch at gmail.com> wrote: