lib/more_math/sequence.rb
# This method tries to detect autocorrelation with the Ljung-Box
# statistic. If enough lags can be considered it returns a hash with
# results, otherwise nil is returned. The keys are
# :lags:: the number of lags,
# :alpha_level:: the alpha level for the test,
# :q:: the value of the ljung_box_statistic,
# :p:: the p-value computed, if p is higher than alpha no correlation was detected,
# :detected:: true if a correlation was found.
This method tries to detect autocorrelation with the Ljung-Box
statistic. If enough lags can be considered it returns a hash with
results, otherwise nil is returned.
This method tries to detect autocorrelation with the Ljung - Box statistic . If enough lags can be considered it returns a hash with results otherwise nil is returned .
def detect_autocorrelation(lags = 20, alpha_level = 0.05)
      if q = ljung_box_statistic(lags)
        p = ChiSquareDistribution.new(lags).probability(q)
        return {
          :lags         => lags,
          :alpha_level  => alpha_level,
          :q            => q,
          :p            => p,
          :detected     => p >= 1 - alpha_level,
        }
      end
    end
def detect_autocorrelation ( lags = 20 , alpha_level = 0.05 ) if q = ljung_box_statistic ( lags ) p = ChiSquareDistribution . new ( lags ) . probability ( q ) return { :lags => lags , :alpha_level => alpha_level , :q => q , :p => p , :detected => p >= 1 - alpha_level , } end end
This method tries to detect autocorrelation with the Ljung-Box
statistic.
This method tries to detect autocorrelation with the Ljung - Box statistic .
lags
<not_specific>
alpha_level
<not_specific>