TPRdim: Envelope dimension by cross-validation for tensor predictor...

Description Usage Arguments Details Value References See Also Examples

View source: R/TPRdim.R

Description

Select the envelope dimension by cross-validation for tensor predictor regression.

Usage

1
TPRdim(x, y, maxdim = 10, nfolds = 5)

Arguments

x

The predictor tensor instance of dimension p_1\times p_2\times\cdots\times p_m \times n, where n is the sample size. Array with the same dimensions and matrix with dimension p\times n are acceptable.

y

The response matrix of dimension r \times n, where n is the sample size. Vector of length n is acceptable.

maxdim

The largest dimension to be considered for selection.

nfolds

Number of folds for cross-validation.

Details

According to Zhang and Li (2017), the dimensions of envelopes at each mode are assumed to be equal, so the u returned is a single value representing the equal envelope dimension.

For each dimension u in 1:maxdim, we obtain the prediction

\hat{Y}_i = \hat{B}_{(m+1)} vec(X_i)

for each predictor X_i in the k-th testing dataset, k = 1,…,nfolds, where \hat{B} is the estimated coefficient based on the k-th training dataset. And the mean squared error for the k-th testing dataset is defined as

1/nk ∑_{i=1}^{nk}||Y_i-\hat{Y}_i||_F^2,

where nk is the sample size of the k-th testing dataset and ||\cdot||_F denotes the Frobenius norm. Then, the average of nfolds mean squared error is recorded as cross-validation mean squared error for the dimension u.

Value

mincv

The minimal cross-validation mean squared error.

u

The envelope subspace dimension selected.

References

Zhang, X. and Li, L., 2017. Tensor envelope partial least-squares regression. Technometrics, 59(4), pp.426-436.

See Also

TPRsim.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
# The dimension of predictor
p <- c(10, 10, 10)
# The envelope dimensions u.
u <- c(1, 1, 1)
# The dimension of response
r <- 5
# The sample size
n <- 200
dat <- TPRsim(p = p, r = r, u = u, n = n)
x <- dat$x
y <- dat$y
TPRdim(x, y, maxdim = 5)

## Use dataset square. (time-consuming)

data("square")
x <- square$x
y <- square$y
# check the dimension of x
dim(x)
# use 32 as the maximal envelope dimension
TPRdim(x, y, maxdim=32)

TRES documentation built on Oct. 20, 2021, 9:06 a.m.