template <class Type>
Type f(Type x){return Type(2)/(Type(1) + exp(-Type(2) * x)) - Type(1);}
template<class Type>
Type objective_function<Type>::operator() ()
{
int timeSteps=obs.dim[1];
Type rho=f(transf_rho);
Type ans=0;
ans -=
dnorm(u.col(0).vec(), Type(0), Type(1),
true).
sum();
for(int i=1; i<timeSteps; i++)
ans += neg_log_density(u.col(i)-u.col(i-1));
for(int i=1; i<timeSteps; i++)
ans -=
dnorm(obs.col(i).vec(), u.col(i).vec(), sdObs,
true).
sum();
return ans;
}
License: