Skip to contents

This function converts univariate or multivariate time series (xts or ts objects) to the format necessary for mvgam

Usage

series_to_mvgam(series, freq, train_prop = 0.85)

Arguments

series

xts or ts object to be converted to mvgam format

freq

integer. The seasonal frequency of the series

train_prop

numeric stating the proportion of data to use for training. Should be between 0.25 and 0.95

Value

A list object containing outputs needed for mvgam, including 'data_train' and 'data_test'

Examples

# A ts object example
data("sunspots")
series <- cbind(sunspots, sunspots)
colnames(series) <- c('blood', 'bone')
head(series)
#>      blood bone
#> [1,]  58.0 58.0
#> [2,]  62.6 62.6
#> [3,]  70.0 70.0
#> [4,]  55.7 55.7
#> [5,]  85.0 85.0
#> [6,]  83.5 83.5
series_to_mvgam(series, frequency(series), 0.85)
#> $data_train
#>         y season year                date series time
#> 1    58.0      1 1749 1749-01-01 00:00:00  blood    1
#> 2    58.0      1 1749 1749-01-01 00:00:00   bone    1
#> 3    62.6      2 1749 1749-01-31 10:00:00  blood    2
#> 4    62.6      2 1749 1749-01-31 10:00:00   bone    2
#> 5    70.0      3 1749 1749-03-02 20:00:01  blood    3
#> 6    70.0      3 1749 1749-03-02 20:00:01   bone    3
#> 7    55.7      4 1749 1749-04-02 06:00:00  blood    4
#> 8    55.7      4 1749 1749-04-02 06:00:00   bone    4
#> 9    85.0      5 1749 1749-05-02 16:00:00  blood    5
#> 10   85.0      5 1749 1749-05-02 16:00:00   bone    5
#> 11   83.5      6 1749 1749-06-02 02:00:01  blood    6
#> 12   83.5      6 1749 1749-06-02 02:00:01   bone    6
#> 13   94.8      7 1749 1749-07-02 12:00:00  blood    7
#> 14   94.8      7 1749 1749-07-02 12:00:00   bone    7
#> 15   66.3      8 1749 1749-08-01 22:00:00  blood    8
#> 16   66.3      8 1749 1749-08-01 22:00:00   bone    8
#> 17   75.9      9 1749 1749-09-01 08:00:01  blood    9
#> 18   75.9      9 1749 1749-09-01 08:00:01   bone    9
#> 19   75.5     10 1749 1749-10-01 18:00:00  blood   10
#> 20   75.5     10 1749 1749-10-01 18:00:00   bone   10
#> 21  158.6     11 1749 1749-11-01 04:00:00  blood   11
#> 22  158.6     11 1749 1749-11-01 04:00:00   bone   11
#> 23   85.2     12 1749 1749-12-01 14:00:01  blood   12
#> 24   85.2     12 1749 1749-12-01 14:00:01   bone   12
#> 25   73.3      1 1750 1750-01-01 00:00:00  blood   13
#> 26   73.3      1 1750 1750-01-01 00:00:00   bone   13
#> 27   75.9      2 1750 1750-01-31 10:00:00  blood   14
#> 28   75.9      2 1750 1750-01-31 10:00:00   bone   14
#> 29   89.2      3 1750 1750-03-02 20:00:01  blood   15
#> 30   89.2      3 1750 1750-03-02 20:00:01   bone   15
#> 31   88.3      4 1750 1750-04-02 06:00:00  blood   16
#> 32   88.3      4 1750 1750-04-02 06:00:00   bone   16
#> 33   90.0      5 1750 1750-05-02 16:00:00  blood   17
#> 34   90.0      5 1750 1750-05-02 16:00:00   bone   17
#> 35  100.0      6 1750 1750-06-02 02:00:01  blood   18
#> 36  100.0      6 1750 1750-06-02 02:00:01   bone   18
#> 37   85.4      7 1750 1750-07-02 12:00:00  blood   19
#> 38   85.4      7 1750 1750-07-02 12:00:00   bone   19
#> 39  103.0      8 1750 1750-08-01 22:00:00  blood   20
#> 40  103.0      8 1750 1750-08-01 22:00:00   bone   20
#> 41   91.2      9 1750 1750-09-01 08:00:01  blood   21
#> 42   91.2      9 1750 1750-09-01 08:00:01   bone   21
#> 43   65.7     10 1750 1750-10-01 18:00:00  blood   22
#> 44   65.7     10 1750 1750-10-01 18:00:00   bone   22
#> 45   63.3     11 1750 1750-11-01 04:00:00  blood   23
#> 46   63.3     11 1750 1750-11-01 04:00:00   bone   23
#> 47   75.4     12 1750 1750-12-01 14:00:01  blood   24
#> 48   75.4     12 1750 1750-12-01 14:00:01   bone   24
#> 49   70.0      1 1751 1751-01-01 00:00:00  blood   25
#> 50   70.0      1 1751 1751-01-01 00:00:00   bone   25
#> 51   43.5      2 1751 1751-01-31 10:00:00  blood   26
#> 52   43.5      2 1751 1751-01-31 10:00:00   bone   26
#> 53   45.3      3 1751 1751-03-02 20:00:01  blood   27
#> 54   45.3      3 1751 1751-03-02 20:00:01   bone   27
#> 55   56.4      4 1751 1751-04-02 06:00:00  blood   28
#> 56   56.4      4 1751 1751-04-02 06:00:00   bone   28
#> 57   60.7      5 1751 1751-05-02 16:00:00  blood   29
#> 58   60.7      5 1751 1751-05-02 16:00:00   bone   29
#> 59   50.7      6 1751 1751-06-02 02:00:01  blood   30
#> 60   50.7      6 1751 1751-06-02 02:00:01   bone   30
#> 61   66.3      7 1751 1751-07-02 12:00:00  blood   31
#> 62   66.3      7 1751 1751-07-02 12:00:00   bone   31
#> 63   59.8      8 1751 1751-08-01 22:00:00  blood   32
#> 64   59.8      8 1751 1751-08-01 22:00:00   bone   32
#> 65   23.5      9 1751 1751-09-01 08:00:01  blood   33
#> 66   23.5      9 1751 1751-09-01 08:00:01   bone   33
#> 67   23.2     10 1751 1751-10-01 18:00:00  blood   34
#> 68   23.2     10 1751 1751-10-01 18:00:00   bone   34
#> 69   28.5     11 1751 1751-11-01 04:00:00  blood   35
#> 70   28.5     11 1751 1751-11-01 04:00:00   bone   35
#> 71   44.0     12 1751 1751-12-01 14:00:01  blood   36
#> 72   44.0     12 1751 1751-12-01 14:00:01   bone   36
#> 73   35.0      1 1752 1752-01-01 00:00:00  blood   37
#> 74   35.0      1 1752 1752-01-01 00:00:00   bone   37
#> 75   50.0      2 1752 1752-01-31 12:00:00  blood   38
#> 76   50.0      2 1752 1752-01-31 12:00:00   bone   38
#> 77   71.0      3 1752 1752-03-02 00:00:01  blood   39
#> 78   71.0      3 1752 1752-03-02 00:00:01   bone   39
#> 79   59.3      4 1752 1752-04-01 12:00:00  blood   40
#> 80   59.3      4 1752 1752-04-01 12:00:00   bone   40
#> 81   59.7      5 1752 1752-05-02 00:00:00  blood   41
#> 82   59.7      5 1752 1752-05-02 00:00:00   bone   41
#> 83   39.6      6 1752 1752-06-01 12:00:01  blood   42
#> 84   39.6      6 1752 1752-06-01 12:00:01   bone   42
#> 85   78.4      7 1752 1752-07-02 00:00:00  blood   43
#> 86   78.4      7 1752 1752-07-02 00:00:00   bone   43
#> 87   29.3      8 1752 1752-08-01 12:00:00  blood   44
#> 88   29.3      8 1752 1752-08-01 12:00:00   bone   44
#> 89   27.1      9 1752 1752-09-01 00:00:01  blood   45
#> 90   27.1      9 1752 1752-09-01 00:00:01   bone   45
#> 91   46.6     10 1752 1752-10-01 12:00:00  blood   46
#> 92   46.6     10 1752 1752-10-01 12:00:00   bone   46
#> 93   37.6     11 1752 1752-11-01 00:00:00  blood   47
#> 94   37.6     11 1752 1752-11-01 00:00:00   bone   47
#> 95   40.0     12 1752 1752-12-01 12:00:01  blood   48
#> 96   40.0     12 1752 1752-12-01 12:00:01   bone   48
#> 97   44.0      1 1753 1753-01-01 00:00:00  blood   49
#> 98   44.0      1 1753 1753-01-01 00:00:00   bone   49
#> 99   32.0      2 1753 1753-01-31 10:00:00  blood   50
#> 100  32.0      2 1753 1753-01-31 10:00:00   bone   50
#> 101  45.7      3 1753 1753-03-02 20:00:01  blood   51
#> 102  45.7      3 1753 1753-03-02 20:00:01   bone   51
#> 103  38.0      4 1753 1753-04-02 06:00:00  blood   52
#> 104  38.0      4 1753 1753-04-02 06:00:00   bone   52
#> 105  36.0      5 1753 1753-05-02 16:00:00  blood   53
#> 106  36.0      5 1753 1753-05-02 16:00:00   bone   53
#> 107  31.7      6 1753 1753-06-02 02:00:01  blood   54
#> 108  31.7      6 1753 1753-06-02 02:00:01   bone   54
#> 109  22.2      7 1753 1753-07-02 12:00:00  blood   55
#> 110  22.2      7 1753 1753-07-02 12:00:00   bone   55
#> 111  39.0      8 1753 1753-08-01 22:00:00  blood   56
#> 112  39.0      8 1753 1753-08-01 22:00:00   bone   56
#> 113  28.0      9 1753 1753-09-01 08:00:01  blood   57
#> 114  28.0      9 1753 1753-09-01 08:00:01   bone   57
#> 115  25.0     10 1753 1753-10-01 18:00:00  blood   58
#> 116  25.0     10 1753 1753-10-01 18:00:00   bone   58
#> 117  20.0     11 1753 1753-11-01 04:00:00  blood   59
#> 118  20.0     11 1753 1753-11-01 04:00:00   bone   59
#> 119   6.7     12 1753 1753-12-01 14:00:01  blood   60
#> 120   6.7     12 1753 1753-12-01 14:00:01   bone   60
#> 121   0.0      1 1754 1754-01-01 00:00:00  blood   61
#> 122   0.0      1 1754 1754-01-01 00:00:00   bone   61
#> 123   3.0      2 1754 1754-01-31 10:00:00  blood   62
#> 124   3.0      2 1754 1754-01-31 10:00:00   bone   62
#> 125   1.7      3 1754 1754-03-02 20:00:01  blood   63
#> 126   1.7      3 1754 1754-03-02 20:00:01   bone   63
#> 127  13.7      4 1754 1754-04-02 06:00:00  blood   64
#> 128  13.7      4 1754 1754-04-02 06:00:00   bone   64
#> 129  20.7      5 1754 1754-05-02 16:00:00  blood   65
#> 130  20.7      5 1754 1754-05-02 16:00:00   bone   65
#> 131  26.7      6 1754 1754-06-02 02:00:01  blood   66
#> 132  26.7      6 1754 1754-06-02 02:00:01   bone   66
#> 133  18.8      7 1754 1754-07-02 12:00:00  blood   67
#> 134  18.8      7 1754 1754-07-02 12:00:00   bone   67
#> 135  12.3      8 1754 1754-08-01 22:00:00  blood   68
#> 136  12.3      8 1754 1754-08-01 22:00:00   bone   68
#> 137   8.2      9 1754 1754-09-01 08:00:01  blood   69
#> 138   8.2      9 1754 1754-09-01 08:00:01   bone   69
#> 139  24.1     10 1754 1754-10-01 18:00:00  blood   70
#> 140  24.1     10 1754 1754-10-01 18:00:00   bone   70
#> 141  13.2     11 1754 1754-11-01 04:00:00  blood   71
#> 142  13.2     11 1754 1754-11-01 04:00:00   bone   71
#> 143   4.2     12 1754 1754-12-01 14:00:01  blood   72
#> 144   4.2     12 1754 1754-12-01 14:00:01   bone   72
#> 145  10.2      1 1755 1755-01-01 00:00:00  blood   73
#> 146  10.2      1 1755 1755-01-01 00:00:00   bone   73
#> 147  11.2      2 1755 1755-01-31 10:00:00  blood   74
#> 148  11.2      2 1755 1755-01-31 10:00:00   bone   74
#> 149   6.8      3 1755 1755-03-02 20:00:01  blood   75
#> 150   6.8      3 1755 1755-03-02 20:00:01   bone   75
#> 151   6.5      4 1755 1755-04-02 06:00:00  blood   76
#> 152   6.5      4 1755 1755-04-02 06:00:00   bone   76
#> 153   0.0      5 1755 1755-05-02 16:00:00  blood   77
#> 154   0.0      5 1755 1755-05-02 16:00:00   bone   77
#> 155   0.0      6 1755 1755-06-02 02:00:01  blood   78
#> 156   0.0      6 1755 1755-06-02 02:00:01   bone   78
#> 157   8.6      7 1755 1755-07-02 12:00:00  blood   79
#> 158   8.6      7 1755 1755-07-02 12:00:00   bone   79
#> 159   3.2      8 1755 1755-08-01 22:00:00  blood   80
#> 160   3.2      8 1755 1755-08-01 22:00:00   bone   80
#> 161  17.8      9 1755 1755-09-01 08:00:01  blood   81
#> 162  17.8      9 1755 1755-09-01 08:00:01   bone   81
#> 163  23.7     10 1755 1755-10-01 18:00:00  blood   82
#> 164  23.7     10 1755 1755-10-01 18:00:00   bone   82
#> 165   6.8     11 1755 1755-11-01 04:00:00  blood   83
#> 166   6.8     11 1755 1755-11-01 04:00:00   bone   83
#>  [ reached 'max' / getOption("max.print") -- omitted 4628 rows ]
#> 
#> $data_test
#>         y season year                date series time
#> 1   136.3     10 1948 1948-10-01 12:00:00  blood 2398
#> 2   136.3     10 1948 1948-10-01 12:00:00   bone 2398
#> 3    95.8     11 1948 1948-11-01 00:00:01  blood 2399
#> 4    95.8     11 1948 1948-11-01 00:00:01   bone 2399
#> 5   138.0     12 1948 1948-12-01 12:00:01  blood 2400
#> 6   138.0     12 1948 1948-12-01 12:00:01   bone 2400
#> 7   119.1      1 1949 1949-01-01 00:00:00  blood 2401
#> 8   119.1      1 1949 1949-01-01 00:00:00   bone 2401
#> 9   182.3      2 1949 1949-01-31 10:00:01  blood 2402
#> 10  182.3      2 1949 1949-01-31 10:00:01   bone 2402
#> 11  157.5      3 1949 1949-03-02 20:00:01  blood 2403
#> 12  157.5      3 1949 1949-03-02 20:00:01   bone 2403
#> 13  147.0      4 1949 1949-04-02 06:00:00  blood 2404
#> 14  147.0      4 1949 1949-04-02 06:00:00   bone 2404
#> 15  106.2      5 1949 1949-05-02 16:00:01  blood 2405
#> 16  106.2      5 1949 1949-05-02 16:00:01   bone 2405
#> 17  121.7      6 1949 1949-06-02 02:00:01  blood 2406
#> 18  121.7      6 1949 1949-06-02 02:00:01   bone 2406
#> 19  125.8      7 1949 1949-07-02 12:00:00  blood 2407
#> 20  125.8      7 1949 1949-07-02 12:00:00   bone 2407
#> 21  123.8      8 1949 1949-08-01 22:00:01  blood 2408
#> 22  123.8      8 1949 1949-08-01 22:00:01   bone 2408
#> 23  145.3      9 1949 1949-09-01 08:00:01  blood 2409
#> 24  145.3      9 1949 1949-09-01 08:00:01   bone 2409
#> 25  131.6     10 1949 1949-10-01 18:00:00  blood 2410
#> 26  131.6     10 1949 1949-10-01 18:00:00   bone 2410
#> 27  143.5     11 1949 1949-11-01 04:00:01  blood 2411
#> 28  143.5     11 1949 1949-11-01 04:00:01   bone 2411
#> 29  117.6     12 1949 1949-12-01 14:00:01  blood 2412
#> 30  117.6     12 1949 1949-12-01 14:00:01   bone 2412
#> 31  101.6      1 1950 1950-01-01 00:00:00  blood 2413
#> 32  101.6      1 1950 1950-01-01 00:00:00   bone 2413
#> 33   94.8      2 1950 1950-01-31 10:00:01  blood 2414
#> 34   94.8      2 1950 1950-01-31 10:00:01   bone 2414
#> 35  109.7      3 1950 1950-03-02 20:00:01  blood 2415
#> 36  109.7      3 1950 1950-03-02 20:00:01   bone 2415
#> 37  113.4      4 1950 1950-04-02 06:00:00  blood 2416
#> 38  113.4      4 1950 1950-04-02 06:00:00   bone 2416
#> 39  106.2      5 1950 1950-05-02 16:00:01  blood 2417
#> 40  106.2      5 1950 1950-05-02 16:00:01   bone 2417
#> 41   83.6      6 1950 1950-06-02 02:00:01  blood 2418
#> 42   83.6      6 1950 1950-06-02 02:00:01   bone 2418
#> 43   91.0      7 1950 1950-07-02 12:00:00  blood 2419
#> 44   91.0      7 1950 1950-07-02 12:00:00   bone 2419
#> 45   85.2      8 1950 1950-08-01 22:00:01  blood 2420
#> 46   85.2      8 1950 1950-08-01 22:00:01   bone 2420
#> 47   51.3      9 1950 1950-09-01 08:00:01  blood 2421
#> 48   51.3      9 1950 1950-09-01 08:00:01   bone 2421
#> 49   61.4     10 1950 1950-10-01 18:00:00  blood 2422
#> 50   61.4     10 1950 1950-10-01 18:00:00   bone 2422
#> 51   54.8     11 1950 1950-11-01 04:00:01  blood 2423
#> 52   54.8     11 1950 1950-11-01 04:00:01   bone 2423
#> 53   54.1     12 1950 1950-12-01 14:00:01  blood 2424
#> 54   54.1     12 1950 1950-12-01 14:00:01   bone 2424
#> 55   59.9      1 1951 1951-01-01 00:00:00  blood 2425
#> 56   59.9      1 1951 1951-01-01 00:00:00   bone 2425
#> 57   59.9      2 1951 1951-01-31 10:00:01  blood 2426
#> 58   59.9      2 1951 1951-01-31 10:00:01   bone 2426
#> 59   59.9      3 1951 1951-03-02 20:00:01  blood 2427
#> 60   59.9      3 1951 1951-03-02 20:00:01   bone 2427
#> 61   92.9      4 1951 1951-04-02 06:00:00  blood 2428
#> 62   92.9      4 1951 1951-04-02 06:00:00   bone 2428
#> 63  108.5      5 1951 1951-05-02 16:00:01  blood 2429
#> 64  108.5      5 1951 1951-05-02 16:00:01   bone 2429
#> 65  100.6      6 1951 1951-06-02 02:00:01  blood 2430
#> 66  100.6      6 1951 1951-06-02 02:00:01   bone 2430
#> 67   61.5      7 1951 1951-07-02 12:00:00  blood 2431
#> 68   61.5      7 1951 1951-07-02 12:00:00   bone 2431
#> 69   61.0      8 1951 1951-08-01 22:00:01  blood 2432
#> 70   61.0      8 1951 1951-08-01 22:00:01   bone 2432
#> 71   83.1      9 1951 1951-09-01 08:00:01  blood 2433
#> 72   83.1      9 1951 1951-09-01 08:00:01   bone 2433
#> 73   51.6     10 1951 1951-10-01 18:00:00  blood 2434
#> 74   51.6     10 1951 1951-10-01 18:00:00   bone 2434
#> 75   52.4     11 1951 1951-11-01 04:00:01  blood 2435
#> 76   52.4     11 1951 1951-11-01 04:00:01   bone 2435
#> 77   45.8     12 1951 1951-12-01 14:00:01  blood 2436
#> 78   45.8     12 1951 1951-12-01 14:00:01   bone 2436
#> 79   40.7      1 1952 1952-01-01 00:00:00  blood 2437
#> 80   40.7      1 1952 1952-01-01 00:00:00   bone 2437
#> 81   22.7      2 1952 1952-01-31 12:00:01  blood 2438
#> 82   22.7      2 1952 1952-01-31 12:00:01   bone 2438
#> 83   22.0      3 1952 1952-03-02 00:00:01  blood 2439
#> 84   22.0      3 1952 1952-03-02 00:00:01   bone 2439
#> 85   29.1      4 1952 1952-04-01 12:00:00  blood 2440
#> 86   29.1      4 1952 1952-04-01 12:00:00   bone 2440
#> 87   23.4      5 1952 1952-05-02 00:00:01  blood 2441
#> 88   23.4      5 1952 1952-05-02 00:00:01   bone 2441
#> 89   36.4      6 1952 1952-06-01 12:00:01  blood 2442
#> 90   36.4      6 1952 1952-06-01 12:00:01   bone 2442
#> 91   39.3      7 1952 1952-07-02 00:00:00  blood 2443
#> 92   39.3      7 1952 1952-07-02 00:00:00   bone 2443
#> 93   54.9      8 1952 1952-08-01 12:00:01  blood 2444
#> 94   54.9      8 1952 1952-08-01 12:00:01   bone 2444
#> 95   28.2      9 1952 1952-09-01 00:00:01  blood 2445
#> 96   28.2      9 1952 1952-09-01 00:00:01   bone 2445
#> 97   23.8     10 1952 1952-10-01 12:00:00  blood 2446
#> 98   23.8     10 1952 1952-10-01 12:00:00   bone 2446
#> 99   22.1     11 1952 1952-11-01 00:00:01  blood 2447
#> 100  22.1     11 1952 1952-11-01 00:00:01   bone 2447
#> 101  34.3     12 1952 1952-12-01 12:00:01  blood 2448
#> 102  34.3     12 1952 1952-12-01 12:00:01   bone 2448
#> 103  26.5      1 1953 1953-01-01 00:00:00  blood 2449
#> 104  26.5      1 1953 1953-01-01 00:00:00   bone 2449
#> 105   3.9      2 1953 1953-01-31 10:00:01  blood 2450
#> 106   3.9      2 1953 1953-01-31 10:00:01   bone 2450
#> 107  10.0      3 1953 1953-03-02 20:00:01  blood 2451
#> 108  10.0      3 1953 1953-03-02 20:00:01   bone 2451
#> 109  27.8      4 1953 1953-04-02 06:00:00  blood 2452
#> 110  27.8      4 1953 1953-04-02 06:00:00   bone 2452
#> 111  12.5      5 1953 1953-05-02 16:00:01  blood 2453
#> 112  12.5      5 1953 1953-05-02 16:00:01   bone 2453
#> 113  21.8      6 1953 1953-06-02 02:00:01  blood 2454
#> 114  21.8      6 1953 1953-06-02 02:00:01   bone 2454
#> 115   8.6      7 1953 1953-07-02 12:00:00  blood 2455
#> 116   8.6      7 1953 1953-07-02 12:00:00   bone 2455
#> 117  23.5      8 1953 1953-08-01 22:00:01  blood 2456
#> 118  23.5      8 1953 1953-08-01 22:00:01   bone 2456
#> 119  19.3      9 1953 1953-09-01 08:00:01  blood 2457
#> 120  19.3      9 1953 1953-09-01 08:00:01   bone 2457
#> 121   8.2     10 1953 1953-10-01 18:00:00  blood 2458
#> 122   8.2     10 1953 1953-10-01 18:00:00   bone 2458
#> 123   1.6     11 1953 1953-11-01 04:00:01  blood 2459
#> 124   1.6     11 1953 1953-11-01 04:00:01   bone 2459
#> 125   2.5     12 1953 1953-12-01 14:00:01  blood 2460
#> 126   2.5     12 1953 1953-12-01 14:00:01   bone 2460
#> 127   0.2      1 1954 1954-01-01 00:00:00  blood 2461
#> 128   0.2      1 1954 1954-01-01 00:00:00   bone 2461
#> 129   0.5      2 1954 1954-01-31 10:00:01  blood 2462
#> 130   0.5      2 1954 1954-01-31 10:00:01   bone 2462
#> 131  10.9      3 1954 1954-03-02 20:00:01  blood 2463
#> 132  10.9      3 1954 1954-03-02 20:00:01   bone 2463
#> 133   1.8      4 1954 1954-04-02 06:00:00  blood 2464
#> 134   1.8      4 1954 1954-04-02 06:00:00   bone 2464
#> 135   0.8      5 1954 1954-05-02 16:00:01  blood 2465
#> 136   0.8      5 1954 1954-05-02 16:00:01   bone 2465
#> 137   0.2      6 1954 1954-06-02 02:00:01  blood 2466
#> 138   0.2      6 1954 1954-06-02 02:00:01   bone 2466
#> 139   4.8      7 1954 1954-07-02 12:00:00  blood 2467
#> 140   4.8      7 1954 1954-07-02 12:00:00   bone 2467
#> 141   8.4      8 1954 1954-08-01 22:00:01  blood 2468
#> 142   8.4      8 1954 1954-08-01 22:00:01   bone 2468
#> 143   1.5      9 1954 1954-09-01 08:00:01  blood 2469
#> 144   1.5      9 1954 1954-09-01 08:00:01   bone 2469
#> 145   7.0     10 1954 1954-10-01 18:00:00  blood 2470
#> 146   7.0     10 1954 1954-10-01 18:00:00   bone 2470
#> 147   9.2     11 1954 1954-11-01 04:00:01  blood 2471
#> 148   9.2     11 1954 1954-11-01 04:00:01   bone 2471
#> 149   7.6     12 1954 1954-12-01 14:00:01  blood 2472
#> 150   7.6     12 1954 1954-12-01 14:00:01   bone 2472
#> 151  23.1      1 1955 1955-01-01 00:00:00  blood 2473
#> 152  23.1      1 1955 1955-01-01 00:00:00   bone 2473
#> 153  20.8      2 1955 1955-01-31 10:00:01  blood 2474
#> 154  20.8      2 1955 1955-01-31 10:00:01   bone 2474
#> 155   4.9      3 1955 1955-03-02 20:00:01  blood 2475
#> 156   4.9      3 1955 1955-03-02 20:00:01   bone 2475
#> 157  11.3      4 1955 1955-04-02 06:00:00  blood 2476
#> 158  11.3      4 1955 1955-04-02 06:00:00   bone 2476
#> 159  28.9      5 1955 1955-05-02 16:00:01  blood 2477
#> 160  28.9      5 1955 1955-05-02 16:00:01   bone 2477
#> 161  31.7      6 1955 1955-06-02 02:00:01  blood 2478
#> 162  31.7      6 1955 1955-06-02 02:00:01   bone 2478
#> 163  26.7      7 1955 1955-07-02 12:00:00  blood 2479
#> 164  26.7      7 1955 1955-07-02 12:00:00   bone 2479
#> 165  40.7      8 1955 1955-08-01 22:00:01  blood 2480
#> 166  40.7      8 1955 1955-08-01 22:00:01   bone 2480
#>  [ reached 'max' / getOption("max.print") -- omitted 680 rows ]
#> 

