######******###### np.cor.test ######******######
# generate data
rho <- 0.5
val <- c(sqrt(1 + rho), sqrt(1 - rho))
corsqrt <- matrix(c(val[1], -val[2], val), 2, 2) / sqrt(2)
set.seed(1)
n <- 50
z <- cbind(rnorm(n), rnorm(n)) %*% corsqrt
x <- z[,1]
y <- z[,2]
# test H0: rho = 0
set.seed(0)
test <- np.cor.test(x, y)
# plot results
plot(test)
######******###### np.loc.test ######******######
# generate data
set.seed(1)
n <- 50
x <- rnorm(n, mean = 0.5)
# one sample t-test
set.seed(0)
test <- np.loc.test(x)
# plot results
plot(test)
######******###### np.reg.test ######******######
# generate data
set.seed(1)
n <- 50
x <- cbind(rnorm(n), rnorm(n))
beta <- c(0.25, 0.5)
y <- x %*% beta + rnorm(n)
# Wald test (method = "perm")
set.seed(0)
test <- np.reg.test(x, y)
# plot results
plot(test)
Run the code above in your browser using DataLab