@@ -84,7 +84,10 @@ Series B (Statistical Methodology) 66, 187–205.
8484struct Storey <: Pi0Estimator
8585 λ:: Float64
8686
87- Storey (λ) = isin (λ, 0 , 1 ) ? new (λ) : throw (DomainError ())
87+ function Storey (λ)
88+ isin (λ, 0 , 1 ) || throw (DomainError (" λ must be in [0, 1]" ))
89+ return new (λ)
90+ end
8891end
8992
9093Storey () = Storey (0.1 )
@@ -131,8 +134,11 @@ struct StoreyBootstrap <: Pi0Estimator
131134 λseq:: Vector{Float64}
132135 q :: Float64
133136
134- StoreyBootstrap (λseq, q) =
135- isin (λseq, 0 , 1 ) && isin (q, 0 , 1 ) ? new (λseq, q) : throw (DomainError ())
137+ function StoreyBootstrap (λseq, q)
138+ isin (λseq, 0 , 1 ) || throw (DomainError (" λseq must be in [0, 1]" ))
139+ isin (q, 0 , 1 ) || throw (DomainError (" q must be in [0, 1]" ))
140+ return new (λseq, q)
141+ end
136142end
137143
138144StoreyBootstrap () = StoreyBootstrap (0.05 : 0.05 : 0.95 , 0.1 )
@@ -229,7 +235,10 @@ julia> estimate_pi0(pvals, Oracle(0.5)) # a bit boring...
229235struct Oracle <: Pi0Estimator
230236 π0:: Float64
231237
232- Oracle (π0) = isin (π0, 0 , 1 ) ? new (π0) : throw (DomainError ())
238+ function Oracle (π0)
239+ isin (π0, 0 , 1 ) || throw (DomainError (" π0 must be in [0, 1]" ))
240+ return new (π0)
241+ end
233242end
234243
235244Oracle () = Oracle (1.0 )
@@ -269,7 +278,10 @@ struct TwoStep <: Pi0Estimator
269278 α:: Float64
270279 adjustment:: PValueAdjustment
271280
272- TwoStep (α, method) = isin (α, 0 , 1 ) ? new (α, method) : throw (DomainError ())
281+ function TwoStep (α, method)
282+ isin (α, 0 , 1 ) || throw (DomainError (" α must be in [0, 1]" ))
283+ return new (α, method)
284+ end
273285end
274286
275287TwoStep () = TwoStep (0.05 )
@@ -313,8 +325,10 @@ Statistical Society: Series B (Statistical Methodology) 74, 163–182.
313325struct RightBoundary <: Pi0Estimator
314326 λseq:: Vector{Float64}
315327
316- RightBoundary (λseq) =
317- isin (λseq, 0 , 1 ) ? new (λseq) : throw (DomainError ())
328+ function RightBoundary (λseq)
329+ isin (λseq, 0 , 1 ) || throw (DomainError (" λseq must be in [0, 1]" ))
330+ return new (λseq)
331+ end
318332end
319333
320334# λseq used in Liang, Nettleton 2012
@@ -366,11 +380,11 @@ struct CensoredBUM <: Pi0Estimator
366380 maxiter:: Int64
367381
368382 function CensoredBUM (γ0, λ, xtol, maxiter)
369- if isin (γ0, 0 , 1 ) && isin (λ, 0 , 1 ) && isin (xtol, 0 , 1 ) && maxiter > 0
370- new (γ0, λ, xtol, maxiter )
371- else
372- throw (DomainError ())
373- end
383+ isin (γ0, 0 , 1 ) || throw ( DomainError ( " γ0 must be in [ 0, 1] " ))
384+ isin (λ, 0 , 1 ) || throw ( DomainError ( " λ must be in [0, 1] " ) )
385+ isin (xtol, 0 , 1 ) || throw ( DomainError ( " xtol must be in [0, 1] " ))
386+ maxiter > 0 || throw (DomainError (" maxiter must be a positive number " ))
387+ return new (γ0, λ, xtol, maxiter)
374388 end
375389end
376390
@@ -495,11 +509,10 @@ struct BUM <: Pi0Estimator
495509 maxiter:: Int64
496510
497511 function BUM (γ0, xtol, maxiter)
498- if isin (γ0, 0 , 1 ) && isin (xtol, 0 , 1 )
499- new (γ0, xtol, maxiter)
500- else
501- throw (DomainError ())
502- end
512+ isin (γ0, 0 , 1 ) || throw (DomainError (" γ0 must be in [0, 1]" ))
513+ isin (xtol, 0 , 1 ) || throw (DomainError (" xtol must be in [0, 1]" ))
514+ maxiter > 0 || throw (DomainError (" maxiter must be a positive number" ))
515+ return new (γ0, xtol, maxiter)
503516 end
504517end
505518
@@ -620,11 +633,10 @@ struct ConvexDecreasing <: Pi0Estimator
620633 maxiter:: Int64
621634
622635 function ConvexDecreasing (gridsize, xtol, maxiter)
623- if gridsize > 0 && isin (xtol, 0 , 1 ) && maxiter > 0
624- new (gridsize, xtol, maxiter)
625- else
626- throw (DomainError ())
627- end
636+ gridsize > 0 || throw (DomainError (" gridsize must be a positive number" ))
637+ isin (xtol, 0 , 1 ) || throw (DomainError (" xtol must be in [0, 1]" ))
638+ maxiter > 0 || throw (DomainError (" maxiter must be a positive number" ))
639+ return new (gridsize, xtol, maxiter)
628640 end
629641end
630642
0 commit comments