Skip to content

Commit 2aa1e76

Browse files
author
PharmCat
committed
v0.6.5 rr mn bugfix
1 parent b015fe5 commit 2aa1e76

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ClinicalTrialUtilities"
22
uuid = "535c2557-d7d0-564d-8ff9-4ae146c18cfe"
33
authors = ["Vladimir Arnautov (mail@pharmcat.net)"]
4-
version = "0.6.4"
4+
version = "0.6.5"
55

66
[deps]
77
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"

src/ci.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ end
481481
a = n2*(lim-1)
482482
b = n1*lim+n2-(x1+x2)*(lim-1)
483483
c = -(x1+x2)
484-
p2d = (-b+sqrt(b^2-4*a*c))/(2*a)
484+
p2d = (-b+sqrt(b^2-4*a*c))/2a
485485
p1d = p2d*lim/(1+p2d*(lim-1))
486486
score = ((n1*(px-p1d))^2)*(1/(n1*p1d*(1-p1d))+1/(n2*p2d*(1-p2d)))*(n1+n2-1)/(n1+n2)
487487
ci = lim
@@ -494,7 +494,7 @@ end
494494
a = n2*-1)
495495
b = φ*n1+n2-(x1+x2)*-1)
496496
c = -(x1 + x2)
497-
p2 = (-b+sqrt(b*b-4*a*c))/a/2
497+
p2 = (-b+sqrt(b*b - 4a * c))/2a
498498
p1 = p2*φ/(1+p2*-1))
499499
return p1, p2
500500
end
@@ -666,10 +666,10 @@ end
666666
b = -(1 + theta + p1 + theta * p2 + Δ*(theta + 2))
667667
c = Δ^2 + Δ*(2 * p1 + theta + 1) + p1 + theta * p2
668668
d = -p1*Δ*(1 + Δ)
669-
v = (b/a/3)^3 - b*c/(6*a*a) + d/2/a
670-
u = sign(v) * sqrt((b/3/a)^2 - c/3/a)
669+
v = (b/3a)^3 - b*c/(6*a*a) + d/2a
670+
u = sign(v) * sqrt((b/3a)^2 - c/3a)
671671
w = (pi + acos(v/u^3))/3
672-
p1n = 2*u*cos(w) - b/3/a
672+
p1n = 2u*cos(w) - b/3a
673673
p2n = p1n - Δ
674674
return p1n * (1-p1n)/n1 + p2n * (1 - p2n)/n2
675675
end
@@ -720,18 +720,18 @@ end
720720
#Miettinen-Nurminen Score interval
721721
#Miettinen, O. and Nurminen, M. (1985), Comparative analysis of two rates. Statist. Med., 4: 213-226. doi:10.1002/sim.4780040211
722722
@inline function mlemnrr(φ, x1::Int, n1::Int, x2::Int, n2::Int)
723-
a = (n1+n2)*φ
724-
b = -*(x1+n2)+x2+n1)
723+
a = (n1 + n2) * φ
724+
b = - *(x2 + n1) + x1 + n2)
725725
c = x1 + x2
726-
p2 = (-b-sqrt(b*b-4*a*c))/2/a
727-
p1 = p2*φ
726+
p2 = (-b-sqrt(b*b-4a*c))/2a
727+
p1 = p2 * φ
728728
return p1, p2
729729
end
730730
@inline function mnrrval(φ, x1::Int, n1::Int, x2::Int, n2::Int, z)
731731
p1 = x1/n1
732732
p2 = x2/n2
733733
pmle1, pmle2 = mlemnrr(φ, x1, n1, x2, n2)
734-
return ((p1 - φ*p2)^2)/((pmle1*(1-pmle1)/n1 + φ*φ*pmle2*(1-pmle2)/n2)*((n1+n2-1)/(n1+n2)))-z
734+
return ((p1 - φ*p2)^2)/((pmle1*(1-pmle1)/n1 + φ*φ*pmle2*(1-pmle2)/n2)*(n1+n2)/(n1+n2-1)) - z
735735
end
736736
function proprrmnci(x1::Int, n1::Int, x2::Int, n2::Int, alpha)
737737
z = quantile(Chisq(1), 1 - alpha)

test/citest.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ println(" ---------------------------------- ")
148148
#-- mn
149149

150150
ci = ClinicalTrialUtilities.rrpropci(30, 100, 40, 90; alpha=0.05, method=:mn)
151-
@test ci.lower 0.46636099123297575 atol=1E-6
152-
@test ci.upper 0.9799258384796817 atol=1E-6
151+
@test ci.lower 0.461480914884656 atol=1E-6
152+
@test ci.upper 0.9801801210729479 atol=1E-6
153153
@test ci.estimate 0.675 atol=1E-6
154154
@test ci.estimate StatsBase.confint(ClinicalTrialUtilities.RiskRatio(ClinicalTrialUtilities.Proportion(30, 100),
155155
ClinicalTrialUtilities.Proportion(40, 90)); level = 0.95, method = :mn).estimate
@@ -161,11 +161,11 @@ println(" ---------------------------------- ")
161161

162162
ci = ClinicalTrialUtilities.rrpropci(0, 100, 90, 90; alpha=0.05, method=:mn)
163163
@test ci.lower 0.0
164-
@test ci.upper 0.018137090385952483 atol=1E-6
164+
@test ci.upper 0.03680596180211699 atol=1E-6
165165
@test ci.estimate 0.0
166166

167-
ci = ClinicalTrialUtilities.rrpropci(100, 100, 0, 90; alpha=0.05, method=:mn)
168-
@test ci.lower 44.84369729432598 atol=1E-2 #v 44.8498645475395
167+
ci = ClinicalTrialUtilities.rrpropci(100, 100, 0, 70; alpha=0.05, method=:mn)
168+
@test ci.lower 19.32220093816104 atol=1E-2 #v 44.8498645475395
169169
@test ci.upper Inf
170170
@test ci.estimate Inf
171171

0 commit comments

Comments
 (0)