IStatistics.Rsq

Fore Syntax

Rsq(KnownYs: Array; KnownXs: Array): Double;

Fore.NET Syntax

Rsq(KnownYs: System.Array; KnownXs: System.Array): double;

Parameters

KnownYs. Independent series.

KnownXs. Dependent series.

Description

The Rsq method returns the squared Pearson correlation coefficient (r^2).

Comments

For correct calculation the KnownYs and KnownXs series:

Fore Example

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

Sub userProc;
Var
    st: Statistics;
    d0: Double;
    y, x: Array 
Of Double;
Begin
    y := 
New Double[10];
    y[
00] := 1.6; y[05] := 2.1;
    y[
01] := 1.7; y[06] := 2.2;
    y[
02] := 1.8; y[07] := 2.3;
    y[
03] := 1.9; y[08] := 2.4;
    y[
04] := 2; y[09] := 2.8;
    x := 
New Double[10];
    x[
00] := 2; x[05] := 6;
    x[
01] := 4; x[06] := 15;
    x[
02] := 2; x[07] := 17;
    x[
03] := 5; x[08] := 14;
    x[
04] := 12; x[09] := 3;
    st := 
New Statistics.Create;
    d0 := st.Rsq(y, x);
        
If st.Status <> 0 Then
    Debug.WriteLine(st.Errors);
    
Else
        Debug.WriteLine(
"Squared Pearson coefficient: " + d0.ToString);
    
End If;
End Sub userProc;

After executing the example the console window displays the squared Pearson correlation coefficient:

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
    st: Statistics;
    d0: Double;
    y, x: Array Of Double;
Begin
    y := New Double[10];
    y[00] := 1.6; y[05] := 2.1;
    y[01] := 1.7; y[06] := 2.2;
    y[02] := 1.8; y[07] := 2.3;
    y[03] := 1.9; y[08] := 2.4;
    y[04] := 2; y[09] := 2.8;
    x := New Double[10];
    x[00] := 2; x[05] := 6;
    x[01] := 4; x[06] := 15;
    x[02] := 2; x[07] := 17;
    x[03] := 5; x[08] := 14;
    x[04] := 12; x[09] := 3;
    st := New Statistics.Create();
    d0 := st.Rsq(y, x);
        If st.Status <> 0 Then
    System.Diagnostics.Debug.WriteLine(st.Errors);
    Else
        System.Diagnostics.Debug.WriteLine("Squared Pearson coefficient: " + d0.ToString());
    End If;
End Sub;

See also:

IStatistics