> nll += kterm + 0.5*square(deloy)*(deloy<=1.4) with a logical operator This looks to be non differentiable. ADMB has the posfun function to enable the user to approximate sharp cutoff points with smooth ones