I would like to import into TMB a user formula that is used as the prediction equation in a likelihood function. Is there any way of doing this? Could you point me to a relevant example? Any help would be greatly appreciated.
Thanks!!
For example in the simple linear regression code below, a+b*x is the predictor equation
#include <TMB.hpp>
template<class Type>
Type objective_function<Type>::operator() ()
{
DATA_VECTOR(Y);
DATA_VECTOR(x);
PARAMETER(a);
PARAMETER(b);
PARAMETER(logSigma);
ADREPORT(exp(2*logSigma));
Type nll = -sum(dnorm(Y, a+b*x, exp(logSigma), true));
return nll;
}
I would like to an user-specified formula to be used in place of a+b*x.