Class: Daru::Vector
- Inherits:
-
Object
- Object
- Daru::Vector
- Includes:
- Statsample::TimeSeries::Pacf
- Defined in:
- lib/statsample-timeseries/daru_monkeys.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#ar(n = 1500, k = 1) ⇒ Object
Autoregressive estimation Generates AR(k) series for the calling timeseries by yule walker.
-
#pacf(max_lags = nil, method = :yw) ⇒ Object
Partial Autocorrelation Generates partial autocorrelation series for a timeseries.
Methods included from Statsample::TimeSeries::Pacf
diag, levinson_durbin, pacf_yw, solve_matrix, toeplitz, yule_walker
Instance Method Details
#ar(n = 1500, k = 1) ⇒ Object
Autoregressive estimation
Generates AR(k) series for the calling timeseries by yule walker.
Parameters
-
n: integer, (default = 1500) number of observations for AR.
-
k: integer, (default = 1) order of AR process.
Returns
Array constituting estimated AR series.
59 60 61 62 63 |
# File 'lib/statsample-timeseries/daru_monkeys.rb', line 59 def ar(n = 1500, k = 1) series = Statsample::TimeSeries.arima #series = Statsample::TimeSeries::ARIMA.new series.yule_walker(self, n, k) end |
#pacf(max_lags = nil, method = :yw) ⇒ Object
Partial Autocorrelation
Generates partial autocorrelation series for a timeseries
Arguments
-
max_lags: integer, optional - provide number of lags
-
method: string. Default: ‘yw’.
* *yw*: For yule-walker algorithm unbiased approach * *mle*: For Maximum likelihood algorithm approach * *ld*: Forr Levinson-Durbin recursive approach
Returns
array of pacf
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/statsample-timeseries/daru_monkeys.rb', line 34 def pacf(max_lags = nil, method = :yw) helper = Statsample::TimeSeries::Pacf method = method.downcase.to_sym max_lags ||= (10 * Math.log10(size)).to_i if method == :yw or method == :mle helper.pacf_yw(self, max_lags, method.to_s) elsif method == :ld series = self.acvf helper.levinson_durbin(series, max_lags, true)[2] else raise "Method presents for pacf are 'yw', 'mle' or 'ld'" end end |