Dears,
Any help?
Thanks,
LFRC
LFRC wrote:>
> Dears,
>
> I'm trying to find the parameters (a,b, ... l) that optimize the
function
> (Model)
> described below.
>
> 1) How can I set some constraints with MLE2 function? I want to set
p1>0,
> p2>0,
> p3>0, p1>p3.
>
> 2) The code is giving the following warning.
> Warning: optimization did not converge (code 1)
> How can I solve this problem?
>
> Can someone help me?
>
> M <- 14
> Y = c(0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1)
> x1 = c(0.50, 0.50, 0.50, 0.50, 0.50, 0.50, 0.50, 0.50, 0.50, 0.50, 0.25,
> 0.25, 0.25, 0.25)
> x2 = c(-1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
> x3 = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
> states = c(1, 1, 2, 3, 1, 2, 3, 1, 1, 2, 2, 3, 1, 1)
> prob_fn = rep(0,M)
>
> Model=function(a, b, c, d, e, f, g, h, i, j, k, l)
> {
> p1 = exp(-(a g*x1 d*x2 j*x3))
> p2 = exp(-(b h*x1 e*x2 k*x3))
> p3 = exp(-(c i*x1 f*x2 l*x3))
>
> ### Set P
> t5 = 0
> while(t5<M)
> {
> t5 = t5 1
>
> if(states[t5]==1) {prob_ok = p1[1]}
> if(states[t5]==2) {prob_ok = p2[1]}
> if(states[t5]==3) {prob_ok = p3[1]}
> prob_fn[t5] = c(prob_ok)
> }
>
> prob_fn[prob_fn==0] = 0.0000000000001
>
> ### LL
> ll_calc = -(sum(Y*log(prob_fn)))
> return(ll_calc)
> }
>
> res = mle2(Model, start=list(a=1, b=1, c=1, d=0.15, e=0.15,
> f=0.15, g=0.9, h=0.9, i=0.9, j=0.1, k=0.1, l=0.1), method = "Nelder-
> Mead")
> res
>
> Best regards,
> LFRC
>
>
--
View this message in context:
http://www.nabble.com/MLE-Constraints-tp19994553p20016631.html
Sent from the R help mailing list archive at Nabble.com.