SupportsR: Boolean;
SupportsR: boolean;
The SupportsR property returns whether statistical method can be calculated via R package.
Returned values:
True. Calculation of statistical method via the R package is supported.
False. Calculation of statistical method via the R package is not supported.
Add a link to the Stat system assembly.
Sub UserProc;
Var
Method: SmLinearRegress;
can, fra, ger: Array[10] Of Double;
status, i: Integer;
Begin
Method := New SmLinearRegress.Create;
// Explained variable
can[0] := 6209; can[1] := 6385;
can[2] := 6528; can[3] := 6837;
can[4] := 6495; can[5] := 6907;
can[6] := 7349; can[7] := 7213;
can[8] := 7061; can[9] := 7180;
Method.Explained.Value := can;
// Regressors
fra[0] := 4110; ger[0] := 3415;
fra[1] := 4280; ger[1] := 3673;
fra[2] := 4459; ger[2] := 4013;
fra[3] := 4545; ger[3] := 4278;
fra[4] := 4664; ger[4] := 4577;
fra[5] := 4861; ger[5] := 5135;
fra[6] := 5195; ger[6] := 5388;
fra[7] := 5389; ger[7] := 5610;
fra[8] := 5463; ger[8] := 5787;
fra[9] := 5610; ger[9] := 6181;
Method.Explanatories.Clear;
Method.Explanatories.Add.Value := fra;
Method.Explanatories.Add.Value := ger;
// Sample period parameters
Method.ModelPeriod.FirstPoint := 1;
Method.ModelPeriod.LastPoint := 10;
// Forecast parameters
Method.Forecast.LastPoint := 10;
// Support of R
If Method.SupportsR Then
// Calculation of statistical method via R package
Method.UseR := True;
// Calculate and output results
status := Method.Execute;
If status <> 0 Then
Debug.WriteLine(Method.Errors);
Else
Debug.WriteLine("=== Model series ===");
Debug.Indent;
For i := 0 To Method.Fitted.Length - 1 Do
Debug.WriteLine((i+1).ToString + ". " + Method.Fitted[i].ToString);
End For;
Debug.Unindent;
End If;
End If;
End Sub UserProc;
After executing the example the console window displays the result of checking if statistical method can be calculated via R package, and the calculated modeling series.
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
Method: SmLinearRegress;
can, fra, ger: Array[10] Of Double;
status, i: Integer;
Fitted: System.Array;
Begin
Method := New SmLinearRegress.Create();
// Explained variable
can[0] := 6209; can[1] := 6385;
can[2] := 6528; can[3] := 6837;
can[4] := 6495; can[5] := 6907;
can[6] := 7349; can[7] := 7213;
can[8] := 7061; can[9] := 7180;
Method.Explained.Value := can;
// Regressors
fra[0] := 4110; ger[0] := 3415;
fra[1] := 4280; ger[1] := 3673;
fra[2] := 4459; ger[2] := 4013;
fra[3] := 4545; ger[3] := 4278;
fra[4] := 4664; ger[4] := 4577;
fra[5] := 4861; ger[5] := 5135;
fra[6] := 5195; ger[6] := 5388;
fra[7] := 5389; ger[7] := 5610;
fra[8] := 5463; ger[8] := 5787;
fra[9] := 5610; ger[9] := 6181;
Method.Explanatories.Clear();
Method.Explanatories.Add().Value := fra;
Method.Explanatories.Add().Value := ger;
// Sample period parameters
Method.ModelPeriod.FirstPoint := 1;
Method.ModelPeriod.LastPoint := 10;
// Forecast parameters
Method.Forecast.LastPoint := 10;
// Support of R
If Method.SupportsR Then
// Calculation of statistical method via R package
Method.UseR := True;
// Calculate and output results
status := Method.Execute();
If status <> 0 Then
System.Diagnostics.Debug.WriteLine(Method.Errors);
Else
System.Diagnostics.Debug.WriteLine("=== Model series ===");
System.Diagnostics.Debug.Indent();
Fitted := Method.Fitted;
For i := 0 To Method.Fitted.Length - 1 Do
System.Diagnostics.Debug.WriteLine((i+1).ToString() + ". " + Fitted[i].ToString());
End For;
System.Diagnostics.Debug.Unindent();
End If;
End If;
End Sub;
See also: