DistributionType: ErrorDistributionType;
The DistributionType property determines type of error distribution.
Normal error distribution is used by default: that is, DistributionType = ErrorDistributionType.NormalDistribution.
To execute the example, add a link to the Stat system assembly.
Sub UserProc;
Var
Cr: SmCensoredTruncatedRegression;
y, x, uBound, lBound: Array[20] Of Double;
i, res, factN, N: Integer;
coef: ICoefficients;
stat: ISummaryStatistics;
Begin
Cr := New SmCensoredTruncatedRegression.Create;
// Set values fornbsp;variables
y[0] := 1; x[0] := 0.841471;
y[1] := Double.Nan; x[1] := 0.909297;
y[2] := -0.432407;x[2]:=0.14112;
y[3] := -1; x[3] := -0.756802;
y[4] := Double.Nan; x[4] := -0.958924;
y[5] := -0.628591;x[5]:=-0.279415;
y[6] := 1; x[6] := 0.656987;
y[7] := 1; x[7] := 0.989358;
y[8] := 1; x[8] := 0.412118;
y[9] := -0.423543;x[9]:=-0.544021;
y[10] := -1; x[10] := -0.99999;
y[11] := Double.Nan; x[11] := -0.536573;
y[12] := 1; x[12] := 0.420167;
y[13] := 1; x[13] := 0.990607;
y[14] := 0.544025; x[14] := 0.650288;
y[15] := Double.Nan; x[15] := -0.287903;
y[16] := -1; x[16] := -0.961397;
y[17] := Double.Nan; x[17] := -0.750987;
y[18] := 0.549188; x[18] := 0.149877;
y[19] := 1; x[19] := 0.912945;
// Determine model type
Cr.ModelType := CTModelType.TruncatedRegression;
// Determine error distribution type
Cr.DistributionType := ErrorDistributionType.GumbelDistribution;
// Set explained series
Cr.Explained.Value := y;
// Set explanatory series
Cr.Explanatories.Add.Value := x;
factN := 20;
N := 1;
// Set values for the first and the last points of the identificationnbsp;period
Cr.ModelPeriod.FirstPoint := 1;
Cr.ModelPeriod.LastPoint := factN - 5;
// Set value for the last forecast point
Cr.Forecast.LastPoint := factN;
// Determine maximum number of iterations
Cr.MaxIteration := 500;
// Determine accuracy of solution
Cr.Tolerance := 0.0001;
For i := 0 To factN - 1 Do
lBound[i] := -1;
uBound[i] := 1;
End For;
// Determine left (lower) limit for observation
Cr.LeftBound.Value := lBound;
//Determine right (upper) limit for observation
Cr.RightBound.Value := uBound;
// Determine constant
Cr.ModelCoefficients.Intercept.Mode := InterceptMode.AutoEstimate;
// Determine missing data treatment method
Cr.MissingData.Method := MissingDataMethod.LinTrend;
// Perform calculation and display error messages
res := Cr.Execute;
Debug.WriteLine("Errors: " + Cr.Errors);
// Display calculation results
If res = 0 Then
Debug.WriteLine("");
Debug.WriteLine("Estimated model coefficients: ");
Debug.Indent;
coef := Cr.ModelCoefficients.Coefficients;
For i := 0 To N - 1 Do
Debug.WriteLine("coefficient value: " + coef.Estimate[i].ToString);
Debug.WriteLine("standard error: " + coef.StandardError[i].ToString);
Debug.WriteLine("t-statistic: " + coef.TStatistic[i].ToString);
Debug.WriteLine("probability: " + coef.Probability[i].ToString);
End For;
Debug.Unindent;
Debug.WriteLine("");
Debug.WriteLine("Results of Sigma calculation: ");
Debug.Indent;
Debug.WriteLine("value: " + Cr.Sigma.ToString);
Debug.WriteLine("standard error: " + Cr.SigmaSE.ToString);
Debug.WriteLine("error of Z-statistics: " + Cr.SigmaZStatErr.ToString);
Debug.WriteLine("probability of Z-statistics error: " + Cr.SigmaZStatProbErr.ToString);
Debug.Unindent;
Debug.WriteLine("");
Debug.WriteLine("Common statistics:");
Debug.Indent;
stat := cr.SummaryStatistics;
Debug.WriteLine("R2: " + stat.R2.ToString);
Debug.WriteLine("AdjR2: " + stat.AdjR2.ToString);
Debug.WriteLine("Fstat: " + stat.Fstat.ToString);
Debug.WriteLine("ProbFstat: " + stat.ProbFstat.ToString);
Debug.WriteLine("DW: " + stat.DW.ToString);
Debug.WriteLine("========");
Debug.WriteLine("MD: " + stat.MD.ToString);
Debug.WriteLine("SE: " + stat.SE.ToString);
Debug.WriteLine("SSR: " + stat.SSR.ToString);
Debug.WriteLine("LogL: " + stat.LogL.ToString);
Debug.WriteLine("AvgLogL: " + stat.AvgLogL.ToString);
Debug.WriteLine("SD: " + stat.SD.ToString);
Debug.WriteLine("AIC: " + stat.AIC.ToString);
Debug.WriteLine("SC: " + stat.SC.ToString);
Debug.WriteLine("HQcriterion: " + stat.HQcriterion.ToString);
Debug.Unindent; Debug.WriteLine("");
Debug.WriteLine("Modeling series:"); Debug.Indent;
For i := 0 To cr.Fitted.Length - 1 Do
Debug.WriteLine(i.ToString + ": " + (cr.Fitted[i] As Double).ToString);
End For;
Debug.Unindent; Debug.WriteLine("");
Debug.WriteLine("Latent modeling series:"); Debug.Indent;
For i := 0 To cr.LatentFitted.Length - 1 Do
Debug.WriteLine(i.ToString + ": " + (cr.LatentFitted[i] As Double).ToString);
End For;
Debug.Unindent; Debug.WriteLine("");
Debug.WriteLine("Residuals:"); Debug.Indent;
For i := 0 To cr.Residuals.Length - 1 Do
Debug.WriteLine(i.ToString + ": " + (cr.Residuals[i] As Double).ToString);
End For;
Debug.Unindent; Debug.WriteLine("");
Debug.WriteLine("Forecast:"); Debug.Indent;
For i := 0 To cr.Forecast.Value.Length - 1 Do
Debug.WriteLine(i.ToString + ": " + (cr.Forecast.Value[i] As Double).ToString);
End For;
Debug.Unindent; Debug.WriteLine("");
Debug.WriteLine("Latent forecast:"); Debug.Indent;
For i := 0 To cr.LatentForecast.Value.Length - 1 Do
Debug.WriteLine(i.ToString + ": " + (cr.LatentForecast.Value[i] As Double).ToString);
End For;
End If;
End Sub UserProc;
After executing the example a regression model with censored data is created and calculated, results are displayed in the console window.
See also: