WeightedSummaryStatistics: ISummaryStatistics;
WeightedSummaryStatistics: Prognoz.Platform.Interop.Stat.ISummaryStatistics;
The WeightedSummaryStatistics property returns weighted descriptive statistics of a model.
Descriptive statistics are calculated using general formulas. The property does not calculate statistics, not relevant for the current model.
To execute the example, add a link to the Stat system assembly.
Sub UserProc;
Var
PooledModel: ISmPooledModel;
yY: Array[6, 2] Of Double;
x1x, x2x: Array[7, 2] Of Double;
Constan: IIntercept;
Status, i: Integer;
d1,d2: Array Of Double;
Begin
PooledModel := New SmPooledModel.Create;
// Explained values
yY[0, 0] := 20; yY[0, 1] := 17;
yY[1, 0] := 7; yY[1, 1] := 28;
yY[2, 0] := -50; YY[2, 1] := 21;
yY[3, 0] := 20; yY[3, 1] := 17;
yY[4, 0] := 25; yY[4, 1] := 7;
yY[5, 0] := -50; YY[5, 1] := 0.1;
PooledModel.Explained.Value := YY;
// Explanatory values
x1x[0, 0] := 4; x1x[0, 1] := -1.5;
x1x[1, 0] := 0.5; x1x[1, 1] := 5;
x1x[2, 0] := -2; x1x[2, 1] := 2.5;
x1x[3, 0] := 130; x1x[3, 1] := 131;
x1x[4, 0] := 141; x1x[4, 1] := 145;
x1x[5, 0] := 150; x1x[5, 1] := 151;
x1x[6, 0] := 160; x1x[6, 1] := 161;
PooledModel.Explanatories.Add.Value := x1x;
// Weights
x2x[0, 0] := 3; x2x[0, 1] := 0.5;
x2x[1, 0] := 6; x2x[1, 1] := 1;
x2x[2, 0] := 0.75; x2x[2, 1] := 2;
x2x[3, 0] := 230; x2x[3, 1] := 231;
x2x[4, 0] := 240; x2x[4, 1] := 241;
x2x[5, 0] := 250; x2x[5, 1] := 251;
x2x[6, 0] := 260; x2x[6, 1] := 261;
PooledModel.Weights := x2x;
// Sample period
PooledModel.ModelPeriod.FirstPoint := 1;
PooledModel.ModelPeriod.LastPoint := 5;
// Latest forecast point
PooledModel.Forecast.LastPoint := 7;
// Weights
PooledModel.GLSWeights := GLSWeightsType.PeriodWeights;
// Model type
PooledModel.CrossSection := PooledModelCrossSectionType.None;
// Parameters of model coefficients
Constan := PooledModel.ModelCoefficients.Intercept;
Constan.Mode := InterceptMode.None;
// Run calculation
Status := PooledModel.Execute;
If Status = 0 Then
Debug.WriteLine("=== Weighted summary statistics ===");
Debug.WriteLine(" Determination coefficient: " + PooledModel.WeightedSummaryStatistics.R2.ToString);
Debug.WriteLine(" Mean error: " + PooledModel.WeightedSummaryStatistics.ME.ToString);
Debug.WriteLine(" Standard error: " + PooledModel.WeightedSummaryStatistics.SE.ToString);
Debug.WriteLine(" Standard deviation of residuals: " + PooledModel.WeightedSummaryStatistics.SEE.ToString);
Debug.WriteLine("=== Summary statistics ===");
Debug.WriteLine(" Determination coefficient: " + PooledModel.SummaryStatistics.R2.ToString);
Debug.WriteLine(" Mean error: " + PooledModel.SummaryStatistics.ME.ToString);
Debug.WriteLine(" Standard error: " + PooledModel.SummaryStatistics.SE.ToString);
Debug.WriteLine(" Standard deviation of residuals: " + PooledModel.SummaryStatistics.SEE.ToString);
Debug.WriteLine("=== Residuals ===");
For i := 0 To PooledModel.Residuals.GetUpperBound(1) Do
d1 := PooledModel.Residuals;
d2 := PooledModel.Residuals;
Debug.WriteLine(" " + d1[i,0].ToString + " " + d2[i,1].ToString);
End For;
End If;
End Sub UserProc;
After executing the example the panel data regression model with random effects is calculated; calculation results are displayed in the console window.
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
PooledModel: ISmPooledModel;
yY: Array[2, 6] Of Double;
x1x, x2x: Array[2, 7] Of Double;
Constan: IIntercept;
Status, i: Integer;
d1,d2: System.Array;
Begin
PooledModel := New SmPooledModel.Create();
// Explained values
yY[0, 0] := 20; yY[1, 0] := 17;
yY[0, 1] := 7; yY[1, 1] := 28;
yY[0, 2] := -50; YY[1, 2] := 21;
yY[0, 3] := 20; yY[1, 3] := 17;
yY[0, 4] := 25; yY[1, 4] := 7;
yY[0, 5] := -50; YY[1, 5] := 0.1;
PooledModel.Explained.Value := YY;
// Explanatory values
x1x[0, 0] := 4; x1x[1, 0] := -1.5;
x1x[0, 1] := 0.5; x1x[1, 1] := 5;
x1x[0, 2] := -2; x1x[1, 2] := 2.5;
x1x[0, 3] := 130; x1x[1, 3] := 131;
x1x[0, 4] := 141; x1x[1, 4] := 145;
x1x[0, 5] := 150; x1x[1, 5] := 151;
x1x[0, 6] := 160; x1x[1, 6] := 161;
PooledModel.Explanatories.Add().Value := x1x;
// Weights
x2x[0, 0] := 3; x2x[1, 0] := 0.5;
x2x[0, 1] := 6; x2x[1, 1] := 1;
x2x[0, 2] := 0.75; x2x[1, 2] := 2;
x2x[0, 3] := 230; x2x[1, 3] := 231;
x2x[0, 4] := 240; x2x[1, 4] := 241;
x2x[0, 5] := 250; x2x[1, 5] := 251;
x2x[0, 6] := 260; x2x[1, 6] := 261;
PooledModel.Weights := x2x;
// Sample period
PooledModel.ModelPeriod.FirstPoint := 1;
PooledModel.ModelPeriod.LastPoint := 5;
// Latest forecast point
PooledModel.Forecast.LastPoint := 7;
// Type of weights
PooledModel.GLSWeights := GLSWeightsType.glswtPeriodWeights;
// Model type
PooledModel.CrossSection := PooledModelCrossSectionType.pmcstNone;
// Parameters of model coefficients
Constan := PooledModel.ModelCoefficients.Intercept;
Constan.Mode := InterceptMode.imNone;
// Run calculation
Status := PooledModel.Execute();
If Status = 0 Then
System.Diagnostics.Debug.WriteLine("=== Weighted summary statistics ===");
System.Diagnostics.Debug.WriteLine(" Determination coefficient: " + PooledModel.WeightedSummaryStatistics.R2.ToString());
System.Diagnostics.Debug.WriteLine(" Mean error: " + PooledModel.WeightedSummaryStatistics.ME.ToString());
System.Diagnostics.Debug.WriteLine(" Standard error: " + PooledModel.WeightedSummaryStatistics.SE.ToString());
System.Diagnostics.Debug.WriteLine(" Standard deviation of residuals: " + PooledModel.WeightedSummaryStatistics.SEE.ToString());
System.Diagnostics.Debug.WriteLine("=== Summary statistics ===");
System.Diagnostics.Debug.WriteLine(" Determination coefficient: " + PooledModel.SummaryStatistics.R2.ToString());
System.Diagnostics.Debug.WriteLine(" Mean error: " + PooledModel.SummaryStatistics.ME.ToString());
System.Diagnostics.Debug.WriteLine(" Standard error: " + PooledModel.SummaryStatistics.SE.ToString());
System.Diagnostics.Debug.WriteLine(" Standard deviation of residuals: " + PooledModel.SummaryStatistics.SEE.ToString());
System.Diagnostics.Debug.WriteLine("=== Residuals ===");
For i := 0 To PooledModel.Residuals.GetUpperBound(1) Do
d1 := PooledModel.Residuals;
d2 := PooledModel.Residuals;
System.Diagnostics.Debug.WriteLine(" " + d1[0,i].ToString() + " " + d2[1,i].ToString());
End For;
End If;
End Sub;
See also: