Package for generating datasets for cross-validation purposes. Learning parameters of a prediction function is a major objective. In order to avoid over-fitting, the model is trained on a different data sample (the 'training set') and evaluated out-of-sample on a so called 'test set'. This approach is known as cross-validation (CV). This package comprises different approaches of dividing the raw data set into a training and test set, respectively, depending on the nature of the underlying data. An nice overview can be accessed here: https://scikit-learn.org/stable/modules/cross_validation.html The separated data sets are stored in array of matrices, which can be read-in for the original model training and evaluation. Written by: Artur Tarassow (atecon@posteo.de) Github project page & pull requests: https://github.com/atecon/CvDataSplitter Public Function: ================ CvDataSplitter() Parameters: =========== The user needs to pass some bundle 'b' in pointer form to the function CvDataSplitter(), e.g. , which includes at least: (i) A list named 'X' with k series, or a matrix named 'X' with T rows and k columns. In case a matrix 'X' was passed, the user additionally needs to pass (ii) a column vector named 'index' referring to the T observations (can be easily generated via gretl by 'genr index'). Additionally, the user can optionally specify the following 2 parameters: cv_type -- string, Type of cross-validation (CV): (i) 'kfold' (default), (ii) 'loo' (Leave-One-Out) (iii) 'recwin' (recursive window for time-series (TS) data) (iv) 'rolwin' (rolling window using a fixed window-width for TS data) n_folds -- int, divide sample into n_folds of groups of equal size (can only be set for cv_type='kfold' (default 5); otherwise determined by the respective CV procedure) win_size -- int, (Initial) Window-width for moving-window related methods 'rolwin' and 'recwin' (default 25 pct. of total valid observations) Returns: ========= The function returns the following information to the bundle 'b': X_train -- array of 'n_folds' matrices, each matrix is of dimension T(i) by (1+k) (for i=1,2,...) holding the observation index in the 1st column and the training data for k variables across columns. X_test -- array of 'n_folds' matrices, each matrix is of dimension T(j) by (1+k) (j=1,2,...) holding the observation index in the 1st column and the test data for k variables across columns. ## Changelog ### v0.3 (June 2021) - Avoid dimension mismatch when concatenating index series with X matrix for both functions kfold() and timefold() in case of missing values. ### v0.2 (June 2021) - Fix typos - Catch error if number of folds exceeds number of observations. - Minimum gretl version required is now 2020a ### v0.1 (March 2019) - Initial version