# Re: [R] MLE where loglikelihood function is a function of numerical solutions

From: Berend Hasselman <bhh_at_xs4all.nl>
Date: Wed, 13 Apr 2011 06:56:18 -0700 (PDT)

Questions:

Doing both those statements outside the loop once is more efficient.

Finally the likelihood function at the end of your code

#Maximum likelihood estimation using mle package
library(stats4)
#defining loglikelighood function
#T <- length(v)
#minuslogLik <- function(x,x2)
#{ f <- rep(NA, length(x))
# for(i in 1:T)
# {
# f[1] <- -1/T*sum(log(transdens(parameters = parameters, x =
c(v[i],v[i+1])))-log(Jac(outmat=outmat, x2=c(v[i],r[i])))
# }
# f
# }

How do the arguments of your function x and x2 influence the calculations in the likelihood function?
As written now with argument x and x2 not being used in the body of the function, there is nothing to optimize.
Shouldn't f[1] be f[i] because otherwise the question is why are looping for( i in 1:T)?
But then returning f as a vector seems wrong here. Shouldn't a likelihood function return a scalar?

Berend

```--
View this message in context: http://r.789695.n4.nabble.com/MLE-where-loglikelihood-function-is-a-function-of-numerical-solutions-tp3439436p3447224.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help