diff --git a/CVE/R/CVE.R b/CVE/R/CVE.R index 1fcd4bf..6dc36d9 100644 --- a/CVE/R/CVE.R +++ b/CVE/R/CVE.R @@ -123,10 +123,10 @@ #' # y = f(B'x) + err #' # with f(x1, x2) = x1^2 + 2 * x2 and err ~ N(0, 0.25^2) #' y <- (x %*% b1)^2 + 2 * (x %*% b2) + 0.25 * rnorm(100) -#' # calculate cve with method 'simple' for k unknown in 1, ..., 4 -#' cve.obj.s <- cve(y ~ x, max.dim = 4) # default method 'simple' +#' # calculate cve with method 'mean' for k unknown in 1, ..., 4 +#' cve.obj.s <- cve(y ~ x, max.dim = 4) # default method 'mean' #' # calculate cve with method 'weighed' for k = 2 -#' cve.obj.w <- cve(y ~ x, k = 2, method = 'weighted') +#' cve.obj.w <- cve(y ~ x, k = 2, method = 'weighted.mean') #' # estimate dimension from cve.obj.s #' khat <- predict_dim(cve.obj.s)$k #' # get cve-estimate for B with dimensions (p, k = khat) @@ -145,13 +145,13 @@ #' # projection matrix on span(B) #' # same as B %*% t(B) since B is semi-orthogonal #' PB <- B %*% solve(t(B) %*% B) %*% t(B) -#' # cve estimates for B with simple and weighted method +#' # cve estimates for B with mean and weighted method #' B.s <- coef(cve.obj.s, k = 2) #' B.w <- coef(cve.obj.w, k = 2) #' # same as B.s %*% t(B.s) since B.s is semi-orthogonal (same vor B.w) #' PB.s <- B.s %*% solve(t(B.s) %*% B.s) %*% t(B.s) #' PB.w <- B.w %*% solve(t(B.w) %*% B.w) %*% t(B.w) -#' # compare estimation accuracy of simple and weighted cve estimate by +#' # compare estimation accuracy of mean and weighted cve estimate by #' # Frobenius norm of difference of projections. #' norm(PB - PB.s, type = 'F') #' norm(PB - PB.w, type = 'F') diff --git a/CVE/R/directions.R b/CVE/R/directions.R index b74f2bc..73e9bbd 100644 --- a/CVE/R/directions.R +++ b/CVE/R/directions.R @@ -26,11 +26,11 @@ directions <- function(object, k, ...) { #' # 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 +#' # calculate cve with method 'mean' for k = 1 #' set.seed(21) -#' cve.obj.simple <- cve(y ~ x, k = 1, method = 'simple') +#' cve.obj.mean <- cve(y ~ x, k = 1, method = 'mean') #' # get projected data for k = 1 -#' x.proj <- directions(cve.obj.simple, k = 1) +#' x.proj <- directions(cve.obj.mean, k = 1) #' # plot y against projected data #' plot(x.proj, y) #' diff --git a/CVE/man/cve.Rd b/CVE/man/cve.Rd index 1b4fd42..6817b0f 100644 --- a/CVE/man/cve.Rd +++ b/CVE/man/cve.Rd @@ -109,7 +109,7 @@ y <- (x \%*\% b1)^2 + 2 * (x \%*\% b2) + 0.25 * rnorm(100) # calculate cve with method 'simple' for k unknown in 1, ..., 4 cve.obj.s <- cve(y ~ x, max.dim = 4) # default method 'simple' # calculate cve with method 'weighed' for k = 2 -cve.obj.w <- cve(y ~ x, k = 2, method = 'weighted') +cve.obj.w <- cve(y ~ x, k = 2, method = 'weighted.mean') # estimate dimension from cve.obj.s khat <- predict_dim(cve.obj.s)$k # get cve-estimate for B with dimensions (p, k = khat) diff --git a/CVE/man/directions.cve.Rd b/CVE/man/directions.cve.Rd index 630dd9d..87cd022 100644 --- a/CVE/man/directions.cve.Rd +++ b/CVE/man/directions.cve.Rd @@ -35,7 +35,7 @@ x <- matrix(rnorm(500), 100, 5) 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') +cve.obj.simple <- cve(y ~ x, k = 1, method = 'mean') # get projected data for k = 1 x.proj <- directions(cve.obj.simple, k = 1) # plot y against projected data