Leverag and Qconcalc: Difference between pages

From Eigenvector Research Documentation Wiki
(Difference between pages)
Jump to navigation Jump to search
imported>Scott
 
imported>Chuck
 
Line 1: Line 1:
===Purpose===
===Purpose===


Calculates sample leverage.
Calculate Q residuals contributions for predictions on a model.


===Synopsis===
===Synopsis===


:lev = leverag(x,''rinv'')
:qcon = qconcalc(newx,model)  
:qcon = qconcalc(model);  %requires that model contains residuals


===Description===
===Description===


LEVERAG calculates the sample leverage according to
This function calculates the Q contributions corresponding to the application of either the original calibration data, or an external set of test data, to a PLS or PCA model.


<pre>lev(i,1) = x(i,:)\*inv(x'\*x)\*x(i,:)'</pre>
If the model '''model''' was created using the "blockdetails = 'all'" option in [[pls]] or [[pca]] (or whatever function was used to create the model), then '''newx''' can be omitted to retrieve the Q contributions for the calibration data used to build the model. Note, however, that this option is not the default option for these functions, so it is unlikely that this call will work unless you have specifically created the model with the appropriate call.


Note that the leverage calculation should include a term for calculation of the offset (''e.g.'' see Draper, N. and Smith, H., "Applied Regression Analysis, Second Edition", John Wiley & Sons, New York, N.Y., 1981), but the above formula contains the salient information. This, in effect, assumes that the data have been mean centered and the constant term related to estimating the offset has been ignored. If x'\*x is replaced by x'\*x/(m-1) where m is the number of rows of x, and x has been mean centered then this is the equation for Hotelling's T<sup>2</sup> statistic.
====Inputs====


Note that if x is not of full rank then inv(x'\*x) won't exist, or if x is nearly rank deficient then calculation of the inverse will be unstable. In these cases, the scores from principal components analysis can be used.
* '''newx''' = matrix containing external test data
* '''model''' = structure for the PLS or PCA model to which the data is to be applied


If the optional input ''rinv'' is supplied then the leverage is calculated as
====Outputs====


<pre>lev(i,1) = x(i,:)\*rinv\*x(i,:)'</pre>
* '''qcon''' = matrix Q contributions for all variables used in '''model''', for all calibration objects, or objects represented in '''newx'''


===See Also===
===See Also===


[[doptimal]], [[figmerit]], [[pcr]], [[pls]]
[[datahat]], [[pca]], [[pcr]], [[pls]], [[tconcalc]]

Revision as of 22:14, 8 October 2008

Purpose

Calculate Q residuals contributions for predictions on a model.

Synopsis

qcon = qconcalc(newx,model)
qcon = qconcalc(model); %requires that model contains residuals

Description

This function calculates the Q contributions corresponding to the application of either the original calibration data, or an external set of test data, to a PLS or PCA model.

If the model model was created using the "blockdetails = 'all'" option in pls or pca (or whatever function was used to create the model), then newx can be omitted to retrieve the Q contributions for the calibration data used to build the model. Note, however, that this option is not the default option for these functions, so it is unlikely that this call will work unless you have specifically created the model with the appropriate call.

Inputs

  • newx = matrix containing external test data
  • model = structure for the PLS or PCA model to which the data is to be applied

Outputs

  • qcon = matrix Q contributions for all variables used in model, for all calibration objects, or objects represented in newx

See Also

datahat, pca, pcr, pls, tconcalc