# An xts object example
library(xts)
#> Loading required package: zoo
#> 
#> Attaching package: ‘zoo’
#> The following objects are masked from ‘package:base’:
#> 
#>     as.Date, as.Date.numeric
dates <- seq(as.Date("2001-05-01"), length=30, by="quarter")
data  <- cbind(c(gas = rpois(30, cumprod(1+rnorm(30, mean = 0.01, sd = 0.001)))),
c(oil = rpois(30, cumprod(1+rnorm(30, mean = 0.01, sd = 0.001)))))
series <- xts(x = data, order.by = dates)
colnames(series) <- c('gas', 'oil')
head(series)
#>            gas oil
#> 2001-05-01   1   2
#> 2001-08-01   0   0
#> 2001-11-01   2   3
#> 2002-02-01   2   3
#> 2002-05-01   1   3
#> 2002-08-01   1   1
series_to_mvgam(series, freq = 4, train_prop = 0.85)
#> $data_train
#>    y season year       date series time
#> 1  1      2 2001 2001-05-01    gas    1
#> 2  2      2 2001 2001-05-01    oil    1
#> 3  0      3 2001 2001-08-01    gas    2
#> 4  0      3 2001 2001-08-01    oil    2
#> 5  2      4 2001 2001-11-01    gas    3
#> 6  3      4 2001 2001-11-01    oil    3
#> 7  2      1 2002 2002-02-01    gas    4
#> 8  3      1 2002 2002-02-01    oil    4
#> 9  1      2 2002 2002-05-01    gas    5
#> 10 3      2 2002 2002-05-01    oil    5
#> 11 1      3 2002 2002-08-01    gas    6
#> 12 1      3 2002 2002-08-01    oil    6
#> 13 2      4 2002 2002-11-01    gas    7
#> 14 0      4 2002 2002-11-01    oil    7
#> 15 3      1 2003 2003-02-01    gas    8
#> 16 3      1 2003 2003-02-01    oil    8
#> 17 2      2 2003 2003-05-01    gas    9
#> 18 0      2 2003 2003-05-01    oil    9
#> 19 0      3 2003 2003-08-01    gas   10
#> 20 1      3 2003 2003-08-01    oil   10
#> 21 0      4 2003 2003-11-01    gas   11
#> 22 1      4 2003 2003-11-01    oil   11
#> 23 2      1 2004 2004-02-01    gas   12
#> 24 2      1 2004 2004-02-01    oil   12
#> 25 1      2 2004 2004-05-01    gas   13
#> 26 1      2 2004 2004-05-01    oil   13
#> 27 1      3 2004 2004-08-01    gas   14
#> 28 2      3 2004 2004-08-01    oil   14
#> 29 2      4 2004 2004-11-01    gas   15
#> 30 0      4 2004 2004-11-01    oil   15
#> 31 0      1 2005 2005-02-01    gas   16
#> 32 2      1 2005 2005-02-01    oil   16
#> 33 2      2 2005 2005-05-01    gas   17
#> 34 1      2 2005 2005-05-01    oil   17
#> 35 1      3 2005 2005-08-01    gas   18
#> 36 1      3 2005 2005-08-01    oil   18
#> 37 1      4 2005 2005-11-01    gas   19
#> 38 2      4 2005 2005-11-01    oil   19
#> 39 2      1 2006 2006-02-01    gas   20
#> 40 2      1 2006 2006-02-01    oil   20
#> 41 1      2 2006 2006-05-01    gas   21
#> 42 0      2 2006 2006-05-01    oil   21
#> 43 0      3 2006 2006-08-01    gas   22
#> 44 1      3 2006 2006-08-01    oil   22
#> 45 0      4 2006 2006-11-01    gas   23
#> 46 0      4 2006 2006-11-01    oil   23
#> 47 1      1 2007 2007-02-01    gas   24
#> 48 2      1 2007 2007-02-01    oil   24
#> 49 2      2 2007 2007-05-01    gas   25
#> 50 0      2 2007 2007-05-01    oil   25
#> 
#> $data_test
#>    y season year       date series time
#> 1  2      3 2007 2007-08-01    gas   26
#> 2  2      3 2007 2007-08-01    oil   26
#> 3  1      4 2007 2007-11-01    gas   27
#> 4  0      4 2007 2007-11-01    oil   27
#> 5  1      1 2008 2008-02-01    gas   28
#> 6  0      1 2008 2008-02-01    oil   28
#> 7  1      2 2008 2008-05-01    gas   29
#> 8  1      2 2008 2008-05-01    oil   29
#> 9  2      3 2008 2008-08-01    gas   30
#> 10 1      3 2008 2008-08-01    oil   30
#>