Learn R Programming

msir (version 1.3.3)

predict.msir: Model-based Sliced Inverse Regression directions

Description

MSIR estimates a set of \(d \le p\) orthogonal direction vectors of length \(p\) which are estimates of the basis of the dimensional reduction subspace.

Usage

# S3 method for msir
predict(object, dim = 1:object$numdir, newdata, …)

Arguments

object

an object of class 'msir' resulting from a call to msir.

dim

the dimensions of the reduced subspace used for prediction.

newdata

a data frame or matrix giving the data. If missing the data obtained from the call to msir are used.

further arguments passed to or from other methods.

Value

The function returns a matrix of points projected on the subspace spanned by the estimated basis vectors.

References

Scrucca, L. (2011) Model-based SIR for dimension reduction. Computational Statistics & Data Analysis, 55(11), 3010-3026.

See Also

{msir}

Examples

Run this code
# NOT RUN {
n <- 200
p <- 5
b <- as.matrix(c(1,-1,rep(0,p-2)))
x <- matrix(rnorm(n*p), nrow = n, ncol = p)
y <- exp(0.5 * x%*%b) + 0.1*rnorm(n)
pairs(cbind(y,x), gap = 0)

MSIR <- msir(x, y)
summary(MSIR)
plot(MSIR, which = 1, type = "2Dplot")
all.equal(predict(MSIR), MSIR$dir)
predict(MSIR, dim = 1:2)

x0 <- matrix(rnorm(n*p), nrow = n, ncol = p)
y0 <- exp(0.5 * x0%*%b) + 0.1*rnorm(n)
plot(predict(MSIR, dim = 1, newdata = x0), y0)
# }

Run the code above in your browser using DataLab