Calculates the model estimate and residuals of the data.
- xhat = datahat(model);
- [xhat,resids] = datahat(model,data);
- [xhat,resids] = datahat(loadings,data);
Given a standard model structure (model), DATAHAT computes the model estimate of the data (xhat). For example, if (model) is a PCA model of a matrix:
- Xcal such that Xcal = TPT + E, then Xhat = TPT
- Xcal = TPT + E = Xhat + E.
If optional input (data) is supplied then DATAHAT computes the model estimate of (data) which will be output in (xhat). For the PCA model of matrix Xcal, and (data) is a data matrix Xnew then:
- Xhat = XnewPPT = TnewPT
and the output (resids) is a matrix with the corresponding residuals:
- E = Xnew-XnewPPT = Xnew(I-PPT)
If (data) is Xcal then:
- Xhat = TPT
and resids is:
- E = Xcal(I-PPT).
Note that preprocessing in (model) will be performed before the residuals are calculated. If data is not provided, only (xhat) of the calibration data is available.
Note that DATAHAT works with almost all standard model structures or a cell-array of loadings can be supplied in place of model (for use with multiway models only).