The uniFCextensions package aims to do two or three things, all based on a single-equation dynamic OLS model in a time-series context: 1: Estimate an interval forecast without assuming Gaussian innovations. (With Gaussian: built-in in gretl.) This is done by simulating (bootstrapping) the predictive density. The implicit assumption is a symmetric loss function (plus perhaps a symmetric innovation distribution, or alternatively even quadratic loss). 2: Provide a point forecast for the case of a lin-lin loss function. For lin-lin loss with asymmetry parameter alpha the optimal point forecast is the alpha-quantile of the predictive density. 3: For a model where the dependent variable was log-transformed (explicitly or implicitly), say log(y), construct a consistent forecast for the non-log variable y. About task 3, it is well known that simply applying the exponential (anti-log) function to the log-y-forecast is not consistent, due to the underlying non- linear transformation. Three alternatives are offered; see also Wooldridge (Introd. Ec., ISE, pp. 219-220): (i) exp(logforecast) * a, where the factor 'a' is the coeff of the regression of the in-sample observations of exp(logobserved) only on exp(logfitted), no constant term, and 'logfitted' are the in-sample fitted values of log(y). (ii) exp(logforecast) * exp(0.5 * s^2), where 's' is the empirical standard error of the original regression with log(y). This formula rests on the assumption of Gaussian innovations (in the log model). (iii) The simulated forecasts of y based on simulating (bootstrapping) the model for log(y), then exponentiating each individual draw, yielding a simulated density for y (for each period in the horizon). The mean of this density is the recommended forecast for y. Parameter uncertainty is not addressed (maybe in the future). GUI: The package is usable from the menu in the model window after a (dynamic) OLS estimation (choose Analysis/Bootstrapped forecasts). In that case it returns a bundle that is an augmented gretl model bundle; if the asymmetry parameter is left at the middle default value 0.5, then task 1 or 3 are performed (depending on the respective tick box choice) and a 'uniFCboot' matrix is added. If the forecast horizon is greater than 1 and a fairly recent gretl version is used (>=2024a), then a plot is also produced. On the other hand, if the asymmetry parameter is different from 0.5, then task 2 is executed and a 'FClinlin' matrix together with a 'alphalinlin' scalar member are added. The exogenous future values in the GUI context should be passed _without_ the coefficients factored in, i.e. as a H x K matrix (where K is the number of non-constant exogenous terms), not as a H x 1 vector as in the scripting context (see below). Hansl: And of course it is usable also through a functional scripting interface with the following functions: 1: uniFCboot, for tasks 1 and 3 -------------------------------- Parameters: bundle (mod): a model bundle as given by gretl's $model accessor, int (H): optional forecast horizon (default 1), int (reps): optional number of bootstrap draws (default 5000 [GUI: 3000]), matrix (quants): optional quantiles to be evaluated which should have values between 0 and 0.5 (formal default null implies default quantiles below), matrix (exo): optional future exogenous influences (values times coeffs) (default null, nothing), bool (fcastexp): optional switch to forecast the non-log after a log model (default FALSE, no transform) 'exo' (Hx1) provides the future values of any exogenous terms (other than the constant!) in the underlying equation (X'b, i.e. already with the coefficients factored in). Otherwise they are set to zero. Returns a matrix; - In the default case of fcastexp==FALSE, a H x (1 + 2*Q) matrix of bootstrapped quantiles of forecast (FC) densities, where Q is the number of elements in 'quants'. The first column always refers to the median (q0.5), and Q is the number of elements in 'quants'; The default for 'quants' is {0.005, 0.025, 0.05, 0.1}, corresponding to two-sided 1%, 5%, 10%, 20%. Each value is mirrored to the right: e.g. 0.1 together with 0.9.) - If fcastexp==TRUE, the respective (1 + 2*Q) quantiles for the exp()- transformed density are supplemented by three columns at the end, holding the consistent mean forecasts explained above in (i), (ii), and (iii). The total dimension of the return matrix is therefore H x (4 + 2*Q). The bootstrap is based on simple resampling. Note: if you want a fast level forecast from a log model (task 3) only based on the analytical methods (i) or (ii), consider setting 'reps' to a low number and ignoring the bootstrap results. 1b: FCboot, newly recommended interface for tasks 1 and 3 --------------------------------------------------------- Parameters: bundle (mod): a model bundle as given by gretl's $model accessor, bundle (optsinput): optional bundle with options. This function offers a bundle-based interface for the user options. The labels of the options are listed in the companion function uniFCboot above. If no options bundle is specified, the defaults given above are used. Returns the same matrix as uniFCboot. 2: FClinlin, for task 2 ----------------------- Parameters: bundle (mod): a model bundle as given by gretl's $model accessor, scalar (alpha): optional asymmetry param between zero and one (default 0.5), int (H): optional forecast horizon (default 1), int (reps): optional number of bootstrap draws (default 3000), matrix (exo): optional future exogenous influences (values times coeffs) (default null, nothing). Returns a matrix (vector): H-row column vector of lin-lin point forecasts, from forecast step 1 (top) to H (bottom). This is nothing else than the alpha-quantile of the forecast density, which is the optimal FC under lin-lin loss with alpha (see e.g. the Elliott & Timmermann forecasting book p. 43). For construction of 'exo' see the uniFCboot function. Changelog: ---------- 1.2, May 2025: - internal updates, require gretl 2021c; - warn explicitly (in the GUI) if no future exogenous values were given although the model has such terms; - also in the GUI, expect a data matrix of dimension horizon-by-numofexo for the exogenous future terms (Xexo), not already the product of this matrix with the estimated coefficients (of dimension horizon-by-1, exo), because in the GUI from the model window the coefficients aren't available to the user in a convenient way; - increase default number of bootstrap repetitions, while also speeding up the bootstrap routine; - add a simple plot in the GUI for tasks 1 and 3 (but only for horizons >1); - add level forecast from log model; - fix an ugly bug with gappy lag structures that would lead to wrong results 1.1, June 2021: clean up internal syntax, require gretl 2018a 1.0, July 2017: initial release