template<class Type>
Type objective_function<Type>::operator() ()
{
Type g=0;
vector<Type> sigma=exp(log_sigma);
vector<Type> sigma_init=sigma/sqrt(Type(1.0)-phi*phi);
for(
int j=0;j<p;j++)g += SCALE(AR1(phi(j)),sigma_init(j))(ht.
col(j));
for(int i=0;i<n;i++)
{
vector<Type> sigma_y = exp( Type(0.5) * (mu_x + h.col(i).vec() ));
g +=
VECSCALE(neg_log_density,sigma_y)( y.col(i).vec() );
}
return g;
}
License: