Trouble with glmfit using binomial distribution and logit
이전 댓글 표시
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!
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Univariate Discrete Distributions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!