Error using mnrfit(); Issue with linsolve (Matrix must be positive definite)

I am trying to predict one of three possible activities using various predictor variables. My inputs are Classifications, a [30,1] matrix with 10 instances of each activity (ie. 1-10 is sitting, 11-20 is standing, and 21-30 is walking). 'Classifications' is a categorical matrix similar to the example (https://www.mathworks.com/help/stats/mnrfit.html). My prediction variable matrix 'AllData' is a [30,50] matrix where the 50 variables correspond to 10 anatomical regions with 5 measures taken at each region. Values range from 0 to ~155.0 for the predictor measures. When i run:
MLR = mnrfit(AllData,Classifications);
The code executes, with a bunch of warnings thrown.
Warning: Matrix is close to singular or
badly scaled. Results may be inaccurate.
When I modify the code to be:
[MLR,dev,stats] = mnrfit(AllData,Classifications);
I get:
Error using linsolve
Matrix must be positive definite.
Error in mnrfit (line 248)
bcov =
linsolve(hess,eye(size(hess)),struct('SYM',true,'POSDEF',true));
Interestingly, when I invert AllData to be AllData', and adjust Classifications to be [50,1], the new code executes (ie. I get to access the stats and no erros are thrown). See sample photos.
I believe something is wrong with the nature of how my values are assorted in AllData; however, I have tried changing the 0 values to be numbers and still get the error. Maybe something is wrong with how it is physically organized as the same values run when inverted.
Any insight would be fantastic.

Answers (0)

Categories

Products

Release

R2017b

Asked:

on 24 Jan 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!