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] -1.330378
#> 
#> $fitted
#>  [1]  0.3729975493 -0.2828969861  0.0009805367 -0.2364487318  0.2858778215
#>  [6]  0.4862808210 -0.0670024221 -0.3817168621 -0.0852205697  0.0268782836
#> [11] -0.1236577085  0.4529835552 -0.2154701178 -0.7756802973 -0.4020400582
#> [16] -0.5556282497  0.0446177412  0.3170185389 -0.1701885455 -0.4247484660
#> [21] -0.0740192936  0.0863908002 -0.0217555908  0.5913536347 -0.0465537159
#> [26] -0.5821392126 -0.1897959298 -0.3306027172  0.2765030384  0.5498419614
#> [31]  0.0576513630 -0.2078137111  0.1260886684  0.2637503300  0.1269338673
#> [36]  0.7054513816  0.0270306805 -0.5549898060 -0.2150031526 -0.4140882088
#> [41]  0.1288176388  0.3320350142 -0.2361987712 -0.5836286716 -0.3376127578
#> [46] -0.2937592014 -0.5303054087 -0.0574392783 -0.8474330028 -1.5469481521
#> 
#> $trend
#>  [1]  0.405095761  0.306320942  0.218233904  0.140341177  0.072149292
#>  [6]  0.013164777 -0.037105836 -0.079156018 -0.113479238 -0.140568968
#> [11] -0.160918675 -0.175021831 -0.183371906 -0.186462369 -0.184786691
#> [16] -0.178838341 -0.169110789 -0.156097505 -0.140291959 -0.122187622
#> [21] -0.102277962 -0.081056451 -0.059016558 -0.036651752 -0.014455504
#> [26]  0.007078716  0.027457438  0.046187192  0.062774509  0.076725918
#> [31]  0.087547949  0.094747133  0.097830000  0.096303079  0.089672901
#> [36]  0.077445995  0.059128892  0.034228122  0.002250215 -0.037298300
#> [41] -0.084910891 -0.141081029 -0.206302185 -0.281067827 -0.365871427
#> [46] -0.461206453 -0.567566375 -0.685444665 -0.815334791 -0.957730224
#> 
#> $seasonal
#>  [1] -0.03209821 -0.58921793 -0.21725337 -0.37678991  0.21372853  0.47311604
#>  [7] -0.02989659 -0.30256084  0.02825867  0.16744725  0.03726097  0.62800539
#> [13] -0.03209821 -0.58921793 -0.21725337 -0.37678991  0.21372853  0.47311604
#> [19] -0.02989659 -0.30256084  0.02825867  0.16744725  0.03726097  0.62800539
#> [25] -0.03209821 -0.58921793 -0.21725337 -0.37678991  0.21372853  0.47311604
#> [31] -0.02989659 -0.30256084  0.02825867  0.16744725  0.03726097  0.62800539
#> [37] -0.03209821 -0.58921793 -0.21725337 -0.37678991  0.21372853  0.47311604
#> [43] -0.02989659 -0.30256084  0.02825867  0.16744725  0.03726097  0.62800539
#> [49] -0.03209821 -0.58921793
#> 
#> $theta_trend
#>            X1            X2            X3            X4 
#>  4.050958e-01 -1.042832e-01  5.590625e-03 -8.224499e-05 
#> 
#> $theta_seasonal
#>          X5          X6          X7          X8          X9         X10 
#> -0.13746744 -0.05455094 -0.35115662  0.03683697  0.01711512  0.06996300 
#>         X11         X12         X13         X14 
#> -0.22414412 -0.06783436 -0.11753602 -0.01651287 
#> 
#> $r2
#> [1] 0.1805387
#> 
#> $n
#> [1] 50
#> 
#> $horizon
#> [1] 1
#> 
#> $method
#> [1] "N-BEATS basis: poly(P=3) + Fourier(H=5, period=12)"
#>