diff --git a/pls_playground.Rmd b/pls_playground.Rmd index 83c79a7..c35feac 100644 --- a/pls_playground.Rmd +++ b/pls_playground.Rmd @@ -51,4 +51,52 @@ coefs <- coef(pls.model) barplot(sort(coefs[,1,1], decreasing = T)[1:4]) +``` + + +```{r simulate} +X <- matrix(rnorm(1100), 100, 11) +Y <- matrix(rnorm(400), 100, 4) + +pls.model <- plsr(Y ~ X, validation = "CV") + +cv <- RMSEP(pls.model) +best_dims <- which.min(cv$val[estimate = "adjCV", , ]) - 1 +pls.model <- plsr(Y ~ X, ncomp = best_dims) +coefs <- sort(coef(pls.model)[,1,1], decreasing = T) + +barplot(coefs) + +``` + + +```{r cca-simulate} +X <- matrix(rnorm(1100), 100, 11) +Y <- matrix(rnorm(400), 100, 4) + +M <- cor(cbind(X,Y)) +corrplot(M, method="ellipse", order="hclust", addrect=2, addCoef.col="black") +cc <- cancor(X, Y) + +#NB: cc <- cancor(cbind(rt,correct, accuracy) ~ xt + xl + xtl, data = data) + +``` + + +```{r plsrglm} +rm(list = ls()) +library(plsRglm) + +data(Cornell) +df <- Cornell +x <- subset(df, select = -c(Y)) +y <- df$Y +## K is the number of folds in CV, and nt is the maximum number of components, +#cv.modpls<-cv.plsRglm(dataY=y,dataX=x ,nt=10,modele="pls-glm-logistic",K=8) + +modpls <- plsRglm(dataY = y,dataX = x, nt = 10, modele = "pls-glm-logistic", sparse=TRUE,sparseStop=TRUE) +res.cv.modpls<-cvtable(summary(cv.modpls)) + +res6<-plsR(Y~.,data=Cornell, nt=6, typeVC="missing", pvals.expli=TRUE) + ``` \ No newline at end of file