# NOT RUN {
set.seed(300)
ncol <- 30
nrow <- 20
covariate <- sin((1:nrow)*2*pi/nrow)
x <- matrix(rep(NA, nrow*ncol), nrow=nrow)
xsig <- seq(0,1,length.out=nrow)
y <- xsig + covariate + rnorm(nrow, sd=0.5)
for(i in 1:ncol){
x[, i] <- xsig + rnorm(nrow, sd=i/ncol)
}
r2 <- crossvalidatedR2(x, y, covariates=covariate)
# }
Run the code above in your browser using DataLab