2
0
Fork 0
CVE/CVE/man/predict.cve.Rd

56 lines
1.3 KiB
Plaintext
Raw Normal View History

% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/predict.R
\name{predict.cve}
\alias{predict.cve}
\title{Predict method for CVE Fits.}
\usage{
2019-12-20 08:40:46 +00:00
\method{predict}{cve}(object, newdata, k, ...)
}
\arguments{
2019-12-20 08:40:46 +00:00
\item{object}{an object of class \code{"cve"}, usually, a result of a call to
\code{\link{cve}} or \code{\link{cve.call}}.}
2019-12-20 08:40:46 +00:00
\item{newdata}{Matrix of new predictor values, \eqn{C}.}
2019-12-20 08:40:46 +00:00
\item{k}{dimension of SDR space to be used for data projection.}
\item{...}{further arguments passed to \code{\link{mars}}.}
}
\value{
2019-12-20 08:40:46 +00:00
prediced response at \code{newdata}.
}
\description{
2019-12-20 08:40:46 +00:00
Predict response using projected data \eqn{B'C} by fitting
\eqn{g(B'C) + \epsilon} using \code{\link{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)
}
\seealso{
\code{\link{cve}}, \code{\link{cve.call}} and \pkg{\link{mars}}.
}