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

morie_nbeats_basis(x = rnorm(50))
#> $forecast
#> [1] 0.6912181
#> 
#> $fitted
#>  [1]  0.831370367  0.919255250  0.225998232  0.234626067  0.065647877
#>  [6] -0.017010541 -0.221997486 -0.090825385  0.492899815 -0.104516406
#> [11] -0.244051663  0.184798926  0.774405624  0.843498497  0.133410576
#> [16]  0.127168615 -0.054718264 -0.148324265 -0.362297686 -0.238150955
#> [21]  0.340509983 -0.260009393 -0.400686699  0.028982948  0.621369810
#> [26]  0.695203955 -0.008181588 -0.005760064 -0.177022352 -0.258042654
#> [31] -0.457469270 -0.316814626  0.280315330 -0.299773921 -0.418059994
#> [36]  0.035961992  0.654662300  0.756770998  0.083621114  0.118239404
#> [41] -0.018865010 -0.063766333 -0.225112862 -0.044417025  0.594715231
#> [46]  0.058589388 -0.013772172  0.488135434  1.156682470  1.310599001
#> 
#> $trend
#>  [1]  0.196156508  0.201969938  0.205318528  0.206365701  0.205274884
#>  [6]  0.202209502  0.197332981  0.190808747  0.182800224  0.173470839
#> [11]  0.162984017  0.151503184  0.139191765  0.126213186  0.112730872
#> [16]  0.098908249  0.084908742  0.070895778  0.057032781  0.043483177
#> [21]  0.030410392  0.017977852  0.006348981 -0.004312794 -0.013844049
#> [26] -0.022081357 -0.028861292 -0.034020430 -0.037395345 -0.038822611
#> [31] -0.038138803 -0.035180494 -0.029784260 -0.021786675 -0.011024314
#> [36]  0.002666250  0.019448441  0.039485686  0.062941410  0.089979038
#> [41]  0.120761996  0.155453710  0.194217605  0.237217107  0.284615641
#> [46]  0.336576633  0.393263508  0.454839692  0.521468611  0.593313689
#> 
#> $seasonal
#>  [1]  0.63521386  0.71728531  0.02067970  0.02826037 -0.13962701 -0.21922004
#>  [7] -0.41933047 -0.28163413  0.31009959 -0.27798725 -0.40703568  0.03329574
#> [13]  0.63521386  0.71728531  0.02067970  0.02826037 -0.13962701 -0.21922004
#> [19] -0.41933047 -0.28163413  0.31009959 -0.27798725 -0.40703568  0.03329574
#> [25]  0.63521386  0.71728531  0.02067970  0.02826037 -0.13962701 -0.21922004
#> [31] -0.41933047 -0.28163413  0.31009959 -0.27798725 -0.40703568  0.03329574
#> [37]  0.63521386  0.71728531  0.02067970  0.02826037 -0.13962701 -0.21922004
#> [43] -0.41933047 -0.28163413  0.31009959 -0.27798725 -0.40703568  0.03329574
#> [49]  0.63521386  0.71728531
#> 
#> $theta_trend
#>            X1            X2            X3            X4 
#>  1.961565e-01  7.100326e-03 -1.314133e-03  2.723759e-05 
#> 
#> $theta_seasonal
#>           X5           X6           X7           X8           X9          X10 
#>  0.110064529  0.309984124  0.216364534  0.116402568  0.073359341  0.268562148 
#>          X11          X12          X13          X14 
#> -0.036931148 -0.008460872  0.116418618 -0.051274109 
#> 
#> $r2
#> [1] 0.2495414
#> 
#> $n
#> [1] 50
#> 
#> $horizon
#> [1] 1
#> 
#> $method
#> [1] "N-BEATS basis: poly(P=3) + Fourier(H=5, period=12)"
#>