ISlARMA.UseFittedInForecast

Syntax

UseFittedInForecast: Boolean;

Description

The UseFittedInForecast property determines, whether the first forecast values are calculated in the autoregression model based on modeled values.

Comments

Available values:

Example

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

Sub UserProc;
Var
    lr: ISmLinearRegress;
    W: Array[20Of Double;
    ARMA: ISlARMA;
    Inits: Array[2Of Double;
    res: Integer;
    d: Double;
    CoefficientsAR: ICoefficients;
    ModelCoefficients: IModelCoefficients;
    i: Integer;
    Forecast: Array Of Double;
Begin
    lr := New SmLinearRegress.Create;
    // explanatory series values
    w[0] := 2; w[4] := -1.9; w[8] := -0.7; w[12] := 5.4; w[16] := 2.8;
    w[1] := 0.8; w[5] := Double.Nan; w[9] := Double.Nan; w[13] := 6.4;w[17] := 0.8;
    w[2] := -0.3; w[6] := 3.2; w[10] := 4.3; w[14] := 7.4; w[18] := -0.7;
    w[3] := -0.3; w[7] := 1.6; w[11] := 1.1;w[15] := 2;w[19] := Double.Nan;
    // sample period
    lr.ModelPeriod.FirstPoint := 1;
    lr.ModelPeriod.LastPoint := 13;
    lr.Forecast.LastPoint := 19;
    lr.MissingData.Method := MissingDataMethod.SampleAverage;
    lr.Explained.Value := w;
    ModelCoefficients := lr.ModelCoefficients;
    // constant will be used in the model
    ModelCoefficients.Intercept.Mode := InterceptMode.AutoEstimate;
    ARMA := lr.ARMA;
    // the forecast values will be calculated based on modeled series
    ARMA.UseFittedInForecast := True;
    // autoregression order
    ARMA.ParseAR("1");
    // initial approximations of autoregression
    Inits[0] := 0.0025;
    ARMA.InitAR := Inits;
    // difference
    ARMA.Diff := 2;
    // optimization method
    ARMA.EstimationMethod := ARMAEstimationMethodType.LevenbergMarquardt;
    // The first calculation of the model. The forecast values are calculated based on modeled series
    res := lr.Execute;
    If (res = 0Then
    Debug.WriteLine("The forecast values are calculated based on modeled series");
        // autoregression coefficients
        CoefficientsAR := ARMA.CoefficientsAR;
        d := CoefficientsAR.Estimate[0];
        Debug.WriteLine(" Estimation of autoregression coefficient: " + d.ToString);
        // forecast values
        Forecast := lr.Forecast.Value;
        Debug.WriteLine(" Forecast values:"); Debug.Indent;
        For i := lr.ModelPeriod.LastPoint To Forecast.Length - 1 Do
            Debug.WriteLine(Forecast[i]);
        End For;
        Debug.Unindent;
    Else
        Debug.WriteLine(lr.Errors);
    End If;
    // The second calculation of the model. The forecast values are calculated based on actual data
    ARMA.UseFittedInForecast := False;
    res := lr.Execute;
    If (res = 0Then
    Debug.WriteLine("The forecast values are calculated based on actual data");
        // autoregression coefficients
        CoefficientsAR := ARMA.CoefficientsAR;
        d := CoefficientsAR.Estimate[0];
        Debug.WriteLine(" Estimation of autoregression coefficient: " + d.ToString);
        // forecast values
        Forecast := lr.Forecast.Value;
        Debug.WriteLine(" Forecast values:"); Debug.Indent;
        For i := lr.ModelPeriod.LastPoint To Forecast.Length - 1 Do
            Debug.WriteLine(Forecast[i]);
        End For;
        Debug.Unindent;
    Else
        Debug.WriteLine(lr.Errors);
    End If;
End Sub UserProc;

After executing the example a linear regression model is created and its parameters are defined. The console window displays model coefficients estimates and the forecast values calculated based on the modeled series and actual data.

See also:

ISlARMA