#include "hmm_filter.hpp"
template<class Type>
struct sde_t{
  Type lambda, gamma, sigmaX;
  sde_t(Type lambda_, Type gamma_, Type sigmaX_){
    lambda = lambda_; gamma = gamma_; sigmaX = sigmaX_;
  }
  
  Type advection  (Type x){ return lambda * x - gamma * pow(x,3); }
  
  Type dispersion (Type x){ return sigmaX; }
};
template<class Type>
Type objective_function<Type>::operator() ()
{
  
  
  
  Type sigmaX=exp(logsX);
  Type sigmaY=exp(logsY);
  
  sde_t<Type> sde(lambda, gamma, sigmaX);
  
  fvade_t<sde_t, Type> fvol = fvade(sde, grid);
  
  hmm_filter<Type> hmm_nll(fvol, 
dt);
  hmm_nll.setGaussianError(sigmaY);
  Type ans = hmm_nll(yobs);
  return ans;
}
   
License: