CrossSectionSDinit: Double;
The CrossSectionSDinit property determines cross-section standard deviation.
The CrossSectionSDinit property is used for calculation with saved coefficients.
To get standard deviation of group error, use the ISmPooledModel.CrossSectionSD property.
To execute the example, add links to the Stat and MathFin system assemblies.
Sub UserProc;
Var
PooledModel: ISmPooledModel;
yY: Array[6, 2] Of Double;
x1x: Array[7, 2] Of Double;
Coefficients: ICoefficients;
Intercept: IIntercept;
i, j, Status: Integer;
arr, Effects, StError, Est, TStat, Prob: Array Of Double;
IntStError, IntEst, IntTStat, IntProb: Double;
str: String;
Begin
PooledModel := New SmPooledModel.Create;
// Explained values
yY[0, 0] := 20; yY[0, 1] := 17;
yY[1, 0] := 10; yY[1, 1] := 7;
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] := 120; x1x[4, 1] := 141;
x1x[5, 0] := 150; x1x[5, 1] := 151;
x1x[6, 0] := 160; x1x[6, 1] := 161;
PooledModel.Explanatories.Add.Value := x1x;
PooledModel.Explanatories.Item(0).InitValue:=0.5;
// Parameters of model coefficients
PooledModel.ModelCoefficients.Intercept.InitValue:=100;
// Sample period
PooledModel.ModelPeriod.FirstPoint := 1;
PooledModel.ModelPeriod.LastPoint := 5;
// Latest forecast point
PooledModel.Forecast.LastPoint := 7;
// Model type
PooledModel.CrossSection := PooledModelCrossSectionType.RandomEffect;
// Method to estimate random effects
PooledModel.RandomEffectsMethod := PooledModelRandomEffectsMethodType.SwamyArora;
//Set, that the model uses saved coefficients
PooledModel.ARMA.MaxIteration:=0;
PooledModel.ARMA.CalcInitMode:=ARMAInitType.Manual;
// Cross-section standard deviations
PooledModel.CrossSectionSDinit := 0.030485421521669304;
// Initial values of effects for calculation without estimation
arr:=New Double[PooledModel.Explained.Value.GetUpperBound(2)+1];
For i:=0 To arr.Length-1 Do
arr[i]:=(i-1)*math.Power(-1,i+2);
End For;
PooledModel.EffectsInits := arr;
// Specifications of random effects, for calculation without estimation
PooledModel.IdiosyncraticSDinit := 0.31046596048669278;
// Start calculation
Status := PooledModel.Execute;
Debug.WriteLine(PooledModel.Errors);
If Status = 0 Then
Debug.WriteLine("Estimates of constant:");
Intercept := PooledModel.ModelCoefficients.Intercept;
IntEst := Intercept.Estimate;
IntStError := Intercept.StandardError;
IntTStat := Intercept.TStatistic;
IntProb := Intercept.Probability;
Debug.WriteLine(" " + IntEst.ToString + " "
+ IntStError.ToString + " " + IntTStat.ToString + " " + IntProb.ToString);
Debug.WriteLine("Estimates of model coefficients:");
Coefficients := PooledModel.ModelCoefficients.Coefficients;
j := Coefficients.Estimate.Length;
For i := 0 To j - 1 Do
Est := Coefficients.Estimate;
StError := Coefficients.StandardError;
TStat := Coefficients.TStatistic;
Prob := Coefficients.Probability;
Debug.WriteLine(" " + (i + 1).ToString + ": " + Est[i].ToString + " "
+ StError[i].ToString + " " + TStat[i].ToString + " " + Prob[i].ToString);
End For;
Debug.WriteLine("Calculated effects: ");
Effects := PooledModel.Effects;
For i := 0 To PooledModel.Effects.Length-1 Do
Debug.WriteLine(" " + (i+1).ToString + ": " + Effects[i].ToString);
End For;
Debug.WriteLine("Covariance matrix");
For i := 0 To PooledModel.CovarianceMatrix.GetUpperBound(1) Do
str := "";
For j := 0 To PooledModel.CovarianceMatrix.GetUpperBound(2) Do
str := str + " " + (PooledModel.CovarianceMatrix[i, j] As Double).ToString;
End For;
Debug.WriteLine(str);
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.
See also: