TMB Documentation  v1.9.11
gamma.cpp
1 
2 #include <TMB.hpp>
3 template<class Type>
4 Type objective_function<Type>::operator() ()
5 {
6  DATA_VECTOR(Y);
7  PARAMETER(shape);
8  PARAMETER(scale);
9 
10  Type nll=-dgamma(Y,shape,scale,true).sum();
11  vector<Type> residuals = qnorm( pgamma(Y,shape,scale) );
12  REPORT(residuals);
13  return nll;
14 }
15 
Type qnorm(Type p, Type mean=0., Type sd=1.)
Quantile function of the normal distribution (following R argument convention).
#define DATA_VECTOR(name)
Get data vector from R and declare it as vector<Type>
Definition: tmb_core.hpp:236
Includes and sets all stuff needed to compile the user defined objective function.
#define REPORT(name)
Report scalar, vector or array back to R without derivative information.
Definition: tmb_core.hpp:313
Type dgamma(Type y, Type shape, Type scale, int give_log=0)
Density of X where X~gamma distributed.
Definition: lgamma.hpp:134
#define PARAMETER(name)
Get parameter scalar from R and declare it as Type.
Definition: tmb_core.hpp:227
Vector class used by TMB.
Definition: tmbutils.hpp:18
Type pgamma(Type q, Type shape, Type scale=1.)
Distribution function of the gamma distribution (following R argument convention).
License: GPL v2