Skip to content

Commit e63718c

Browse files
committed
small bugfix in BC spearman (when using small number of bootstrap
iterations)
1 parent 97e0012 commit e63718c

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

R/bootstrap_spearman_inference.R

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,18 @@ BCIntervalSpearman = function( fD1, fD2, ordering='MEI', bootstrap_iterations=10
104104
else
105105
# when alpha1 * bootstrap_iterations is not an integer,
106106
# a modification is used
107-
int1 = v[ floor( ( bootstrap_iterations + 1 ) * alpha1 ) ]
107+
id = min(c(floor( ( bootstrap_iterations + 1 ) * alpha1 ), bootstrap_iterations))
108+
id = max(c(id, 1))
109+
int1 = v[ id ]
108110

109111
# it's the case in which alpha2 * bootstrap_iterations is an integer
110112
if( alpha2 * bootstrap_iterations - floor( alpha2 * bootstrap_iterations ) == 0 )
111113
int2 = v[ alpha2 * bootstrap_iterations ]
112114
else
113115
# when alpha2*bootstrap_iterations is not an integer,
114116
# a modification is used
117+
id = min( c( floor( ( bootstrap_iterations + 1 ) * alpha2 ), bootstrap_iterations ) )
118+
id = max( c( id, 1 ) )
115119
int2 = v[ floor( ( bootstrap_iterations + 1 ) * alpha2 ) ]
116120

117121
return( list( lower=int1, upper=int2 ) )
@@ -184,12 +188,18 @@ BCIntervalSpearmanMultivariate = function(mfD,
184188
{
185189
for( jL in (iL + 1): mfD$L )
186190
{
191+
if( verbose )
192+
{
193+
message(paste0('Bootstrap of components (', iL, ', ', jL, ')'))
194+
}
195+
187196
interval = BCIntervalSpearman( mfD$fDList[[ iL ]],
188197
mfD$fDList[[ jL ]],
189198
ordering=ordering,
190199
bootstrap_iterations=bootstrap_iterations,
191200
alpha=alpha,
192201
verbose=verbose )
202+
193203
lower[ iL, jL ] = interval$lower
194204
lower[ jL, iL ] = lower[iL, jL]
195205

0 commit comments

Comments
 (0)