predict.cve: Predict method for CVE Fits.

Description Usage Arguments Value See Also Examples

View source: R/predict.R

Description

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

Usage

1
2
## 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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# 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)

CVarE documentation built on March 11, 2021, 5:06 p.m.