Skip to contents

N-BEATS-style polynomial + Fourier basis-expansion forecasting

Usage

morie_nbeats_basis(x, horizon = 1, n_trend = 3, n_season = 5, period = 12)

Arguments

x

Numeric history.

horizon

Forecast horizon. Default 1.

n_trend

Polynomial-trend degree. Default 3.

n_season

Number of Fourier harmonics. Default 5.

period

Seasonal period. Default 12.

Value

Named list with \(forecast, fitted, trend, seasonal, theta_trend, theta_seasonal, r2, n, horizon, method\).

Examples

set.seed(1)
morie_nbeats_basis(x = rnorm(50))
#> $forecast
#> [1] 0.9645875
#> 
#> $fitted
#>  [1] -0.5108995264 -0.3285830578  0.2084724321  0.3699176373 -0.1144617669
#>  [6]  0.2849235095  0.8485858530  0.6850209534  0.3174139211  0.1647639152
#> [11]  0.1457925131 -0.1063367201 -0.1983984231 -0.0879449449  0.3819396527
#> [16]  0.4809060638 -0.0612600363  0.2850306423  0.8002904861  0.5930151850
#> [21]  0.1863898494 -0.0005863618 -0.0491918709 -0.3262631130 -0.4385747267
#> [26] -0.3436790611  0.1153398221  0.2081326168 -0.3355150014  0.0139862572
#> [31]  0.5371487792  0.3424682544 -0.0468702068 -0.2118674453 -0.2338018837
#> [36] -0.4795099568 -0.5557663035 -0.4201232727  0.0843350738  0.2272594301
#> [41] -0.2615645284  0.1474524880  0.7348228659  0.6090422952  0.2932958863
#> [46]  0.2065827982  0.2676246084  0.1095848820  0.1256889802  0.3583845540
#> 
#> $trend
#>  [1] -0.053205899  0.010432577  0.065931927  0.113683156  0.154077275
#>  [6]  0.187505291  0.214358212  0.235027046  0.249902802  0.259376487
#> [11]  0.263839111  0.263681680  0.259295204  0.251070690  0.239399147
#> [16]  0.224671583  0.207279006  0.187612423  0.166062845  0.143021277
#> [21]  0.118878730  0.094026210  0.068854727  0.043755287  0.019118900
#> [26] -0.004663426 -0.027200684 -0.048101864 -0.066975960 -0.083431962
#> [31] -0.097078862 -0.107525653 -0.114381326 -0.117254873 -0.115755286
#> [36] -0.109491557 -0.098072676 -0.081107638 -0.058205432 -0.028975051
#> [41]  0.006974513  0.050034269  0.100595224  0.159048388  0.225784767
#> [46]  0.301195370  0.385671206  0.479603282  0.583382607  0.697400189
#> 
#> $seasonal
#>  [1] -0.45769363 -0.33901564  0.14254051  0.25623448 -0.26853904  0.09741822
#>  [7]  0.63422764  0.44999391  0.06751112 -0.09461257 -0.11804660 -0.37001840
#> [13] -0.45769363 -0.33901564  0.14254051  0.25623448 -0.26853904  0.09741822
#> [19]  0.63422764  0.44999391  0.06751112 -0.09461257 -0.11804660 -0.37001840
#> [25] -0.45769363 -0.33901564  0.14254051  0.25623448 -0.26853904  0.09741822
#> [31]  0.63422764  0.44999391  0.06751112 -0.09461257 -0.11804660 -0.37001840
#> [37] -0.45769363 -0.33901564  0.14254051  0.25623448 -0.26853904  0.09741822
#> [43]  0.63422764  0.44999391  0.06751112 -0.09461257 -0.11804660 -0.37001840
#> [49] -0.45769363 -0.33901564
#> 
#> $theta_trend
#>            X1            X2            X3            X4 
#> -5.320590e-02  6.783838e-02 -4.265068e-03  6.516803e-05 
#> 
#> $theta_seasonal
#>           X5           X6           X7           X8           X9          X10 
#>  0.020784611 -0.344545775  0.141481952  0.003728026 -0.112069996 -0.219573850 
#>          X11          X12          X13          X14 
#> -0.030752390  0.084538981  0.042568919  0.018158990 
#> 
#> $r2
#> [1] 0.1846192
#> 
#> $n
#> [1] 50
#> 
#> $horizon
#> [1] 1
#> 
#> $method
#> [1] "N-BEATS basis: poly(P=3) + Fourier(H=5, period=12)"
#>