2019-09-16 09:15:51 +00:00
|
|
|
% Generated by roxygen2: do not edit by hand
|
2019-11-22 08:32:14 +00:00
|
|
|
% Please edit documentation in R/plot.R
|
2019-09-16 09:15:51 +00:00
|
|
|
\name{plot.cve}
|
|
|
|
\alias{plot.cve}
|
2019-10-22 08:33:41 +00:00
|
|
|
\title{Loss distribution elbow plot.}
|
2019-09-16 09:15:51 +00:00
|
|
|
\usage{
|
2019-10-18 07:06:36 +00:00
|
|
|
\method{plot}{cve}(x, ...)
|
2019-09-16 09:15:51 +00:00
|
|
|
}
|
|
|
|
\arguments{
|
2019-10-18 07:06:36 +00:00
|
|
|
\item{x}{Object of class \code{"cve"} (result of [\code{\link{cve}}]).}
|
2019-09-16 09:15:51 +00:00
|
|
|
|
2019-10-18 07:06:36 +00:00
|
|
|
\item{...}{Pass through parameters to [\code{\link{plot}}] and
|
|
|
|
[\code{\link{lines}}]}
|
2019-09-16 09:15:51 +00:00
|
|
|
}
|
|
|
|
\description{
|
2019-11-20 18:03:21 +00:00
|
|
|
Boxplots of the loss from \code{min.dim} to \code{max.dim} \code{k} values.
|
2019-12-05 16:35:29 +00:00
|
|
|
}
|
|
|
|
\examples{
|
|
|
|
# create B for simulation
|
|
|
|
B <- cbind(rep(1, 6), (-1)^seq(6)) / sqrt(6)
|
|
|
|
|
|
|
|
set.seed(21)
|
|
|
|
# creat predictor data x ~ N(0, I_p)
|
|
|
|
X <- matrix(rnorm(600), 100)
|
|
|
|
|
|
|
|
# simulate response variable
|
|
|
|
# y = f(B'x) + err
|
|
|
|
# with f(x1, x2) = x1^2 + 2 x2 and err ~ N(0, 0.25^2)
|
|
|
|
Y <- (X \%*\% B[, 1])^2 + 2 * X \%*\% B[, 2] + rnorm(100, 0, .1)
|
|
|
|
|
|
|
|
# Create bandwidth estimation function
|
|
|
|
estimate.bandwidth <- function(X, k, nObs) {
|
|
|
|
n <- nrow(X)
|
|
|
|
p <- ncol(X)
|
|
|
|
X_c <- scale(X, center = TRUE, scale = FALSE)
|
|
|
|
2 * qchisq((nObs - 1) / (n - 1), k) * sum(X_c^2) / (n * p)
|
|
|
|
}
|
|
|
|
# calculate cve with method 'simple' for k = min.dim,...,max.dim
|
|
|
|
cve.obj.simple <- cve(Y ~ X, h = estimate.bandwidth, nObs = sqrt(nrow(X)))
|
|
|
|
|
|
|
|
# elbow plot
|
|
|
|
plot(cve.obj.simple)
|
|
|
|
|
2019-09-16 09:15:51 +00:00
|
|
|
}
|
|
|
|
\seealso{
|
|
|
|
see \code{\link{par}} for graphical parameters to pass through
|
2019-10-18 07:06:36 +00:00
|
|
|
as well as \code{\link{plot}}, the standard plot utility.
|
2019-09-16 09:15:51 +00:00
|
|
|
}
|