diff --git a/Project.toml b/Project.toml index 81f059e..09781ff 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ authors = ["Vladimir Arnautov (mail@pharmcat.net)"] name = "ClinicalTrialUtilities" uuid = "535c2557-d7d0-564d-8ff9-4ae146c18cfe" -version = "0.3.0" +version = "0.3.1" [deps] Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" diff --git a/README.md b/README.md index 4b35624..38b6e37 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,9 @@ [![Coverage Status](https://coveralls.io/repos/github/PharmCat/ClinicalTrialUtilities.jl/badge.svg?branch=master)](https://coveralls.io/github/PharmCat/ClinicalTrialUtilities.jl?branch=master) [![Latest docs](https://img.shields.io/badge/docs-latest-blue.svg)](https://pharmcat.github.io/ClinicalTrialUtilities.jl/dev/) -## Difference since v0.2.7 +## Difference since v0.3.0 - Changes in Equivalence Hypothesis alpha level! See [here](https://github.com/PharmCat/ClinicalTrialUtilities.jl/issues/46)! + Wrong Equivalence Hypothesis alpha level! Use 0.2.7 or 0.3.1 version. ## Description @@ -38,7 +38,7 @@ using Pkg; Pkg.add("ClinicalTrialUtilities"); **NB! Hypothesis types:** - :ea - Equality: two-sided; -- :ei - Equivalencens: two one-sided hypothesis; +- :ei - Equivalencens: two one-sided hypothesis (TOST); - :ns - Non-Inferiority / Superiority: one-sided hypothesis, for some cases you should use two-sided hypothesis for Non-Inferiority/Superiority, you can use alpha/2 for this; ``` diff --git a/cange.log b/cange.log index 5e5cd84..65ea9f9 100644 --- a/cange.log +++ b/cange.log @@ -1,3 +1,9 @@ +v0.3.1 + + - deleteat! fix + - simulation crush fix + - Equivalence Hypothesis alpha level fix! + v0.3.0 - #44 , #45 , #46 - update test diff --git a/src/ClinicalTrialUtilities.jl b/src/ClinicalTrialUtilities.jl index 97df092..c777017 100644 --- a/src/ClinicalTrialUtilities.jl +++ b/src/ClinicalTrialUtilities.jl @@ -30,13 +30,14 @@ catch global lgamma(x) = SpecialFunctions.lgamma(x) end +#= try if collect(methods(DataFrames.delete!, (AbstractDataFrame, Any)))[1].file == Symbol("deprecated.jl") DataFrames.delete!(df::AbstractDataFrame, inds) = deleterows!(df, inds) end catch end - +=# const ZDIST = Normal() const LOG2 = log(2) @@ -53,7 +54,10 @@ include("proportion.jl") include("means.jl") include("hypothesis.jl") - +#DataSET +include("dataset.jl") +#Frequency +include("freque.jl") #Confidence interval calculation include("ci.jl") @@ -69,14 +73,11 @@ include("samplesize.jl") include("sim.jl") #info function include("info.jl") -#DataSET -include("dataset.jl") + #Descriptive statistics include("descriptives.jl") #PK include("pk.jl") -#Frequency -include("freque.jl") #Export include("export.jl") #Randomization diff --git a/src/ci.jl b/src/ci.jl index 0a8f759..7067f4e 100644 --- a/src/ci.jl +++ b/src/ci.jl @@ -69,9 +69,12 @@ end function StatsBase.confint(param::Mean; level = 0.95, method = :default)::ConfInt meanci(param.m, param.sd^2, param.n; alpha = 1 - level, method = method) end -function StatsBase.confint(param::DiffMean{true}; level = 0.95, method = :default)::ConfInt where T <: Mean +function StatsBase.confint(param::DiffMean{true}; level = 0.95, method = :default)::ConfInt diffmeanci(param.a.m, param.a.sd^2, param.a.n, param.b.m, param.b.sd^2, param.b.n; alpha = 1 - level, method = method) end +function StatsBase.confint(param::MetaProp; level = 0.95, method = :default)::ConfInt + error() +end """ @@ -109,6 +112,7 @@ function basepval(param::T, hyp::Equality; method = :default, atol = 1E-6) where end p end +#------------------------------------------------------------------------------- """ propci(x::Int, n::Int; alpha=0.05, method = :default)::ConfInt @@ -190,6 +194,11 @@ function diffpropci(x1::Int, n1::Int, x2::Int, n2::Int; alpha::Real = 0.05, meth throw(ArgumentError("Method unknown!")) end end +#TEST +function diffpropci(tab::ConTab{2,2}; alpha::Real = 0.05, method::Symbol = :default)::ConfInt + diffpropci(tab.a, tab.a + tab.b, tab.c, tab.c + tab.d; alpha = alpha, method = method) +end + """ rrpropci(x1::Int, n1::Int, x2::Int, n2::Int; alpha::Real = 0.05, method::Symbol = :default)::ConfInt @@ -293,7 +302,11 @@ function diffmeanci(m1::Real, s1::Real, n1::Real, m2::Real, s2::Real, n2::Real; end end - #-----------------------------PROPORTIONS----------------------------------- + +################################################################################ +# ATOMIC FUNCTIONS +################################################################################ +#-----------------------------PROPORTIONS--------------------------------------- #Wilson’s confidence interval for a single proportion, wilson score #Wilson, E.B. (1927) Probable inference, the law of succession, and statistical inferenceJ. Amer.Stat. Assoc22, 209–212 diff --git a/src/freque.jl b/src/freque.jl index a1bb741..9963672 100644 --- a/src/freque.jl +++ b/src/freque.jl @@ -119,7 +119,7 @@ function contab(data::DataFrame, sort; row::Symbol, col::Symbol) tempdf = DataFrame(row = Vector{eltype(data[!, row])}(undef, 0), col = Vector{eltype(data[!, col])}(undef, 0)) rename!(tempdf, rcv) for si = 1:size(slist, 1) - if size(tempdf, 1) > 0 delete!(tempdf, 1:size(tempdf, 1)) end + if size(tempdf, 1) > 0 deleterows!(tempdf, 1:size(tempdf, 1)) end for i = 1:size(data, 1) if data[i, sort] == slist[si, :] push!(tempdf, data[i, rcv]) @@ -160,7 +160,7 @@ function mcnmcontab(data::DataFrame, sort; row::Symbol, col::Symbol) tempdf = DataFrame(row = Vector{eltype(data[!, row])}(undef, 0), col = Vector{eltype(data[!, col])}(undef, 0)) rename!(tempdf, rcv) for si = 1:size(slist, 1) - if size(tempdf, 1) > 0 delete!(tempdf, 1:size(tempdf, 1)) end + if size(tempdf, 1) > 0 deleterows!(tempdf, 1:size(tempdf, 1)) end for i = 1:size(data, 1) if data[i, sort] == slist[si, :] push!(tempdf, data[i, rcv]) @@ -351,6 +351,8 @@ Meta-analysis for 2x2 tables. tab: vectro of ConTab{2,2} or McnmConTab; +Inverce Variance method used to get variance estimate for fixed effect. + type - type of measure: - :rr - :or/ @@ -438,7 +440,7 @@ function Base.show(io::IO, obj::MetaProp) println(io, " Trial number (k): $(obj.k)") println(io, " Model: $(obj.model)") println(io, " Type: $(obj.type)") - if obj.type == :fixed + if obj.type == :diff println(io, " Estimate: $(obj.est)") println(io, " Variance: $(obj.var)") else diff --git a/src/pk.jl b/src/pk.jl index 6af17d6..3223cab 100644 --- a/src/pk.jl +++ b/src/pk.jl @@ -885,7 +885,7 @@ function getdatai(data, sort, cols, func; sortby = nothing) datai[!, i] = Vector{eltype(data[!, i])}(undef, 0) end for i = 1:size(sortlist, 1) - if size(datai, 1) > 0 delete!(datai, 1:size(datai, 1)) end + if size(datai, 1) > 0 deleterows!(datai, 1:size(datai, 1)) end for c = 1:size(data, 1) #For each line in data if data[c, sort] == sortlist[i,:] push!(datai, data[c, cols]) diff --git a/src/powersamplesize.jl b/src/powersamplesize.jl index 6ea6da1..c3a2e8d 100644 --- a/src/powersamplesize.jl +++ b/src/powersamplesize.jl @@ -25,7 +25,7 @@ function one_mean_equality(μ₀::Real, μ₁::Real, σ::Real, α::Real, β::Rea return ((quantile(ZDIST, 1 - α / 2) + quantile(ZDIST, 1 - β)) * σ / (μ₀ - μ₁))^2 end function one_mean_equivalence(μ₀::Real, μ₁::Real, σ::Real, δ::Real, α::Real, β::Real)::Float64 - return (σ*(quantile(ZDIST, 1 - 2 * α) + quantile(ZDIST, 1 - β / 2))/(δ - abs(μ₀ - μ₁)))^2 + return (σ*(quantile(ZDIST, 1 - α) + quantile(ZDIST, 1 - β / 2))/(δ - abs(μ₀ - μ₁)))^2 end function one_mean_superiority(μ₀::Real, μ₁::Real, σ::Real, δ::Real, α::Real, β::Real)::Float64 #Non-inferiority / Superiority return (σ*(quantile(ZDIST, 1 - α) + quantile(ZDIST, 1 - β))/(μ₀ - μ₁ - δ))^2 @@ -35,7 +35,7 @@ function two_mean_equality(μ₀::Real, μ₁::Real, σ::Real, α::Real, β::Rea return (1 + 1 / k)*(σ*(quantile(ZDIST, 1 - α / 2) + quantile(ZDIST, 1 - β))/(μ₀ - μ₁))^2 end function two_mean_equivalence(μ₀::Real, μ₁::Real, σ::Real, δ::Real, α::Real, β::Real, k::Real)::Float64 - return (1 + 1 / k)*(σ*(quantile(ZDIST, 1 - 2 * α) + quantile(ZDIST, 1 - β / 2))/(δ - abs(μ₀ - μ₁)))^2 + return (1 + 1 / k)*(σ*(quantile(ZDIST, 1 - α) + quantile(ZDIST, 1 - β / 2))/(δ - abs(μ₀ - μ₁)))^2 end function two_mean_superiority(μ₀::Real, μ₁::Real, σ::Real, δ::Real, α::Real, β::Real, k::Real)::Float64 #Non-inferiority / Superiority return (1 + 1 / k)*(σ*(quantile(ZDIST, 1 - α) + quantile(ZDIST, 1 - β))/(μ₀ - μ₁ - δ))^2 @@ -46,7 +46,7 @@ function one_proportion_equality(p₀::Real, p₁::Real, α::Real, β::Real)::Fl return p₀*(1 - p₀)*((quantile(ZDIST, 1 - α / 2)+quantile(ZDIST, 1 - β))/(p₀ - p₁))^2 end function one_proportion_equivalence(p₀::Real, p₁::Real, δ::Real, α::Real, β::Real)::Float64 - return p₀*(1 - p₀)*((quantile(ZDIST, 1 - 2 * α) + quantile(ZDIST, 1 - β / 2))/(abs(p₀ - p₁) - δ))^2 + return p₀*(1 - p₀)*((quantile(ZDIST, 1 - α) + quantile(ZDIST, 1 - β / 2))/(abs(p₀ - p₁) - δ))^2 end function one_proportion_superiority(p₀::Real, p₁::Real, δ::Real, α::Real, β::Real)::Float64 return p₀*(1 - p₀)*((quantile(ZDIST, 1 - α)+quantile(ZDIST, 1 - β))/(p₀ - p₁ - δ))^2 @@ -56,7 +56,7 @@ function two_proportion_equality(p₀::Real, p₁::Real, α::Real, β::Real, k:: return (p₀ * (1 - p₀) / k + p₁ * (1 - p₁)) * ((quantile(ZDIST, 1 - α / 2) + quantile(ZDIST, 1 - β))/(p₀-p₁))^2 end function two_proportion_equivalence(p₀::Real, p₁::Real, δ::Real, α::Real, β::Real, k::Real)::Float64 - return (p₀ * (1 - p₀)/k + p₁ * (1 - p₁)) * ((quantile(ZDIST, 1 - 2 * α)+quantile(ZDIST, 1 - β / 2))/(δ - abs(p₀-p₁)))^2 + return (p₀ * (1 - p₀)/k + p₁ * (1 - p₁)) * ((quantile(ZDIST, 1 - α)+quantile(ZDIST, 1 - β / 2))/(δ - abs(p₀-p₁)))^2 end function two_proportion_superiority(p₀::Real, p₁::Real, δ::Real, α::Real, β::Real, k::Real)::Float64 return (p₀ *(1 - p₀) / k + p₁ *(1 - p₁)) * ((quantile(ZDIST, 1 - α)+quantile(ZDIST, 1 - β))/(p₀-p₁-δ))^2 @@ -66,7 +66,7 @@ function co_proportion_equality(seq, σ::Real, ϵ::Real, α::Real, β::Real) (quantile(ZDIST, 1 - α / 2) + quantile(ZDIST, 1 - β) * σ) ^ 2 / (seq * ϵ ^ 2) end function co_proportion_equivalence(seq, σ::Real, ϵ::Real, δ::Real, α::Real, β::Real) - (quantile(ZDIST, 1 - 2 * α) + quantile(ZDIST, 1 - β / 2) * σ) ^ 2 / (seq * (δ - abs(ϵ)) ^ 2) + (quantile(ZDIST, 1 - α) + quantile(ZDIST, 1 - β / 2) * σ) ^ 2 / (seq * (δ - abs(ϵ)) ^ 2) end function co_proportion_superiority(seq, σ::Real, ϵ::Real, δ::Real, α::Real, β::Real) (quantile(ZDIST, 1 - α) + quantile(ZDIST, 1 - β) * σ) ^ 2 / (seq * (ϵ - δ) ^ 2) @@ -79,7 +79,7 @@ function or_equality(p₀::Real, p₁::Real, α::Real, β::Real, k::Real)::Float end function or_equivalence(p₀::Real, p₁::Real, δ::Real, α::Real, β::Real, k::Real)::Float64 OR = p₀ * (1 - p₁) / p₁ / (1 - p₀) - return (1 / k / p₀ / (1 - p₀) + 1 / p₁ / (1 - p₁)) * ((quantile(ZDIST, 1 - 2 * α)+quantile(ZDIST, 1 - β / 2))/(log(OR) - δ))^2 + return (1 / k / p₀ / (1 - p₀) + 1 / p₁ / (1 - p₁)) * ((quantile(ZDIST, 1 - α)+quantile(ZDIST, 1 - β / 2))/(log(OR) - δ))^2 end function or_superiority(p₀::Real, p₁::Real, δ::Real, α::Real, β::Real, k::Real)::Float64 OR = p₀ *(1 - p₁) / p₁ / (1 - p₀) @@ -106,7 +106,7 @@ function cox_equality(θ, θ₀, p, α::Float64, β::Real, k::Real) 1.0/p/(1.0/(1+k)*(1.0-1.0/(1+k)))*((quantile(ZDIST, 1 - α / 2) + quantile(ZDIST, 1 - β))/(log(θ)-log(θ₀)))^2 end function cox_equivalence(θ, θ₀, p, α::Float64, β::Real, k::Real) - 1.0/p/(1.0/(1+k)*(1.0-1.0/(1+k)))*((quantile(ZDIST, 1 - 2 * α) + quantile(ZDIST, 1 - β / 2))/(log(θ₀) - abs(log(θ))))^2 + 1.0/p/(1.0/(1+k)*(1.0-1.0/(1+k)))*((quantile(ZDIST, 1 - α) + quantile(ZDIST, 1 - β / 2))/(log(θ₀) - abs(log(θ))))^2 end function cox_superiority(θ, θ₀, p, α::Float64, β::Real, k::Real) 1.0/p/(1.0/(1+k)*(1.0-1.0/(1+k)))*((quantile(ZDIST, 1 - α) + quantile(ZDIST, 1 - β))/(log(θ)-log(θ₀)))^2 @@ -121,7 +121,7 @@ function one_mean_equality_pow(μ₀::Real, μ₁::Real, σ::Real, α::Float64, end function one_mean_equivalence_pow(μ₀::Real, μ₁::Real, σ::Real, δ::Real, α::Float64, n::Int)::Float64 z = (abs(μ₀ - μ₁) - δ)/σ * sqrt(n) - return max(0, 2 * (cdf(ZDIST,z - quantile(ZDIST, 1 - 2 * α)) + cdf(ZDIST, -z - quantile(ZDIST, 1 - 2 * α))) - 1) + return max(0, 2 * (cdf(ZDIST,z - quantile(ZDIST, 1 - α)) + cdf(ZDIST, -z - quantile(ZDIST, 1 - α))) - 1) end function one_mean_superiority_pow(μ₀::Real, μ₁::Real, σ::Real, δ::Real, α::Float64, n::Int)::Float64 #Non-inferiority / Superiority z = (μ₀ - μ₁ - δ) / σ*sqrt(n) @@ -134,7 +134,7 @@ function two_mean_equality_pow(μ₀::Real, μ₁::Real, σ::Real, α::Float64, end function two_mean_equivalence_pow(μ₀::Real, μ₁::Real, σ::Real, δ::Real, α::Float64, n::Int, k::Real)::Float64 z=(abs(μ₀ - μ₁) - δ)/(σ * sqrt((1 + 1 / k) / n)) - return max(0, 2 * (cdf(ZDIST, z - quantile(ZDIST, 1 - 2 * α)) + cdf(ZDIST, - z - quantile(ZDIST, 1 - 2 * α))) - 1) + return max(0, 2 * (cdf(ZDIST, z - quantile(ZDIST, 1 - α)) + cdf(ZDIST, - z - quantile(ZDIST, 1 - α))) - 1) end function two_mean_superiority_pow(μ₀::Real, μ₁::Real, σ::Real, δ::Real, α::Float64, n::Int, k::Real)::Float64 #Non-inferiority / Superiority z = (μ₀ - μ₁ - δ)/(σ * sqrt((1 + 1 / k) / n)) @@ -148,7 +148,7 @@ function one_proportion_equality_pow(p₀::Real, p₁::Real, α::Float64, n::Int end function one_proportion_equivalence_pow(p₀::Real, p₁::Real, δ::Real, α::Float64, n::Int)::Float64 z=(abs(p₀-p₁)-δ)/sqrt(p₀*(1-p₀)/n) - return max(0, 2 * (cdf(ZDIST, z - quantile(ZDIST, 1 - 2 * α)) + cdf(ZDIST,- z - quantile(ZDIST, 1 - 2 * α))) - 1) + return max(0, 2 * (cdf(ZDIST, z - quantile(ZDIST, 1 - α)) + cdf(ZDIST,- z - quantile(ZDIST, 1 - α))) - 1) end function one_proportion_superiority_pow(p₀::Real, p₁::Real, δ::Real, α::Float64, n::Int)::Float64 z=(p₀-p₁-δ)/sqrt(p₀*(1-p₀)/n) @@ -162,7 +162,7 @@ function two_proportion_equality_pow(p₀::Real, p₁::Real, α::Float64, n::Int end function two_proportion_equivalence_pow(p₀::Real, p₁::Real, δ::Real, α::Float64, n::Int, k::Real)::Float64 z = (δ - abs(p₀ - p₁)) / sqrt(p₀ * (1 - p₀) / n / k + p₁ * (1 - p₁ ) / n) - return max(0, 2 * (cdf(ZDIST, z - quantile(ZDIST, 1 - 2 * α)) + cdf(ZDIST, - z - quantile(ZDIST, 1 - 2 * α))) - 1) + return max(0, 2 * (cdf(ZDIST, z - quantile(ZDIST, 1 - α)) + cdf(ZDIST, - z - quantile(ZDIST, 1 - α))) - 1) end function two_proportion_superiority_pow(p₀::Real, p₁::Real, δ::Real, α::Float64, n::Int, k::Real)::Float64 z = (p₀ - p₁ - δ)/sqrt(p₀ * (1 - p₀) / n / k + p₁ * (1 - p₁) / n) @@ -178,7 +178,7 @@ function or_equivalence_pow(p₀::Real, p₁::Real, δ::Real, α::Float64, n::In #println("$p₀ $p₁ $δ $α $n $k") OR = p₀ * (1 - p₁)/p₁/(1 - p₀) z = (abs(log(OR)) - δ) * sqrt(n)/sqrt(1/(k * p₀ * (1 - p₀)) + 1/(p₁ * (1 - p₁))) - return max(0, 2 * (cdf(ZDIST, z - quantile(ZDIST, 1 - 2 * α)) + cdf(ZDIST,-z - quantile(ZDIST, 1 - 2 * α))) - 1) + return max(0, 2 * (cdf(ZDIST, z - quantile(ZDIST, 1 - α)) + cdf(ZDIST,-z - quantile(ZDIST, 1 - α))) - 1) end function or_superiority_pow(p₀::Real, p₁::Real, δ::Real, α::Float64, n::Int, k::Real)::Float64 OR = p₀ * (1 - p₁)/p₁/(1 - p₀) diff --git a/src/samplesize.jl b/src/samplesize.jl index 6a8b69c..5370af4 100644 --- a/src/samplesize.jl +++ b/src/samplesize.jl @@ -188,9 +188,9 @@ Clinical trial sample size estimation. - :or - Odd Ratio; **type (Hypothesis type):** -- :ea - Equality (two-sided hypothesis, 100\\*(1 - α)% CI); -- :ei - Equivalence (two-sided hypothesis, 100\\*(1 - **2\\*α**)% CI); -- :ns - Non-Inferiority / Superiority (one-sided hypothesis, 100\\*(1 - α)% CI); +- :ea - Equality (two-sided hypothesis, 100\\*(1 - α)% two-sided CI); +- :ei - Equivalence (two-sided hypothesis, 100\\*(1 - **2\\*α**)% two-sided CI); +- :ns - Non-Inferiority / Superiority (one-sided hypothesis, one side of 100\\*(1 -**2\\*α**)% two-sided CI); - :mcnm - McNemar's Equality test; **group (group num):** @@ -313,9 +313,9 @@ Clinical trial power estimation. - :or - Odd Ratio; **type (Hypothesis type):** -- :ea - Equality (two-sided hypothesis, 100\\*(1 - α)% CI); -- :ei - Equivalence (two-sided hypothesis, 100\\*(1 - **2\\*α**)% CI); -- :ns - Non-Inferiority / Superiority (one-sided hypothesis, 100\\*(1 - α)% CI); +- :ea - Equality (two-sided hypothesis, 100\\*(1 - α)% two-sided CI); +- :ei - Equivalence (two-sided hypothesis, 100\\*(1 - **2\\*α**)% two-sided CI); +- :ns - Non-Inferiority / Superiority (one-sided hypothesis, one side of 100\\*(1 -**2\\*α**)% two-sided CI); - :mcnm - McNemar's Equality test; **group (group num):** diff --git a/src/sim.jl b/src/sim.jl index b4321ed..d4662ff 100644 --- a/src/sim.jl +++ b/src/sim.jl @@ -41,7 +41,7 @@ end Proportion difference power simulation. """ -function ctsim(t::CTask{DiffProportion{P, P}, D, H, Power}; nsim = 100, seed=0, method = :default, dropout = 0.0) where P <: Proportion where D where H <: AbstractHypothesis +function ctsim(t::CTask{DiffProportion{P1, P2}, D, H, Power}; nsim = 100, seed=0, method = :default, dropout = 0.0) where P1 <: Proportion where P2 <: Proportion where D where H <: AbstractHypothesis if seed != 0 Random.seed!(seed) end n₁ = getval(t.objective) n₂ = Int(ceil(getval(t.objective) / t.k)) diff --git a/test/ctsamplen.jl b/test/ctsamplen.jl index 0fa5522..034d9f0 100644 --- a/test/ctsamplen.jl +++ b/test/ctsamplen.jl @@ -7,7 +7,7 @@ println(" ---------------------------------- ") Base.show(io, t) Base.show(io, t.task) #2 - t = ClinicalTrialUtilities.ctsamplen(param=:mean, type=:ei, group=:one, alpha = 0.05 / 2, beta=0.2, sd=0.1, diff=0.05, a=2, b=2) + t = ClinicalTrialUtilities.ctsamplen(param=:mean, type=:ei, group=:one, alpha = 0.05, beta=0.2, sd=0.1, diff=0.05, a=2, b=2) @test ceil(t.result) == ceil(ClinicalTrialUtilities.ctsamplen(t.task).result) == 35 Base.show(io, t) #3 @@ -19,7 +19,7 @@ println(" ---------------------------------- ") @test ceil(t.result) == ceil(ClinicalTrialUtilities.ctsamplen(t.task).result) == 63 Base.show(io, t) #5 - t = ClinicalTrialUtilities.ctsamplen(param=:mean, type=:ei, group=:two, alpha=0.05 / 2, beta=0.2, sd=10, diff=5, a=5, b=4, k=1) + t = ClinicalTrialUtilities.ctsamplen(param=:mean, type=:ei, group=:two, alpha=0.05, beta=0.2, sd=10, diff=5, a=5, b=4, k=1) @test ceil(t.result) == ceil(ClinicalTrialUtilities.ctsamplen(t.task).result) == 108 Base.show(io, t) #6 @@ -31,7 +31,7 @@ println(" ---------------------------------- ") @test ceil(t.result) == ceil(ClinicalTrialUtilities.ctsamplen(t.task).result) == 50 Base.show(io, t) #8 - t = ClinicalTrialUtilities.ctsamplen(param=:prop, type=:ei, group=:one, alpha=0.05 / 2, beta=0.2, diff=0.2, a=0.6, b=0.6) + t = ClinicalTrialUtilities.ctsamplen(param=:prop, type=:ei, group=:one, alpha=0.05, beta=0.2, diff=0.2, a=0.6, b=0.6) @test ceil(t.result) == ceil(ClinicalTrialUtilities.ctsamplen(t.task).result) == 52 Base.show(io, t) #9 @@ -43,7 +43,7 @@ println(" ---------------------------------- ") @test ceil(t.result) == ceil(ClinicalTrialUtilities.ctsamplen(t.task).result) == 70 Base.show(io, t) #11 p.93 - t = ClinicalTrialUtilities.ctsamplen(param=:prop, type=:ei, group=:two, alpha=0.05 / 2, beta=0.2, diff=0.2, a=0.75, b=0.80) + t = ClinicalTrialUtilities.ctsamplen(param=:prop, type=:ei, group=:two, alpha=0.05, beta=0.2, diff=0.2, a=0.75, b=0.80) @test ceil(t.result) == ceil(ClinicalTrialUtilities.ctsamplen(t.task).result) == 133 Base.show(io, t) #12 p.92 @@ -56,7 +56,7 @@ println(" ---------------------------------- ") @test ceil(t.result) == ceil(ClinicalTrialUtilities.ctsamplen(t.task).result) == 156 Base.show(io, t) #14.1 p.109 - t = ClinicalTrialUtilities.ctsamplen(param=:or, type=:ei, alpha=0.05 / 2, beta=0.2, diff=0.5, a=0.25, b=0.25) + t = ClinicalTrialUtilities.ctsamplen(param=:or, type=:ei, alpha=0.05, beta=0.2, diff=0.5, a=0.25, b=0.25) @test ceil(t.result) == ceil(ClinicalTrialUtilities.ctsamplen(t.task).result) == 366 Base.show(io, t) #15.1 p.108 @@ -64,7 +64,7 @@ println(" ---------------------------------- ") @test ceil(t.result) == ceil(ClinicalTrialUtilities.ctsamplen(t.task).result) == 242 Base.show(io, t) #14.2 - t = ClinicalTrialUtilities.ctsamplen(param=:or, type=:ei, alpha=0.05 / 2, beta=0.2, diff=exp(0.5), a=0.25, b=0.25, logscale = false) + t = ClinicalTrialUtilities.ctsamplen(param=:or, type=:ei, alpha=0.05, beta=0.2, diff=exp(0.5), a=0.25, b=0.25, logscale = false) @test ceil(t.result) == 366 Base.show(io, t) #15.2 @@ -97,7 +97,7 @@ println(" ---------------------------------- ") Base.show(io, t) Base.show(io, t.task) #2 - t = ClinicalTrialUtilities.ctpower(param=:mean, type=:ei, group=:one, a=2, b=2, sd=0.1, diff=0.05, n=35, alpha=0.05 / 2) + t = ClinicalTrialUtilities.ctpower(param=:mean, type=:ei, group=:one, a=2, b=2, sd=0.1, diff=0.05, n=35, alpha=0.05) @test ClinicalTrialUtilities.ctpower(t.task).result ≈ 0.8108839754376387 atol=1E-7 Base.show(io, t) #3 @@ -109,7 +109,7 @@ println(" ---------------------------------- ") @test ClinicalTrialUtilities.ctpower(t.task).result ≈ 0.8013023941055788 atol=1E-7 Base.show(io, t) #5 - t = ClinicalTrialUtilities.ctpower(param=:mean, type=:ei, group=:two, a=5, b=4, sd=10, diff=5, n=108, alpha=0.05 / 2) + t = ClinicalTrialUtilities.ctpower(param=:mean, type=:ei, group=:two, a=5, b=4, sd=10, diff=5, n=108, alpha=0.05) @test ClinicalTrialUtilities.ctpower(t.task).result ≈ 0.80452354556060 atol=1E-7 Base.show(io, t) #6 @@ -121,7 +121,7 @@ println(" ---------------------------------- ") @test ClinicalTrialUtilities.ctpower(t.task).result ≈ 0.8074304194325561 atol=1E-7 Base.show(io, t) #8 - t = ClinicalTrialUtilities.ctpower(param=:prop, type=:ei, group=:one, a=0.6, b=0.6, diff=0.2, n=52, alpha=0.05 / 2) + t = ClinicalTrialUtilities.ctpower(param=:prop, type=:ei, group=:one, a=0.6, b=0.6, diff=0.2, n=52, alpha=0.05) @test ClinicalTrialUtilities.ctpower(t.task).result ≈ 0.8060834056011101 atol=1E-7 Base.show(io, t) #9 @@ -133,7 +133,7 @@ println(" ---------------------------------- ") @test ClinicalTrialUtilities.ctpower(t.task).result ≈ 0.8019139068528 atol=1E-7 Base.show(io, t) #11 - t = ClinicalTrialUtilities.ctpower(param=:prop, type=:ei, group=:two, a=0.65, b=0.85, diff=0.05, n=136, alpha=0.05 / 2) + t = ClinicalTrialUtilities.ctpower(param=:prop, type=:ei, group=:two, a=0.65, b=0.85, diff=0.05, n=136, alpha=0.05) @test ClinicalTrialUtilities.ctpower(t.task).result ≈ 0.8033294052407269 atol=1E-7 Base.show(io, t) #12 @@ -145,7 +145,7 @@ println(" ---------------------------------- ") @test ClinicalTrialUtilities.ctpower(t.task).result ≈ 0.8020239054864792 atol=1E-7 Base.show(io, t) #14 - t = ClinicalTrialUtilities.ctpower(param=:or, type=:ei, a=0.25, b=0.25, diff=0.5, n=366, alpha=0.05 / 2) + t = ClinicalTrialUtilities.ctpower(param=:or, type=:ei, a=0.25, b=0.25, diff=0.5, n=366, alpha=0.05) @test ClinicalTrialUtilities.ctpower(t.task).result ≈ 0.8008593380478983 atol=1E-7 Base.show(io, t) #15