ISummaryStatistics.R2

Fore Syntax

R2: Double;

Fore.NET Syntax

R2: double;

Description

The R2 property returns determination coefficient.

Comments

This coefficient determines the variation percentage of a dependent variable caused by changed exogenous variables.

Fore Example

To execute the example, add a link to the Stat system assembly.

Sub UserProc;
Var
    LinearR: SmLinearRegress;
    can, fr: Array[9Of Double;
    res, i: Integer;
    Con: IIntercept;
    ss: ISummaryStatistics;
Begin
    LinearR := New SmLinearRegress.Create;
    For i := 0 To 8 Do
        can[i] := 1230 + i * 302;
        fr[i] := 579.5 + i * 9.4;
    End For;
    // Set model parameters
    LinearR.Explained.Value := can;
    LinearR.Explanatories.Add.Value := fr;
    Con := LinearR.ModelCoefficients.Intercept;
    con.Mode := InterceptMode.ManualEstimate;
    con.Estimate := 35.7;
    // Run calculation
    res := LinearR.Execute;
    ss := LinearR.SummaryStatistics;
    Debug.Write("Determination coefficient: ");
    Debug.WriteLine(ss.R2);
    Debug.Write("Determination coefficient (uncentered): ");
    Debug.WriteLine(ss.R2_2);
    Debug.Write("Schwarz information criterion: ");
    Debug.WriteLine(ss.SC);
    Debug.Write("Standard deviation of dependent variable: ");
    Debug.WriteLine(ss.SD);
    Debug.Write("Standard error: ");
    Debug.WriteLine(ss.SE);
    Debug.Write("Standard deviation of residuals: ");
    Debug.WriteLine(ss.SEE);
    Debug.Write("Sum of squared residuals of source data deviations from model data: ");
    Debug.WriteLine(ss.SSR);
    Debug.Write("Residual variance: ");
    Debug.WriteLine(ss.VE);
End Sub UserProc;

After executing the example the console window displays summary statistics:

Fore.NET Example

The requirements and result of the Fore.NET example execution match with those in the Fore example.

Imports Prognoz.Platform.Interop.Stat;

Public Shared Sub Main(Params: StartParams);
Var
    LinearR: SmLinearRegress;
    can, fr: Array[9Of Double;
    res, i: Integer;
    Con: IIntercept;
    ss: ISummaryStatistics;
Begin
    LinearR := New SmLinearRegress.Create();
    For i := 0 To 8 Do
        can[i] := 1230 + i * 302;
        fr[i] := 579.5 + i * 9.4;
    End For;
    // Set model parameters
    LinearR.Explained.Value := can;
    LinearR.Explanatories.Add().Value := fr;
    Con := LinearR.ModelCoefficients.Intercept;
    con.Mode := InterceptMode.imManualEstimate;
    con.Estimate := 35.7;
    // Run calculation
    res := LinearR.Execute();
    ss := LinearR.SummaryStatistics;
    System.Diagnostics.Debug.Write("Determination coefficient: ");
    System.Diagnostics.Debug.WriteLine(ss.R2);
    System.Diagnostics.Debug.Write("Determination coefficient (uncentered): ");
    System.Diagnostics.Debug.WriteLine(ss.R2_2);
    System.Diagnostics.Debug.Write("Schwarz information criterion: ");
    System.Diagnostics.Debug.WriteLine(ss.SC);
    System.Diagnostics.Debug.Write("Standard deviation of dependent variable: ");
    System.Diagnostics.Debug.WriteLine(ss.SD);
    System.Diagnostics.Debug.Write("Standard error: ");
    System.Diagnostics.Debug.WriteLine(ss.SE);
    System.Diagnostics.Debug.Write("Standard deviation of residuals: ");
    System.Diagnostics.Debug.WriteLine(ss.SEE);
    System.Diagnostics.Debug.Write("Sum of squared residuals of source data deviations from model data: ");
    System.Diagnostics.Debug.WriteLine(ss.SSR);
    System.Diagnostics.Debug.Write("Error variance: ");
    System.Diagnostics.Debug.WriteLine(ss.VE);
End Sub;

See also:

ISummaryStatistics | Determination Coefficient