Dew Stats Master .NET
PCRegress Routines
Summary
Principal Component Regression.

Unit
Regress

Declaration
Procedure PCRegress(y: TVec; A: TMtx; b: TVec; YCalc: TVec = nil; Bse: TVec = nil; NumOmmit: Integer = 1);
 Parameter  Description 
Defines vector of dependant variable. 
Defines matrix of independant variables. 
NumOmmit Defines the number of variables to ommit from initial model. 
Returns calculated regression coefficiens. 
YCalc Returns vector of calculated dependant variable, where YCalc = A*b + constant term. 
Bse Returns principal component b coefficient standard error. 

Description
Performs unweighted Principal Component Regression (PCR). PCR is a technique for analyzing multiple regression data that suffer from multicollinearity. When multicollinearity occurs, least squares estimates are unbiased, but their variances are large so they may be far from the true value. By adding a degree of bias to the regression estimates, principal components regression reduces the standard errors. The algorithm first standardizes A matrix and performs PC regression on standardized matrix.
Categories
Regression routines.
 See Also 
RidgeRegress 

Example 1

Uses MtxExpr, Regress, StatTools, Math387; procedure Example; var y,b,ycalc,error: Vector; A,ATA: Matrix; mse: TSample; begin // Load data A.SetIt(18,3,false,[1, 2, 1, 2, 4, 2, 3, 6, 4, 4, 7, 3, 5, 7, 2, 6, 7, 1, 7, 8, 1, 8, 10, 2, 9, 12, 4, 10, 13, 3, 11, 13, 2, 12, 13, 1, 13, 14, 1, 14, 16, 2, 15, 18, 4, 16, 19, 3, 17, 19, 2, 18, 19, 1]); Y.SetIt([3,9,11,15,13,13,17,21,25,27,25,27,29,33,35,37,37,39]); // Perform Principal Component Regression PCRegress(y,A,b,ycalc,nil,1); // Errors error.Sub(ycalc,y); end;
#include "MtxVecCpp.h" #include "Regress.hpp" #include "StatTools.hpp" #include "Math387.hpp" void __fastcall Example() { Matrix A, ATA; Vector y,b,ycalc,error; double mse; // Load data A->SetIt(18,3,false,OPENARRAY(TSample,(1, 2, 1, 2, 4, 2, 3, 6, 4, 4, 7, 3, 5, 7, 2, 6, 7, 1, 7, 8, 1, 8, 10, 2, 9, 12, 4, 10, 13, 3, 11, 13, 2, 12, 13, 1, 13, 14, 1, 14, 16, 2, 15, 18, 4, 16, 19, 3, 17, 19, 2, 18, 19, 1))); Y->SetIt(false,OPENARRAY(TSample,(3,9,11,15,13,13,17,21,25,27,25,27,29,33,35,37,37,39))); // Perform Principal Component Regression PCRegress(y,A,b,ycalc,null,1); // Errors error->Sub(ycalc,y); }
using Dew.Math; using Dew.Stats.Units; using Dew.Stats; namespace Dew.Examples { private void Example() { Matrix A = new Matrix(0,0); Matrix ATA = new Matrix(0,0); Vector y = new Vector(0); Vector ycalc = new Vector(0); Vector b = new Vector(0); Vector error = new Vector(0); double mse; // Load data A.SetIt(18,3,false, new double[] {1, 2, 1, 2, 4, 2, 3, 6, 4, 4, 7, 3, 5, 7, 2, 6, 7, 1, 7, 8, 1, 8, 10, 2, 9, 12, 4, 10, 13, 3, 11, 13, 2, 12, 13, 1, 13, 14, 1, 14, 16, 2, 15, 18, 4, 16, 19, 3, 17, 19, 2, 18, 19, 1}); Y.SetIt(false, new double[] {3,9,11,15,13,13,17,21,25,27,25,27,29,33,35,37,37,39}); // Perform Principal Component Regression Regress.PCRegress(y,A,b,ycalc,null,1); // Errors error.Sub(ycalc,y); } }


Declaration
Procedure PCRegress(y: TVec; A: TMtx; b: TVec; Weights: TVec; YCalc: TVec = nil; Bse: TVec = nil; NumOmmit: Integer = 1);
 Parameter  Description 
Weights Defines weights for PC regression. 

Description
Performs weighted PC regression.

Copyright 2008 Dew Research
http://www.dewresearch.com