[R] How to write the log function in R
Ben Bolker
bolker at ufl.edu
Wed Sep 3 00:08:39 CEST 2008
toh <tohbin <at> yahoo.com> writes:
>
>
> Hi,
>
> I need help to write the following log-likelihood function in R:
> log(L) = sum [(y_k - y_k-1).log(m(t_k) - m(t_k-1)) - (m(t_k) - m(t_k-1)) -
> log((y_k -y_k-1)!)]
>
> I need to write this log-likelihood function in order to find the parameters
> by MLE method.
>
if you have a vector y_k then diff(y_k) should give you a vector
corresponding to (y_k - y_k-1) [I assume you mean y_{k-1} rather
than {y_k}-1 above!]
log(x!) is lfactorial(x) in R
sum() works as expected
the rest should be pretty easy ...
Ben Bolker
More information about the R-help
mailing list