[R] optimize a joint lieklihood with mle2
Benedikt Gehr, Institut für Evolutionsbiologie und Umweltwissenschaften
benedikt.gehr at ieu.uzh.ch
Wed Mar 24 13:35:12 CET 2010
Hi
I'm trying to maximize a joint likelihood of 2 likelihoods (Likelihood 1 and
Likelihood 2) in mle2, where the parameters I estimate in Likelihood 2 go
into the likelihood 1. In Likelihood 1 I estimate the vector logN with
length 37, and for the Likelihood 2 I measure a vector s of length 8.
The values of s in Lieklihood 2 are used in the Likelihood 1.
I have 2 questions:
##1
I manage to write the joint lieklihood (it's very long which is why I don't
put it here), but I don't know how to write the correct argument for the
mle2 function. Here is what I've tried:
##################################
the lieklihood function to be optimized is called mfun(logN, s, h=h,
cohort=cohort). I want to maximize the vectors logN and s. I define the
starting values for logN as svec1 and for s as svec2
then I write for the optimization:
m1 = mle2(mfun,start=list(svec1=logN,svec2=s),
method="L-BFGS-B",lower=lower,upper=10,
vecpar=TRUE,
data=list(h=h,cohort=cohort))
but I get the error:
Error in mle2(mfun, start = list(svec1 = logN, svec2 = s), method =
"L-BFGS-B", :
some named arguments in 'start' are not arguments to the specified
log-likelihood function
How can I correctly write the fucntion for this?
#####################################################
##2
Besides I'm using constrained optim method L-BFGS-B. But I would only like
to use it for logN and not for s. Is that at all possible? I guess I could
use the same limits also for s because s falls in the range of logN values,
but how can I tell mle2 that I measure 2 likelihoods.
thanks so much for the help
Benedikt
More information about the R-help
mailing list