37 lines
993 B
R
37 lines
993 B
R
% Generated by roxygen2: do not edit by hand
|
|
% Please edit documentation in R/directions.R
|
|
\name{directions.cve}
|
|
\alias{directions.cve}
|
|
\alias{directions}
|
|
\title{Computes projected training data \code{X} for given dimension `k`.}
|
|
\usage{
|
|
\method{directions}{cve}(dr, k)
|
|
}
|
|
\arguments{
|
|
\item{dr}{Instance of 'cve' as returned by \code{cve}.}
|
|
|
|
\item{k}{SDR dimension to use for projection.}
|
|
}
|
|
\description{
|
|
Computes projected training data \code{X} for given dimension `k`.
|
|
}
|
|
\examples{
|
|
# create B for simulation (k = 1)
|
|
B <- rep(1, 5) / sqrt(5)
|
|
set.seed(21)
|
|
# creat predictor data x ~ N(0, I_p)
|
|
x <- matrix(rnorm(500), 100, 5)
|
|
# 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)
|
|
# calculate cve with method 'simple' for k = 1
|
|
set.seed(21)
|
|
cve.obj.simple <- cve(y ~ x, k = 1, method = 'simple')
|
|
# get projected data for k = 1
|
|
x.proj <- directions(cve.obj.simple, k = 1)
|
|
# plot y against projected data
|
|
plot(x.proj, y)
|
|
|
|
}
|