Compute h(alpha) which is the size of the subsamples to be used for MCD and LTS. Given \(\alpha = alpha\), \(n\) and \(p\), \(h\) is an integer, \(h \approx \alpha n\), where the exact formula also depends on \(p\).

For \(\alpha = 1/2\), h == floor(n+p+1)/2; for the general case, it's simply n2 <- (n+p+1) %/% 2; floor(2*n2 - n + 2*(n-n2)*alpha).

h.alpha.n(alpha, n, p)

Arguments

alpha

fraction, numeric (vector) in [0.5, 1], see, e.g., covMcd.

n

integer (valued vector), the sample size.

p

integer (valued vector), the dimension.

Value

numeric vector of \(h(\alpha, n,p)\); when any of the arguments of length greater than one, the usual R arithmetic (recycling) rules are used.

See also

covMcd and ltsReg which are defined by \(h = h(\alpha,n,p)\) and hence both use h.alpha.n.

Examples

n <- c(10:20,50,100)
p <- 5
## show the simple "alpha = 1/2" case:
cbind(n=n, h= h.alpha.n(1/2, n, p), n2p = floor((n+p+1)/2))
#>         n  h n2p
#>  [1,]  10  8   8
#>  [2,]  11  8   8
#>  [3,]  12  9   9
#>  [4,]  13  9   9
#>  [5,]  14 10  10
#>  [6,]  15 10  10
#>  [7,]  16 11  11
#>  [8,]  17 11  11
#>  [9,]  18 12  12
#> [10,]  19 12  12
#> [11,]  20 13  13
#> [12,]  50 28  28
#> [13,] 100 53  53

## alpha = 3/4 is recommended by some authors :
n <- c(15, 20, 25, 30, 50, 100)
cbind(n=n, h= h.alpha.n(3/4, n, p = 6))
#>        n  h
#> [1,]  15 13
#> [2,]  20 16
#> [3,]  25 20
#> [4,]  30 24
#> [5,]  50 39
#> [6,] 100 76