statsample-timeseries 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -18,5 +18,4 @@ group :development do
18
18
  gem "bio", ">= 1.4.2"
19
19
  gem "rdoc", "~> 3.12"
20
20
  gem 'mocha', '~> 0.14.0'
21
- gem 'gsl'
22
21
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -36,8 +36,12 @@ module Statsample
36
36
  if i > 0
37
37
  ts = ts.diff(i).reject { |x| x.nil? }.to_ts
38
38
  end
39
- filter = Arima::KalmanFilter.new(ts, p, i, q)
40
- filter
39
+ if Statsample.has_gsl?
40
+ filter = Arima::KalmanFilter.new(ts, p, i, q)
41
+ filter
42
+ else
43
+ raise("GSL not available. Install GSL and rb-gsl first")
44
+ end
41
45
  end
42
46
 
43
47
  def ar(p)
@@ -5,7 +5,7 @@ module Statsample
5
5
 
6
6
  class KalmanFilter
7
7
  include Statsample::TimeSeries
8
- include GSL::MultiMin
8
+ include GSL::MultiMin if Statsample.has_gsl?
9
9
 
10
10
  #timeseries object
11
11
  attr_accessor :ts
@@ -7,24 +7,26 @@ class StatsampleArimaKSTestCase < MiniTest::Unit::TestCase
7
7
  setup do
8
8
  @s = [-1.16025577,0.64758021,0.77158601,0.14989543,2.31358162,3.49213868,1.14826956,0.58169457,-0.30813868,-0.34741084,-1.41175595,0.06040081, -0.78230232,0.86734837,0.95015787,-0.49781397,0.53247330,1.56495187,0.30936619,0.09750217,1.09698829,-0.81315490,-0.79425607,-0.64568547,-1.06460320,1.24647894,0.66695937,1.50284551,1.17631218,1.64082872,1.61462736,0.06443761,-0.17583741,0.83918339,0.46610988,-0.54915270,-0.56417108,-1.27696654,0.89460084,1.49970338,0.24520493,0.26249138,-1.33744834,-0.57725961,1.55819543,1.62143157,0.44421891,-0.74000084 ,0.57866347,3.51189333,2.39135077,1.73046244,1.81783890,0.21454040,0.43520890,-1.42443856,-2.72124685,-2.51313877,-1.20243091,-1.44268002 ,-0.16777305,0.05780661,2.03533992,0.39187242,0.54987983,0.57865693,-0.96592469,-0.93278473,-0.75962671,-0.63216906,1.06776183, 0.17476059 ,0.06635860,0.94906227,2.44498583,-1.04990407,-0.88440073,-1.99838258,-1.12955558,-0.62654882,-1.36589161,-2.67456821,-0.97187696, -0.84431782 ,-0.10051809,0.54239549,1.34622861,1.25598105,0.19707759,3.29286114,3.52423499,1.69146333,-0.10150024,0.45222903,-0.01730516, -0.49828727, -1.18484684,-1.09531773,-1.17190808,0.30207662].to_ts
9
9
  end
10
- context "passed through the Kalman Filter" do
11
- setup do
12
- @kf=Statsample::TimeSeries::ARIMA.ks(@s,1,0,0)
13
- end
14
- should "return correct object" do
15
- assert_instance_of Statsample::TimeSeries::Arima::KalmanFilter, @kf
16
- end
17
- should "return correct parameters" do
18
- assert_equal @kf.p,1
19
- assert_equal @kf.q,0
20
- assert_equal @kf.i,0
21
- end
22
- should "return correct ar estimators" do
23
- assert_equal @kf.ar.length,1
24
- assert_in_delta @kf.ar[0], 0.700 #0.564
25
- end
26
- should "return correct ma estimators" do
27
- assert_equal @kf.ma.length,0
10
+ if Statsample.has_gsl?
11
+ context "passed through the Kalman Filter" do
12
+ setup do
13
+ @kf=Statsample::TimeSeries::ARIMA.ks(@s,1,0,0)
14
+ end
15
+ should "return correct object" do
16
+ assert_instance_of Statsample::TimeSeries::Arima::KalmanFilter, @kf
17
+ end
18
+ should "return correct parameters" do
19
+ assert_equal @kf.p,1
20
+ assert_equal @kf.q,0
21
+ assert_equal @kf.i,0
22
+ end
23
+ should "return correct ar estimators" do
24
+ assert_equal @kf.ar.length,1
25
+ assert_in_delta @kf.ar[0], 0.700 #0.564
26
+ end
27
+ should "return correct ma estimators" do
28
+ assert_equal @kf.ma.length,0
29
+ end
28
30
  end
29
31
  end
30
32
  context "passed through the Kalman Filter with AR(0.564)" do
