Learn R Programming

TRES (version 1.1.5)

TPRdim: Envelope dimension by cross-validation for tensor predictor regression (TPR).

Description

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

Usage

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.

Value

mincv

The minimal cross-validation mean squared error.

u

The envelope subspace dimension selected.

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,\ldots,\)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 \sum_{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.

References

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

See Also

TPRsim.

Examples

Run this code
# NOT RUN {
# 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)
# }
# NOT RUN {
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)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab