Problem interpreting regression coefficient output
2 views (last 30 days)
Show older comments
I'm try and compute regression coeffients between mean free joint angles (ankle, hip, knee angles time-normalised to 101 data points) as predictor variables (X = x1, x2, x3) and changes in the mean-free foot COM as an outcome variable (y)
I've just entered the following into Matlab:
X = [ones(size(x1)x1 x2 x3];
B = X\y
where the dimensions of y, x1, x2, and x3 are 1 x 20 each. However the B output is giving me a 80 x 20 matrix filled with zeros apart from row 44 that contains a range of values (e.g 0.0006 0.0033 -0.002 etc). Are these the coeffiecents as I was expecting a single vector column of coefficients?
Any help would be appreciated.
0 Comments
Answers (1)
Star Strider
on 29 Aug 2012
Edited: Star Strider
on 29 Aug 2012
You need to transpose x1, x2, and x3 to be [20 x 1] to form your X matrix:
X = [ones(length(x1),1) x1' x2' x3'];
and if y is not also already a column vector, it needs to be. Assuming y is currently a row vector as well, your multiple linear regression parameter estimation statement becomes:
B = X\y';
That should work.
That the B you calculated is an [80 x 20] matrix filled with zeros results from your current X (not the one I constructed here) being an 80-element row vector rather than the [20 x 4] matrix you intended.
0 Comments
See Also
Categories
Find more on Linear Regression 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!