predict.cve {CVarE}R Documentation

Predict method for CVE Fits.

Description

Predict response using projected data. The forward model g(B' X) is estimated with mars in the mda package.

Usage

## S3 method for class 'cve'
predict(object, newdata, k, ...)

Arguments

object

an object of class "cve", usually, a result of a call to cve or cve.call.

newdata

Matrix of new predictor values, C.

k

dimension of SDR space to be used for data projection.

...

further arguments passed to mars.

Value

prediced respone(s) for newdata.

See Also

cve, cve.call and mars.

Examples

# create B for simulation
B <- rep(1, 5) / sqrt(5)

set.seed(21)
# creat predictor data x ~ N(0, I_p)
x <- matrix(rnorm(500), 100)

# simulate response variable
#    y = f(B'x) + err
# with f(x1) = x1 and err ~ N(0, 0.25^2)
y <- x %*% B + 0.25 * rnorm(100)

x.train <- x[1:80, ]
x.test  <- x[81:100, ]
y.train <- y[1:80, ]
y.test  <- y[81:100, ]

# calculate cve with method 'simple' for k = 1
cve.obj.simple <- cve(y.train ~ x.train, k = 1) 

# predict y.test from x.test
yhat <- predict(cve.obj.simple, x.test, 1)

# plot prediction against y.test
plot(yhat, y.test)

[Package CVarE version 1.1 Index]