MCPcopy Create free account
hub / github.com/BoevaLab/FREEC / lrbuild

Function lrbuild

src/linreg.cpp:70–101  ·  view source on GitHub ↗

Linear regression Subroutine builds model: Y = A(0)*X[0] + ... + A(N-1)*X[N-1] + A(N) and model found in ALGLIB format, covariation matrix, training set errors (rms, average, average relative) and leave-one-out cross-validation estimate of the generalization error. CV estimate calculated using fast algorithm with O(NPoints*NVars) complexity. When covariation matrix is calcul

Source from the content-addressed store, hash-verified

68 Copyright 02.08.2008 by Bochkanov Sergey
69*************************************************************************/
70void lrbuild(const ap::real_2d_array& xy,
71 int npoints,
72 int nvars,
73 int& info,
74 linearmodel& lm,
75 lrreport& ar)
76{
77 ap::real_1d_array s;
78 int i;
79 double sigma2;
80
81 if( npoints<=nvars+1||nvars<1 )
82 {
83 info = -1;
84 return;
85 }
86 s.setbounds(0, npoints-1);
87 for(i = 0; i <= npoints-1; i++)
88 {
89 s(i) = 1;
90 }
91 lrbuilds(xy, s, npoints, nvars, info, lm, ar);
92 if( info<0 )
93 {
94 return;
95 }
96 sigma2 = ap::sqr(ar.rmserror)*npoints/(npoints-nvars-1);
97 for(i = 0; i <= nvars; i++)
98 {
99 ap::vmul(&ar.c(i, 0), 1, ap::vlen(0,nvars), sigma2);
100 }
101}
102
103
104/*************************************************************************

Callers 5

runEMFunction · 0.85
runEMlogFunction · 0.85
calculateRatioUsingCGMethod · 0.85
calculateRatioMethod · 0.85

Calls 3

lrbuildsFunction · 0.85
vmulFunction · 0.85
setboundsMethod · 0.45

Tested by

no test coverage detected