Created
January 16, 2012 14:53
-
-
Save jcquiroz/1621215 to your computer and use it in GitHub Desktop.
likelihoodStats.cxx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <admodel.h> | |
//================================================================================= | |
// Likelihoods for abundance indices or catch | |
//================================================================================= | |
dvar_vector nlikelihood(dvector observed, dvar_vector expected, dvector cv, int LikeType) | |
{ | |
RETURN_ARRAYS_INCREMENT(); | |
dvar_vector logLike; | |
switch (LikeType) | |
{ | |
case 0: //not used | |
break; | |
case 1: //normal | |
logLike=elem_div(square(observed-expected), 2*square(elem_prod(cv,observed))); | |
break; | |
case 2: //lognormal | |
logLike=elem_div(square(log(observed)-log(expected)),2*square(cv)); | |
break; | |
default: | |
cout<<"No such likelihood: "<<LikeType<<" /n"; | |
break; | |
} | |
RETURN_ARRAYS_DECREMENT(); | |
return(logLike); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment