PMSE {TRES} | R Documentation |
Prediction and mean squared error.
Description
Evaluate the tensor response regression (TRR) or tensor predictor regression (TPR) model through the mean squared error.
Usage
PMSE(x, y, B)
Arguments
x |
A predictor tensor, array, matrix or vector. |
y |
A response tensor, array, matrix or vector. |
B |
An coefficient tensor tensor, array, matrix or vector. |
Details
There are three situations:
TRR model: If
y
is anm
-way tensor (array),x
should be matrix or vector andB
should be tensor or array.TPR model: If
x
is anm
-way tensor (array),y
should be matrix or vector andB
should be tensor or array.Other: If
x
andy
are both matrix or vector,B
should be matrix. In this case, the prediction is calculated aspred = B*X
.
In any cases, users are asked to ensure the dimensions of x
, y
and B
match. See TRRsim
and TPRsim
for more details of the TRR and TPR models.
Let \hat{Y}_i
denote each prediction, then the mean squared error is defined as 1/n\sum_{i=1}^n||Y_i-\hat{Y}_i||_F^2
, where ||\cdot||_F
denotes the Frobenius norm.
Value
mse |
The mean squared error. |
pred |
The predictions. |
See Also
Examples
## Dataset in TRR model
r <- c(10, 10, 10)
u <- c(2, 2, 2)
p <- 5
n <- 100
dat <- TRRsim(r = r, p = p, u = u, n = n)
x <- dat$x
y <- dat$y
# Fit data with TRR.fit
fit_std <- TRR.fit(x, y, method="standard")
result <- PMSE(x, y, fit_std$coefficients)
## Dataset in TPR model
p <- c(10, 10, 10)
u <- c(1, 1, 1)
r <- 5
n <- 200
dat <- TPRsim(p = p, r = r, u = u, n = n)
x <- dat$x
y <- dat$y
# Fit data with TPR.fit
fit_std <- TPR.fit(x, y, u, method="standard")
result <- PMSE(x, y, fit_std$coefficients)