template <class Type>
Type objective_function<Type>::operator()()
{
Type nll = -
dnorm(x(0), Type(0), huge,
true);
for (int i = 1; i < x.size(); ++i)
nll -=
dnorm(x(i), x(i - 1) + mu, exp(logsigma),
true);
for (int i = 0; i < y.size(); ++i)
nll -= keep(i) *
dnorm(y(i), x(i), exp(logs),
true);
return nll;
}
License: