coef.cve: Extracts estimated SDR basis.

Description Usage Arguments Value Examples

View source: R/coef.R

Description

Returns the SDR basis matrix for dimension k, i.e. returns the cve-estimate of B with dimension p x k.

Usage

1
2
## S3 method for class 'cve'
coef(object, k, ...)

Arguments

object

an object of class "cve", usually, a result of a call to cve or cve.call.

k

the SDR dimension.

...

ignored (no additional arguments).

Value

The matrix B of dimensions p x k.

Examples

 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
26
27
28
29
# set dimensions for simulation model
p <- 8 # sample dimension
k <- 2 # real dimension of SDR subspace
n <- 100 # samplesize
# create B for simulation
b1 <- rep(1 / sqrt(p), p)
b2 <- (-1)^seq(1, p) / sqrt(p)
B <- cbind(b1, b2)

set.seed(21)
# creat predictor data x ~ N(0, I_p)
x <- matrix(rnorm(n * p), n, p)
# simulate response variable
#    y = f(B'x) + err
# with f(x1, x2) = x1^2 + 2 * x2 and err ~ N(0, 0.1^2)
y <- (x %*% b1)^2 + 2 * (x %*% b2) + 0.1 * rnorm(100)
# calculate cve for k = 2, 3
cve.obj <- cve(y ~ x, min.dim = 2, max.dim = 3)
# get cve-estimate for B with dimensions (p, k = 2)
B2 <- coef(cve.obj, k = 2)

# Projection matrix on span(B)
# equivalent to `B %*% t(B)` since B is semi-orthonormal
PB <- B %*% solve(t(B) %*% B) %*% t(B)
# Projection matrix on span(B2)
# equivalent to `B2 %*% t(B2)` since B2 is semi-orthonormal
PB2 <- B2 %*% solve(t(B2) %*% B2) %*% t(B2)
# compare estimation accuracy by Frobenius norm of difference of projections
norm(PB - PB2, type = 'F')

CVarE documentation built on March 11, 2021, 5:06 p.m.