byar 0.1.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +7 -0
- data/CHANGELOG.md +18 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +22 -0
- data/LICENSE +21 -0
- data/README.md +48 -0
- data/Rakefile +9 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/byar.gemspec +30 -0
- data/lib/byar.rb +17 -15
- data/lib/byar/version.rb +3 -0
- metadata +64 -12
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2fd0c8bff9fb044500df5588a2141f9004cf833c245479604e7729ce4e5eec54
|
4
|
+
data.tar.gz: a105c3f6f461e688efa91453ae1f097fbdfbb03ac856ce979bb0dd0cf1c67012
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e8b924e88891495940a40766df300b106b22330c8531d7e1b8537091ba7aa4262004933a2ac816a53a488927211846faec876ae608b431129561d1bdb3873117
|
7
|
+
data.tar.gz: 87e16c808aa686319175fad80ac764535f307a97c1edd6d0f504f44edc67331a5b394e7ab7a4341ff9908d11bd2796fc3ca149536c94d58e8df9fa5f03435fbf
|
data/.gitignore
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## v1.0.0
|
4
|
+
|
5
|
+
* MIT License added
|
6
|
+
|
7
|
+
## v0.1.1
|
8
|
+
|
9
|
+
* Support for passing custom `z_value`
|
10
|
+
|
11
|
+
## v0.1.0
|
12
|
+
|
13
|
+
* Internal refactor
|
14
|
+
* Change version number to follow pre-1.0 semantic versioning
|
15
|
+
|
16
|
+
## v.0.0.1
|
17
|
+
|
18
|
+
* Initial release
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
byar (1.0.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
minitest (5.11.3)
|
10
|
+
rake (10.5.0)
|
11
|
+
|
12
|
+
PLATFORMS
|
13
|
+
ruby
|
14
|
+
|
15
|
+
DEPENDENCIES
|
16
|
+
bundler (~> 1.17)
|
17
|
+
byar!
|
18
|
+
minitest (~> 5.11)
|
19
|
+
rake (~> 10.0)
|
20
|
+
|
21
|
+
BUNDLED WITH
|
22
|
+
1.17.1
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2011-2033 Floris Huetink
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# Byar
|
2
|
+
|
3
|
+
Byar's approximation calculator in Ruby. Useful when working with (H)SMR mortality models used in hospitals worldwide.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'byar'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install byar
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Use `Byar.lower(observed, expected)` and `Byar.upper(observed, expected)` to get 95% Byar confidence intervals.
|
24
|
+
|
25
|
+
Other features:
|
26
|
+
|
27
|
+
* Call `Byar.new` to instantiate an object
|
28
|
+
* Change the `z_value` used (defaults to 1.96, which corresponds to 95% confidence interval)
|
29
|
+
|
30
|
+
Please note that 1 is used as reference point for cases where `observed` == `expected` (not 100).
|
31
|
+
|
32
|
+
## Development
|
33
|
+
|
34
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
35
|
+
|
36
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
37
|
+
|
38
|
+
## Contributing
|
39
|
+
|
40
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/florish/byar. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
41
|
+
|
42
|
+
## License
|
43
|
+
|
44
|
+
Byar is released under the [MIT License](./LICENSE).
|
45
|
+
|
46
|
+
## Code of Conduct
|
47
|
+
|
48
|
+
Everyone interacting in the Byar project’s codebases, issue trackers, and related communication channels is expected to follow the [code of conduct](./CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "byar"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/byar.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "byar/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'byar'
|
7
|
+
spec.version = Byar::VERSION
|
8
|
+
spec.authors = ['Floris Huetink']
|
9
|
+
spec.email = 'floris@avocado.nl'
|
10
|
+
|
11
|
+
spec.summary = "Byar's approximation"
|
12
|
+
spec.description = "Byar's approximation for use in (H)SMR calculations"
|
13
|
+
spec.license = 'MIT'
|
14
|
+
|
15
|
+
spec.homepage = 'https://github.com/florish/byar'
|
16
|
+
spec.required_ruby_version = '>= 1.9.2'
|
17
|
+
|
18
|
+
# Specify which files should be added to the gem when it is released.
|
19
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
20
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
21
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
22
|
+
end
|
23
|
+
spec.bindir = 'exe'
|
24
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
|
+
spec.require_paths = ['lib']
|
26
|
+
|
27
|
+
spec.add_development_dependency 'bundler', '~> 1.17'
|
28
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
29
|
+
spec.add_development_dependency 'minitest', '~> 5.11'
|
30
|
+
end
|
data/lib/byar.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'byar/version'
|
2
|
+
|
1
3
|
##
|
2
4
|
# Byar is a Byar's approximation confidence interval tool with SMR calculation.
|
3
5
|
#
|
@@ -18,23 +20,23 @@ class Byar
|
|
18
20
|
# Z_VALUE defaults to 1.96 for 95% confidence interval
|
19
21
|
#
|
20
22
|
Z_VALUE = 1.96
|
21
|
-
|
23
|
+
|
22
24
|
##
|
23
25
|
# Create new Byar approximation calculator for +obs+ observed cases
|
24
26
|
def initialize(obs)
|
25
27
|
@obs = obs
|
26
28
|
end
|
27
|
-
|
29
|
+
|
28
30
|
##
|
29
31
|
# Calculate SMR-like lower boundary (1 equals SMR of 100)
|
30
|
-
#
|
32
|
+
#
|
31
33
|
# Give +obs+ observed and +exp+ expected values to return a lower SMR-like
|
32
34
|
# boundary value (0 - Infinite)
|
33
35
|
def self.lower(obs, exp)
|
34
36
|
return nil if exp == 0
|
35
37
|
lower_bound(obs).quo(exp)
|
36
38
|
end
|
37
|
-
|
39
|
+
|
38
40
|
##
|
39
41
|
# Calculate SMR-like upper boundary (1 equals SMR of 100)
|
40
42
|
#
|
@@ -44,14 +46,14 @@ class Byar
|
|
44
46
|
return nil if exp == 0
|
45
47
|
upper_bound(obs).quo(exp)
|
46
48
|
end
|
47
|
-
|
49
|
+
|
48
50
|
##
|
49
51
|
# Calculate lower boundary for observed cases
|
50
52
|
def self.lower_bound(obs, z_value = Z_VALUE)
|
51
53
|
return 0 if obs == 0
|
52
54
|
obs * (1 - 1.quo(9 * obs) - z_value.quo(3 * Math.sqrt(obs))) ** 3
|
53
55
|
end
|
54
|
-
|
56
|
+
|
55
57
|
##
|
56
58
|
# Calculate upper boundary for observed cases
|
57
59
|
def self.upper_bound(obs, z_value = Z_VALUE)
|
@@ -62,45 +64,45 @@ class Byar
|
|
62
64
|
def self.z_value=(value)
|
63
65
|
@z_value = value
|
64
66
|
end
|
65
|
-
|
67
|
+
|
66
68
|
def self.z_value
|
67
69
|
@z_value ||= Z_VALUE
|
68
70
|
end
|
69
|
-
|
71
|
+
|
70
72
|
##
|
71
73
|
# Give lower SMR-like boundary for +expected+ cases
|
72
74
|
def lower(expected)
|
73
75
|
self.class.lower(@obs, expected)
|
74
76
|
end
|
75
|
-
|
77
|
+
|
76
78
|
##
|
77
79
|
# Give upper SMR-like boundary for +expected+ cases
|
78
80
|
def upper(expected)
|
79
81
|
self.class.upper(@obs, expected)
|
80
82
|
end
|
81
|
-
|
83
|
+
|
82
84
|
##
|
83
85
|
# Give lower boundary for observed value
|
84
86
|
def lower_bound
|
85
87
|
self.class.lower_bound(@obs, z_value)
|
86
88
|
end
|
87
|
-
|
89
|
+
|
88
90
|
##
|
89
91
|
# Give upper boundary for observed value
|
90
92
|
def upper_bound
|
91
93
|
self.class.upper_bound(@obs, z_value)
|
92
94
|
end
|
93
|
-
|
95
|
+
|
94
96
|
##
|
95
97
|
# Give object's Z value, with fallback to Class variable or Z_VALUE
|
96
98
|
def z_value
|
97
99
|
@z_value ||= self.class.z_value
|
98
100
|
end
|
99
|
-
|
101
|
+
|
100
102
|
##
|
101
103
|
# Set custom Z value for this Byar instance
|
102
104
|
def z_value=(value)
|
103
105
|
@z_value = value
|
104
106
|
end
|
105
|
-
|
106
|
-
end
|
107
|
+
|
108
|
+
end
|
data/lib/byar/version.rb
ADDED
metadata
CHANGED
@@ -1,45 +1,97 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: byar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Floris Huetink
|
9
8
|
autorequire:
|
10
|
-
bindir:
|
9
|
+
bindir: exe
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
13
|
-
dependencies:
|
11
|
+
date: 2019-01-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.17'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.17'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.11'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.11'
|
14
55
|
description: Byar's approximation for use in (H)SMR calculations
|
15
56
|
email: floris@avocado.nl
|
16
57
|
executables: []
|
17
58
|
extensions: []
|
18
59
|
extra_rdoc_files: []
|
19
60
|
files:
|
61
|
+
- ".gitignore"
|
62
|
+
- CHANGELOG.md
|
63
|
+
- Gemfile
|
64
|
+
- Gemfile.lock
|
65
|
+
- LICENSE
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- bin/console
|
69
|
+
- bin/setup
|
70
|
+
- byar.gemspec
|
20
71
|
- lib/byar.rb
|
72
|
+
- lib/byar/version.rb
|
21
73
|
homepage: https://github.com/florish/byar
|
22
|
-
licenses:
|
74
|
+
licenses:
|
75
|
+
- MIT
|
76
|
+
metadata: {}
|
23
77
|
post_install_message:
|
24
78
|
rdoc_options: []
|
25
79
|
require_paths:
|
26
80
|
- lib
|
27
81
|
required_ruby_version: !ruby/object:Gem::Requirement
|
28
|
-
none: false
|
29
82
|
requirements:
|
30
|
-
- -
|
83
|
+
- - ">="
|
31
84
|
- !ruby/object:Gem::Version
|
32
85
|
version: 1.9.2
|
33
86
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
-
none: false
|
35
87
|
requirements:
|
36
|
-
- -
|
88
|
+
- - ">="
|
37
89
|
- !ruby/object:Gem::Version
|
38
90
|
version: '0'
|
39
91
|
requirements: []
|
40
92
|
rubyforge_project:
|
41
|
-
rubygems_version:
|
93
|
+
rubygems_version: 2.7.7
|
42
94
|
signing_key:
|
43
|
-
specification_version:
|
95
|
+
specification_version: 4
|
44
96
|
summary: Byar's approximation
|
45
97
|
test_files: []
|