Subtract and add the quantity to one line of code in R?

Perhaps this is too simple a question, but I was wondering if it is possible to subtract qnorm(.975)*1/sqrt(34 - 3))and add in tanh(atanh(.5) without writing -and +in two separate lines of code (but instead in one line of code)?

Here is the R code:

tanh(atanh(.5)  -  qnorm(.975)*1/sqrt(34 - 3))
tanh(atanh(.5)  +  qnorm(.975)*1/sqrt(34 - 3))
+4
source share
2 answers

R is vectorized. So, use it.

tanh(atanh(.5) + c(-1, 1)*qnorm(.975)*1/sqrt(34 - 3))
#[1] 0.1947659 0.7169429

A vector c(-1, 1)multiplies the return value qnormby specifying a vector of length 2, if required.

+2
source

After a little thought, the statistical answer is as follows:

tanh(atanh(.5) + qnorm(c(.025, .975))*1/sqrt(34 - 3))
#[1] 0.1947659 0.7169429
+3
source

Source: https://habr.com/ru/post/1693762/


All Articles