| predict_pls_latent | R Documentation |
These prediction helpers reconstruct the response matrix and latent
component scores for partial least squares (PLS) models fitted inside the
Cox-PLS toolbox. They support group PLS, sparse PLS, sparse-group PLS, and
classical PLS models created by sgPLS::gPLS(), sgPLS::sPLS(),
sgPLS::sgPLS(), or plsRcox::pls.cox().
## S3 method for class 'gPLS'
predict(object, newdata, scale.X = TRUE, scale.Y = TRUE, ...)
## S3 method for class 'pls.cox'
predict(object, newdata, scale.X = TRUE, scale.Y = TRUE, ...)
## S3 method for class 'sPLS'
predict(object, newdata, scale.X = TRUE, scale.Y = TRUE, ...)
## S3 method for class 'sgPLS'
predict(object, newdata, scale.X = TRUE, scale.Y = TRUE, ...)
object |
A fitted PLS model returned by |
newdata |
Numeric matrix or data frame with the same number of columns
as the training design matrix used when fitting |
scale.X, scale.Y |
Logical flags indicating whether the predictors and
responses supplied in |
... |
Unused arguments included for compatibility with the generic
|
A list containing reconstructed responses, latent component scores,
and regression coefficients. The exact elements depend on the specific PLS
algorithm but always include components named predict, variates, and
B.hat.
Bastien, P., Bertrand, F., Meyer, N., & Maumy-Bertrand, M. (2015). Deviance residuals-based sparse PLS and sparse kernel PLS for censored data. Bioinformatics, 31(3), 397–404. doi:10.1093/bioinformatics/btu660
coxgpls(), coxsgpls(), coxspls_sgpls(), and
coxDKgplsDR() for Cox model wrappers that return PLS fits using these
prediction methods.
n <- 100
sigma.gamma <- 1
sigma.e <- 1.5
p <- 400
q <- 500
theta.x1 <- c(rep(1, 15), rep(0, 5), rep(-1, 15), rep(0, 5), rep(1.5,15),
rep(0, 5), rep(-1.5, 15), rep(0, 325))
theta.x2 <- c(rep(0, 320), rep(1, 15), rep(0, 5), rep(-1, 15), rep(0, 5),
rep(1.5, 15), rep(0, 5), rep(-1.5, 15), rep(0, 5))
theta.y1 <- 1
theta.y2 <- 1
Sigmax <- matrix(0, nrow = p, ncol = p)
diag(Sigmax) <- sigma.e ^ 2
Sigmay <- matrix(0,nrow = 1, ncol = 1)
diag(Sigmay) <- sigma.e ^ 2
set.seed(125)
gam1 <- rnorm(n)
gam2 <- rnorm(n)
X <- matrix(c(gam1, gam2), ncol = 2, byrow = FALSE) %*% matrix(c(theta.x1, theta.x2),
nrow = 2, byrow = TRUE) + mvtnorm::rmvnorm(n, mean = rep(0, p), sigma =
Sigmax, method = "svd")
Y <- matrix(c(gam1, gam2), ncol = 2, byrow = FALSE) %*% matrix(c(theta.y1, theta.y2),
nrow = 2, byrow = TRUE) + rnorm(n,0,sd=sigma.e)
ind.block.x <- seq(20, 380, 20)
model.gPLS <- sgPLS::gPLS(X, Y, ncomp = 2, mode = "regression", keepX = c(4, 4),
keepY = c(4, 4), ind.block.x = ind.block.x)
head(predict(model.gPLS, newdata = X)$variates)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.