|
|
| bpredfun2(zest,zval)
|
function[res] = bpredfun2(zest,zval)
% BPREDERR helper function, passed to BSTATS.Inputs estimation and
% validation samples, each in a matrix of form z = [y x], computes
% OLS estimates for the estimation sample, and calculates squared
% prediction error vector for those validation-sample observations
% that are not found in the estimation sample.
% EXAMPLE <none> (Oh, the FEX code metrics..)
iest = zest(:,1); yest = zest(:,2); xest = zest(:,3:end);
ival = zval(:,1); yval = zval(:,2); xval = zval(:,3:end);
best = regress(yest,xest);
eval = yval - xval*best;
nval = length(eval);
for i = 1:nval
j = find(iest == ival(i));
if ~isempty(j)
eval(i) = nan;
end
end
res.b = best;
res.e = eval.^2;
|
|
Contact us at files@mathworks.com