comparison scripts/statistics/base/ols.m @ 12547:17997376291b

Fix variable name clash in ols.m
author Michael Creel <michael.creel@uab.es>
date Tue, 29 Mar 2011 07:36:31 -0600
parents c792872f8942
children 6b2f14af2360
comparison
equal deleted inserted replaced
12546:39ca02387a32 12547:17997376291b
99 if (nr != ry) 99 if (nr != ry)
100 error ("ols: number of rows of X and Y must be equal"); 100 error ("ols: number of rows of X and Y must be equal");
101 endif 101 endif
102 102
103 z = x' * x; 103 z = x' * x;
104 r = rank (z); 104 rnk = rank (z);
105 105
106 if (r == nc) 106 if (rnk == nc)
107 beta = inv (z) * x' * y; 107 beta = inv (z) * x' * y;
108 else 108 else
109 beta = pinv (x) * y; 109 beta = pinv (x) * y;
110 endif 110 endif
111 111
112 if (isargout (2) || isargout (3)) 112 if (isargout (2) || isargout (3))
113 r = y - x * beta; 113 r = y - x * beta;
114 endif 114 endif
115 if (isargout (2)) 115 if (isargout (2))
116 sigma = r' * r / (nr - r); 116 sigma = r' * r / (nr - rnk);
117 endif 117 endif
118 118
119 endfunction 119 endfunction
120 120
121 %!test 121 %!test