Trouble with glmfit using binomial distribution and logit
Show older comments
I'm trying to perform logistic regression on a dataset using glmfit. Here is my code:
N = ones(size(feature));
initcoeff = glmfit(feature(:, 1:(w-1)), [feature(:, w) N], ...
'binomial', 'link', 'logit');
w is the width of feature. feature is an array in which each row is an example, and each column is a feature of that example. The last column is a binary vector with the labels for each example as 0 or 1.
When I use 'binomial' as the distribution, I get the following error:
??? Error using ==> glmfit at 171
Y must be a two column matrix or a vector for the binomial distribution.
Error in ==> comptrain at 28
initcoeff = glmfit(feature(:, 1:(w-1)), [feature(:, w) N], 'binomial', 'link',
'logit');
I'm not sure what to do, because Y (feature(:, w)) is a vector. Using other distributions instead of binomial yields an array index mismatch error from somewhere within glmfit.
Any help would be appreciated. Thanks!
Accepted Answer
More Answers (0)
Categories
Find more on Binomial Distribution 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!