R - “ missing value where TRUE/FALSE needed ” -


i'm trying execute following code in r

library(nloptr)  m = 0.00060981 m2 = 0.000109362 m4 = 5.21538e-08 m6 = 4.25e-11 f=function(x){     y = matrix(na, ncol = 1, nrow = 4)   mu = x[1]   s2=x[2]   s2u = x[3]   lambda= x[4]   y[1] = (mu-(s2/2))-m   y[2] = (s2+(lambda*s2u))-m2   y[3] = ((3*(s2^2) + 6*(lambda^2)*(s2u^2)+3*(s2u^2)*(lambda) + 6*(lambda)*(s2u)*s2))-m4   y[4] = (15*(s2^3) +45*(s2^2)*s2u + 45*(lambda^2)*(s2u^2)*s2 +45*(lambda)*(s2u^2)*s2 +15*(lambda^3)*(s2u^3)+45*(lambda^2)*(s2u^3)+15*lambda*(s2u^3))-m6   return(y)  } g = function(x){   return(norm(f(x),'f')) } initiale=c( 0.00197,0.022,0.0036,0.8999) hin = function(x){ h=rep(na,1) h[2]>0 h[3]>0 h[1]<h[2]  h } ans=auglag(par=initiale,fn=g,hin=hin) 

but i'm getting error :

error in if (sig > 1e+05) control.optim$reltol <- 1e-10 :    missing value true/false needed 

why getting error, , how fix code?

i suspect error message result of h function

hin = function(x){        h=rep(na,1)        h[2]>0        h[3]>0        h[1]<h[2]        h  } 

the value of h always na , never changes.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -