g_forecast(G;S;O;X;VV;M;OPTS;R)
Shows fitted values and forecasts future values of a time series
X
using the model object in the M
argument. (Available as of version 19.14)
Function type
Vector only
Syntax
g_forecast(G;S;O;X;VV;M;OPTS;R)
Input
Argument | Type | Description |
---|---|---|
G |
any | A space- or comma-separated list of column names Rows are in the same group
if their values for all of the columns listed in If If any of the columns listed in |
S |
integer | The name of a column in which every row evaluates to a 1 or 0, which determines
whether or not that row is selected to be included in the calculation If
If any of the values in
|
O |
integer | A space- or comma-separated list of column names that
determine the row order within a particular group If
If any of the values in |
X |
any | A column name Represents a time series. |
VV |
list-value | An optional list of independent variables in the case of a model
M (such as ARIMAX) that incorporates such variables. For models
with exogenous variables, the same VV argument, in the same order,
must be specified in g_forecast() . If there are no independent
variables (such as for ARIMA models returned by g_arima() ), leave
this argument empty. |
M |
list-value | The type of model. g_forecast() supports all
sarimax and autoarima models returned from
g_sarimax() .( Available as of version
19.35) |
OPTS |
list-value | Left empty for ARIMA models. There will be options for future models. |
R |
text | Optional for ARIMA values.
|
Return Value
For every row in each group defined by G
, g_forecast()
returns fitted values and future values of the time series X
using the
model object in M
.
Example
The following example shows how to use g_forecast()
with an ARIMA model.
In order to forecast future values, it is necessary to expand the last row of each group
G
by the number of rows to be forecast, after the model is computed on
the unexpanded data. This can be done with <sel value="1+N*g_last1(B;S;O)"
expand="1"/>
<defblock name="arima_forecast" breaks="" var="" p="0" d="0" q="0" steps="0">
<if test="{@var=''}">
<signal msg="arima_forecast: var= must be specified"/>
</if>
<let modelname="{@var}_arima_{@p}_{@d}_{@q}"
fcname="{@var}_forecast"
fcename="{@var}_forecast_se">
<willbe name="{@modelname}" value="g_arima({@breaks};;;{@var};{@p};{@d};{@q};)"/>
<sel value="1+{@steps}*g_last1({@breaks};;)" expand="1"/>
<willbe name="{@fcname}" value="g_forecast({@breaks};;;{@var};;{@modelname};;)"/>
<willbe name="{@fcename}" value="g_forecast({@breaks};;;{@var};;{@modelname};;'se')"/>
</let>
</defblock>
<table>
16.9969;16.5969;16.3012;16.1018;17.0998;16.8997;16.8002;17.4001;
17.0998;16.9996;16.6991;17.3993;17.2002;17.4013;17.4029;17.0015;
17.2965;17.1966;17.4013;16.802;17.1;17.3995;17.3995;17.5008;17.3998;
17.6;17.4;17.3;17;17.8;17.5;18.1;17.5;17.4;17.4;17.1;17.6;17.7;17.4;
17.8;17.6;17.5;16.5;17.8;17.3;17.3;17.1;17.4;16.9;17.3;17.6;16.9;
16.7;16.8;16.8;17.2;16.8;17.6;17.2;16.6;17.1;16.9;16.6;18;17.2;17.3;
17;16.9;17.3;16.8;17.3;17.4;17.7;16.8;16.9;17;16.9;17;16.6;16.7;16.8;
16.7;16.4;16.5;16.4;16.6;16.5;16.7;16.4;16.4;16.2;16.4;16.3;16.4;17;
16.9;17.1;17.1;16.7;16.9;16.5;17.2;16.4;17;17;16.7;16.2;16.6;16.9;
16.5;16.6;16.6;17;17.1;17.1;16.7;16.8;16.3;16.6;16.8;16.9;17.1;16.8;
17;17.2;17.3;17.2;17.3;17.2;17.2;17.5;16.9;16.9;16.9;17.0001;16.4999;
16.6996;16.8001;16.7013;16.6985;16.6005;16.5;17;16.7;16.7;16.9;17.4;
17.1;17;16.8;17.2;17.2;17.4;17.2;16.9;16.8;17;17.4;17.2;17.2;17.1;
17.1;17.1;17.4;17.2;16.9;16.9;17;16.7;16.9;17.3;17.8;17.8;17.6;17.5;
17;16.8999;17.1;17.2002;17.3998;17.5001;17.9;17;17;17;17.2;17.3;17.4;
17.4;17.0001;18.0001;18.2001;17.5999;17.7996;17.6992;17.2002;17.4027
</table>
<call block="arima_forecast" var="c1" p="3" d="1" q="3" steps="10"/>