2.1.11.11 ocmath_calc_conf_and_pred_bands_for_polynomial


Description

Calculate ranges of confidence or prediction in polynomial fitting

Syntax

int ocmath_calc_conf_and_pred_bands_for_polynomial( const double * pX, const double * pY, int nSize, const double * pdCovMat, const LROptions * psLROptions, int nOrder, double dBoundPerc, double dChiSq, double dtValue, double * pdLower, double * pdUpper, BOOL bConf = TRUE )

Parameters

pX
[input] pointer to x coordinates of the data
pY
[input] pointer to y coordinates of the data
nSize
[input] size of the data
pdCovMat
[input] pointer to confidence matrix
psLROptions
[input] struct containing fitting options
nOrder
[input] order of polynomial fitting
dBoundPerc
[input] preserved for future
dChiSq
[input] chi square value
dtValue
[input] t test value
pdLower
[output] pointer to a buffer sized nSize to store lower boundaries
pdUpper
[output] pointer to a buffer sized nSize to store upper boundaries
bConf
[input] switch to calculate confidence or prediction

Return

Return OE_NOERROR if succeed, otherwise, non-zero error code is returned.

Examples

EX1

void ocmath_calc_conf_and_pred_bands_for_polynomial_ex1()
{
    int nOrder,nRet;    
    LROptions sLROptions;    
    RegStats sRegStats;    
    vector vX_2 = { 0.1, 2.3, 3.1, 4.2 };
    vector vY_2 = { 2.6, 2.8, 4.5, 3.7 };
    sLROptions.Confidence = 0.95;    
    nOrder = 2;        
    FitParameter sFitParameter_2[3];              
    matrix mCov(3, 3);
    int nSize = vX_2.GetSize();
    nRet = ocmath_polynomial_fit(nSize, vX_2, vY_2, NULL, nOrder, &sLROptions, sFitParameter_2, 3, &sRegStats, NULL, mCov, NULL);

    double dBoundPerc = 0.95;
    double dof = sRegStats.DOF;
    double dChiSq = sRegStats.ReducedChiSq;
    double tvalue = tTable(1 - (1.0 - dBoundPerc) / 2, dof);
    vector vLower(nSize);
    vector vUpper(nSize);
    ocmath_calc_conf_and_pred_bands_for_polynomial(vX_2, vY_2, nSize, mCov, &sLROptions, nOrder, dBoundPerc, dChiSq, tvalue, vLower, vUpper);
}

Remark

See Also

Header to Include

origin.h

Reference