ocmath_AIC
Description
Function to compute Akaike's Information Criterion (AIC)
Syntax
double ocmath_AIC( const int nSize, const int nParam, const double dSSE, int * iFault = NULL )
Parameters
- nSize
- [input] the number of data points
- nParam
- [input] the number of parameters fit by the regression.
- dSSE
- [input] the sum of square of residuals
- iFault
- [output] error code returned. is equal to STATS_NO_ERROR on successful exit
Return
Value of Akaike's Information Criterion
Examples
Before compile this example please run run.LoadOC(Originlab\stats_utils.c, 16); in Command Window to load all depentence source files.
#include <stats_utils.h>
void ocmath_AIC_ex1()
{
vector vX={3,4,4.5,5,5.5, 6};
vector vY={4,3,3.5,3, 4.2,5};
vector vW;
vW.SetSize(vX.GetSize());
vW = 1;
//parameters required by stats_polynomial_fit
LROptions sLROptions;
RegStats sRegStats;
RegANOVA sRegANOVA;
matrix mCov,mCorr;
FitParameter sFitParameter[3];
sLROptions.Confidence = 0.95;
int nOrder = 2;
int nParam;
nParam = (sLROptions.FixIntercept) ? nOrder : nOrder + 1;
int nRet = stats_polynomial_fit(vX,vY,vW,nOrder,sLROptions,sFitParameter,nParam,&sRegStats,&sRegANOVA,mCov,mCorr);
if (nRet != STATS_NO_ERROR)
return;
int ifault;
double dAIC = ocmath_AIC(vX.GetSize(), nParam, sRegStats.SSR, &ifault);//dAIC = 31.23
}
Remark
See Also
header to Include
stats_utils.h
Reference
|