Why don't the Inner matrix dimensions agree when adding an extra variable?
Show older comments
I'm using multiple regression to obtain the coefficients from 3 predictor variables (x1, x2, x3, each a [1 x 20] array) and two outcome variables (x and y, each a [1 x 20] array). Using the following code:
X = [ones(length(x1),1) x1' x2' x3'];
B = X\devY';
B(1,:)=[]
J = B';
Z = null(J);
to import the [4 x 2] coefficients into a [2 x 3] Jacobian matrix (J) (removing the constant values) from which the null(J)is used to calculate an output known as the UCM using the following code:
for i = 1:N
UCM(:,i) = (Z'*dev(:,i))*Z;
end
This code works for 3 predictor and 2 output variables. However if I add an extra predictor variable (x4) (a [1 x 20] array) I get the following warning:
Error using ==> mtimes Inner matrix dimensions must agree.
Any help would be appreciated.
4 Comments
Jan
on 22 Nov 2012
Please learn how to format code in this forum.
Star Strider
on 22 Nov 2012
What sizes are Z and dev?
Tim Bennett
on 22 Nov 2012
Edited: Tim Bennett
on 22 Nov 2012
Tim Bennett
on 25 Nov 2012
Edited: Tim Bennett
on 25 Nov 2012
Answers (0)
Categories
Find more on Operators and Elementary Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!