-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmvpredict.m
46 lines (39 loc) · 1.11 KB
/
mvpredict.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
function [ypred] = mvpredict(X,b,lv,b0)
%MVPREDICT -- predict y-values from multivariate model
%
% Usage:
% [ypred] = mvpredict(X,b,lv,b0)
%
% Inputs:
% X predictor variables
% b regression coefficients
% lv number of latent variables to use
% b0 mean y from calibration data (optional)
%
% Outputs:
% ypred predicted response values
%
% Description:
% Predict response values from multivariate model.
%
% Copying:
% MVARTOOLS, Copyright (C) 1999-2001 Rune Mathisen <[email protected]>
% MVARTOOLS comes with ABSOLUTELY NO WARRANTY; for details type
% `mvwarranty'. This is free software, and you are welcome to
% redistribute it under certain conditions; type `mvcopying' for
% details. For more information on MVARTOOLS, type 'mvreadme'.
% $Id: mvpredict.m,v 1.2 2001/12/04 09:47:48 rune Exp $
[m,n] = size(X);
[p,q] = size(b);
if q ~= n,
error('X and b must have same length!')
end
if lv > p,
error(['Max number of latent variables: ' num2str(p)])
end
if nargin < 4,
b0 = 0;
end
% predicting values
ypred = b0 + X*b(lv,:)';
%end of mvpredict