@@ -66,24 +68,26 @@ class StatsampleArimaKSTestCase < MiniTest::Unit::TestCase
66
68
  setup do
67
69
  @s = [-1.16025577,0.64758021,0.77158601,0.14989543,2.31358162,3.49213868,1.14826956,0.58169457,-0.30813868,-0.34741084,-1.41175595,0.06040081, -0.78230232,0.86734837,0.95015787,-0.49781397,0.53247330,1.56495187,0.30936619,0.09750217,1.09698829,-0.81315490,-0.79425607,-0.64568547,-1.06460320,1.24647894,0.66695937,1.50284551,1.17631218,1.64082872,1.61462736,0.06443761,-0.17583741,0.83918339,0.46610988,-0.54915270,-0.56417108,-1.27696654,0.89460084,1.49970338,0.24520493,0.26249138,-1.33744834,-0.57725961,1.55819543,1.62143157,0.44421891,-0.74000084 ,0.57866347,3.51189333,2.39135077,1.73046244,1.81783890,0.21454040,0.43520890,-1.42443856,-2.72124685,-2.51313877,-1.20243091,-1.44268002 ,-0.16777305,0.05780661,2.03533992,0.39187242,0.54987983,0.57865693,-0.96592469,-0.93278473,-0.75962671,-0.63216906,1.06776183, 0.17476059 ,0.06635860,0.94906227,2.44498583,-1.04990407,-0.88440073,-1.99838258,-1.12955558,-0.62654882,-1.36589161,-2.67456821,-0.97187696, -0.84431782 ,-0.10051809,0.54239549,1.34622861,1.25598105,0.19707759,3.29286114,3.52423499,1.69146333,-0.10150024,0.45222903,-0.01730516, -0.49828727, -1.18484684,-1.09531773,-1.17190808,0.30207662].to_ts
68
70
  end
69
- context "passed through the Kalman Filter" do
70
- setup do
71
- @kf = Statsample::TimeSeries::ARIMA.ks(@s, 2, 0, 1)
72
- end
71
+ if Statsample.has_gsl?
72
+ context "passed through the Kalman Filter" do
73
+ setup do
74
+ @kf = Statsample::TimeSeries::ARIMA.ks(@s, 2, 0, 1)
75
+ end
73
76
 
74
- should "return correct parameters" do
75
- assert_equal @kf.p, 2
76
- assert_equal @kf.q, 1
77
- assert_equal @kf.i, 0
78
- end
79
- should "return correct AR estimators" do
80
- assert_equal @kf.ar.length, 2
81
- assert_in_delta @kf.ar[0], 0.45, 0.01
82
- assert_in_delta @kf.ar[1], 0.016, 0.01
83
- end
84
- should "return correct ma estimators" do
85
- assert_equal @kf.ma.length, 1
86
- assert_in_delta @kf.ma[0], 0.18, 0.01
77
+ should "return correct parameters" do
78
+ assert_equal @kf.p, 2
79
+ assert_equal @kf.q, 1
80
+ assert_equal @kf.i, 0
81
+ end
82
+ should "return correct AR estimators" do
83
+ assert_equal @kf.ar.length, 2
84
+ assert_in_delta @kf.ar[0], 0.45, 0.01
85
+ assert_in_delta @kf.ar[1], 0.016, 0.01
86
+ end
87
+ should "return correct ma estimators" do
88
+ assert_equal @kf.ma.length, 1
89
+ assert_in_delta @kf.ma[0], 0.18, 0.01
90
+ end
87
91
  end
88
92
  end
89
93
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: statsample-timeseries
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -188,22 +188,6 @@ dependencies:
188
188
  - - ~>
189
189
  - !ruby/object:Gem::Version
190
190
  version: 0.14.0
191
- - !ruby/object:Gem::Dependency
192
- name: gsl
193
- requirement: !ruby/object:Gem::Requirement
194
- none: false
195
- requirements:
196
- - - ! '>='
197
- - !ruby/object:Gem::Version
198
- version: '0'
199
- type: :development
200
- prerelease: false
201
- version_requirements: !ruby/object:Gem::Requirement
202
- none: false
203
- requirements:
204
- - - ! '>='
205
- - !ruby/object:Gem::Version
206
- version: '0'
207
191
  description: Statsample-timeseries is an extension to Statsample. It incorporates
208
192
  helpful timeseries functions and modules like ARMA, ARIMA, acf, pacf, lags etc.
209
193
  email: ankurgel@gmail.com
@@ -257,7 +241,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
257
241
  version: '0'
258
242
  segments:
259
243
  - 0
260
- hash: -237853649
244
+ hash: 903118733
261
245
  required_rubygems_version: !ruby/object:Gem::Requirement
262
246
  none: false
263
247
  requirements: