In fitglm(), logistic regression, when response is two columns matrix, the response in the table can not be recognized
8 views (last 30 days)
Show older comments
age = categorical([1,1,1,1,1,2,2,2,2,2,3,3,3,3,3]');
stage = categorical([1,2,3,4,5,1,2,3,4,5,1,2,3,4,5]');
y = [11,15,2,5,18,3,3,5,0,1,4,4,3,3,2]';
m = [12,16,4,18,19,4,7,8,25,3,5,12,15,93,5]';
resp = [y,m];
data = table(resp, age, stage);
% data = table(age, stage, resp); % This works.
mdl = fitglm(data, 'resp ~ age + stage', 'Distribution', 'binomial', 'link', 'logit');
When 'resp' is at the last column in the table, this works well. But when resp is not in the last column, fitglm() doesn't work;
The error is "Response variable must be a numeric vector".
3 Comments
the cyclist
on 25 Feb 2019
Thanks for submitting the bug report, and reporting back!
Searching the bug reports for "fitglm" doesn't currently find anything, but hopefully it gets fixed in the next release.
Answers (0)
See Also
Categories
Find more on 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!