


function co = cosn(H); computes the cosine of the angle between the H(:,1) and its projection onto the span of H(:,2:end) Not the same as multiple correlation coefficient since the means are not zero Copyright (C) 2008-2010 Dynare Team This file is part of Dynare. Dynare is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Dynare is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Dynare. If not, see <http://www.gnu.org/licenses/>.


0001 function [co, b, yhat] = cosn(H); 0002 0003 % function co = cosn(H); 0004 % computes the cosine of the angle between the H(:,1) and its 0005 % projection onto the span of H(:,2:end) 0006 % 0007 % Not the same as multiple correlation coefficient since the means are not 0008 % zero 0009 % 0010 % Copyright (C) 2008-2010 Dynare Team 0011 % 0012 % This file is part of Dynare. 0013 % 0014 % Dynare is free software: you can redistribute it and/or modify 0015 % it under the terms of the GNU General Public License as published by 0016 % the Free Software Foundation, either version 3 of the License, or 0017 % (at your option) any later version. 0018 % 0019 % Dynare is distributed in the hope that it will be useful, 0020 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0021 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0022 % GNU General Public License for more details. 0023 % 0024 % You should have received a copy of the GNU General Public License 0025 % along with Dynare. If not, see <http://www.gnu.org/licenses/>. 0026 0027 y = H(:,1); 0028 X = H(:,2:end); 0029 0030 b=(X\y); 0031 yhat = X*b; 0032 if rank(yhat), 0033 co = abs(y'*yhat/sqrt((y'*y)*(yhat'*yhat))); 0034 else 0035 co=0; 0036 end 0037 0038 0039