[R] optim "a log-likelihood function"
Christian Schulz
ozric at web.de
Wed Sep 29 21:10:15 CEST 2004
many thanks , that x are my parameters is the help !
christian
>
> LL <- function(x, trans, time) {
> r <- x[1]
> alpha <- x[2]
> ...
> sum(l)
> }
>
> optim(c(1, 1), LL, control = list(fnscale = -1),
> trans = trans, time = time)
>
> Some style issues:
> 1. Break up lines that run too long, especially if you expect others to
> read your code.
> 2. You don't need an explicit "return" at the end of a function.
> 3. You should remove the "for" loop in LL and vectorise "l", which
> should be easy.
>
> Hope this is helpful,
>
> --sundar
>
> ______________________________________________
> R-help at 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
More information about the R-help
mailing list