class TeaLeaves::NaiveForecast
A naive model just uses the current period's value as the prediction for the next period, i.e. F_t+1 = Y_t
Public Class Methods
new(time_series)
click to toggle source
Creates a naive forecasting model for the given time series.
# File lib/tealeaves/naive_forecast.rb, line 8 def initialize(time_series) @time_series = time_series @one_step_ahead_forecasts = [nil] + time_series @one_step_ahead_forecasts.pop end
Public Instance Methods
predict(n=nil)
click to toggle source
Returns a prediction for the next period, or for the next n periods.
# File lib/tealeaves/naive_forecast.rb, line 22 def predict(n=nil) if n.nil? @time_series.last else [@time_series.last] * n end end
u_statistic()
click to toggle source
Returns Thiel's U Statistic. By definition, this is 1 for the Naive method.
# File lib/tealeaves/naive_forecast.rb, line 16 def u_statistic 1 end