Skip to content
Prev 86966 / 398513 Next

I need your help

Hello,
I made some adjustments to your code.

1) You used 't' twice in your code. When you assign t
<- 1.645, the length m of 't' becomes 1 (that's why
your matrix was 3 x 1)

2) I assumed that the 'critical value' t is the
quantile of a Normal (0,1). By using 't <-
qnorm(0.5*level + 0.5)' allows you to consider any
value between 0 and 1 for level. Otherwise, you must
write a 'neverending' list  of 'if else'. If I assumed
wrong, put back in the code the 'if else' statement.

3) The 'kronecker' function avoids the loops for 'i'
and 'j'

I hope this is what you want.

Marco Geraci


######################

taille <- function (delta, level, prob = 0.2) {

t <- qnorm(0.5*level + 0.5)

n <- length(delta)
m <- length(level)

result <-
prob*(1-prob)*matrix(kronecker(t^2,delta^2,FUN="/"),
n, m, byrow=T)

rownames(result) <- delta
colnames(result) <- level
round(result,2)

}

taille (delta = c(0.01, 0.02, 0.03), level = c(0.90,
0.95, 0.99))

#############################



--- KOITA Lassana - STAC/ACE
<lassana.koita at aviation-civile.gouv.fr> wrote:

            
#####################################################################
####################################################################"