# NOT RUN {
qBCI(rnorm(100),runif(100))
# non-functional relationship:
x1 <- runif(500,0,10)
x2 <- runif(500,0,10)
y1 <- x1+rnorm(500,sd=1)
y2 <- 10-x2+rnorm(500,sd=1)
x <- c(x1,x2)
y <- c(y1,y2)
plot(x,y, pch = 19)
wdcor(x,y)
1 - qBCI(x,y)
y1 <- x1+rnorm(500,sd=0.1)
y2 <- 10-x2+rnorm(500,sd=0.1)
x <- c(x1,x2)
y <- c(y1,y2)
plot(x,y, pch = 19)
wdcor(x,y)
1 - qBCI(x,y)
# or a quadratic curve:
test <- sapply(seq(0,4,0.2),function(s){
x <- runif(200,-1,1)
y <- 5+12*x^2+rnorm(200,sd=s)
return(c(cor(x,y),
wdcor(x,y),
1 - qBCI(x,y)))
})
plot(test[3,],type="l", ylim=c(-0.2,1))
lines(test[1,], col = 2, lwd = 2)
lines(test[2,], col = 3, lwd = 2)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab