Description Usage Arguments Value See Also Examples
Predict response using projected data. The forward model g(B' X) is
estimated with mars
in the mda package.
1 2 |
object |
an object of class |
newdata |
Matrix of new predictor values, C. |
k |
dimension of SDR space to be used for data projection. |
... |
further arguments passed to |
prediced respone(s) for newdata
.
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.