The reason you are having trouble with using an *apply function is
that f_like does
not have an argument 'N', so the N it uses is the N from the
environment in which
f_like was defined, .GlobalEnv, not one you might set in *apply's FUN argument.
Hence, make N an argument to f_like and use it in *ap
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.
OK -- that is the part I'm stuck at - pointers to how to do preci
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
The MWE (below) shows what I'm hoping to get some help with:
step 1\ specify the likelihood expression I want to evaluate using a
brute-force grid search (not that I would do this in practice, but it is
a convenient approach to explain the idea in a class...).
step 2\ want to evaluate the lik
4 matches
Mail list logo