Implements grey prediction models for time series forecasting:
GM11 applies the GM(1,1) model with level ratio test.
GM1N applies the GM(1,N) model with multiple related factors.
DGM21 applies the DGM(2,1) model for second-order dynamics.
verhulst applies the Verhulst model for logistic growth.
Value
For GM11: List with fitted values (fitted), next prediction (pnext), prediction function (f), matrix (mat), parameters (u), level ratios (lambda), and range (rng).
For GM1N: List with fitted values (fitted), next prediction (pred, NULL unless new_data is supplied), posterior variance ratio (C), small error probability (P), and prediction function (f).
For DGM21, verhulst: List with fitted values (fitted), next prediction (pnext), prediction function (f), matrix (mat), and parameters (u).
Details
For GM11, the returned prediction function f(k) implements the inverse
accumulated generating operation (IAGO) formula and is valid for k >= 2;
fitted[1] always equals the first original value X[1].
Examples
# Sample time series for GM11, DGM21, Verhulst
x = c(100, 120, 145, 175, 210)
# GM11
result = GM11(x)
#> Level ratio test passed!
result$fitted # Fitted values
#> [1] 100.0000 119.9184 144.3784 173.8275 209.2834
result$pnext # Next prediction
#> [1] 251.9713
result$f(6:8) # Predict next 3 periods
#> [1] 251.9713 303.3663 365.2444
# DGM21
x = c(2.874,3.278,3.39,3.679,3.77,3.8)
result = DGM21(x)
result$fitted # Fitted values
#> [1] 2.874000 3.086001 3.408835 3.620105 3.758366 3.848848
result$pnext # Next prediction
#> [1] 3.908061
result$f(6:8) # Predict next 3 periods
#> [1] 20.59616 24.50422 28.45103
# Verhulst
x = c(4.93,2.33,3.87,4.35,6.63,7.15,5.37,6.39,7.81,8.35)
result = verhulst(x)
result$fitted # Fitted values
#> [1] 4.930000 1.952177 2.635709 3.481640 4.468640 5.528334 6.536384 7.326754
#> [9] 7.737430 7.673378
result$pnext # Next prediction
#> [1] 7.149904
result$f(6:8) # Predict next 3 periods
#> [1] 22.99650 29.53288 36.85964
# Sample data for GM1N
data = data.frame(
factor1 = c(50, 55, 60, 65, 70),
factor2 = c(20, 22, 25, 28, 30),
output = c(100, 120, 145, 175, 210)
)
result = GM1N(data)
#> Smoothness check: Passed
#> Level ratio check: Passed
result$fitted
#> [1] 100.0000 111.3703 195.8204 231.7904 301.9012