Examples - pi.science.regression.PIGompertzRegression
1. How to compute Gompertz regression for X and Y values
(with PARTIAL_SUMS method) ?
/* - prepare X data for regression */
PIVariable X = new PIVariable();
X.AddMoreValuesRange( 1, 29 );
/* - prepare Y data for regression */
PIVariable Y = new PIVariable();
Y.addValues( new int[] { 3, 5, 7, 9, 14 } );
Y.addValues( new int[] { 17, 21, 27, 36, 40 } );
Y.addValues( new int[] { 47, 54, 65, 71, 78 } );
Y.addValues( new int[] { 84, 96, 102, 108, 113 } );
Y.addValues( new int[] { 125, 129, 132, 136, 145 } );
Y.addValues( new int[] { 146, 148, 149, 151 } );
/* - create and compute regression */
PIGompertzRegression regression = new PIGompertzRegression( X, Y );
/* cut partial sums from START */
regression.SetCutStyleForPartialSum( CutStyleForPartialSum.START );
/* set calculation method */
regression.SetCalcMethod( CalcMethod.PARTIAL_SUMS );
regression.Calc();
/* - show results */
Console.WriteLine( regression.GetTextFormula() );
Console.WriteLine( regression.GetTextFormulaFilled() );
/* - calc prediction for X = 15 */
PIDebug.Blank();
Console.WriteLine( "Prediction for X=15 : " + regression.CalcPredictedY( 55.0 ) );
PIDebug.Blank();
Console.WriteLine( "Prediction errors:" );
Console.WriteLine( regression.GetErrors().AsString( 5 ) );
PIDebug.blank();
Console.WriteLine( "SSE = " + regression.GetSSE() );
Console.WriteLine( "ME = " + regression.GetME() );
Console.WriteLine( "MSE = " + regression.GetMSE() );
Console.WriteLine( "MAE = " + regression.GetMAE() );
Console.WriteLine( "MAPE = " + regression.GetMAPE() );
Console.WriteLine( "MPE = " + regression.GetMPE() );
Output:
y = gama * (A^((B^x))
y = 188.1880 * 0.0237^( 0.8941^x)
Prediction for X=15 : 186.70111929865695
Prediction errors:
-3.62885;-4.44769;-5.96931;-8.21619;-8.17836;-10.81467;-13.05679;-13.81519;
-11.98598;-15.45785;-16.11842;-16.85955;-13.58145;-15.19549;-15.62583;-16.81005;
-11.69903;-12.25615;-12.45621;-13.28404;-6.73306;-7.80382;-9.50265;-9.84037;
-4.83120;-7.49180;-8.84040;-10.89620;-11.67878
SSE = 3874.8415717652333
ME = -10.933632784816385
MSE = 133.61522661259426
MAE = 10.933632784816385
MAPE = 28.334993780480005
MPE = -28.334993780480005