Error using glmfit: Second column in Y?
显示 更早的评论
Hi everyone,
I'm currently trying to use glmfit like this:
B2 = glmfit(x(c,:),y,'binomial');
With y being a n x 1 matrix with 1's and 2's for group one and two. However, it keeps giving me the following error:
For the binomial distribution, Y must be a binary vector or a matrix with two columns with the number of trials in the second column.
My question is: Should I ad a second column with 1:number of observations? Example below:
y = [1,1; 1,2; 1,3; 1,4; 2,5; 2,6; 2,7; 2,8];
Best regards,
Eric
采纳的回答
更多回答(1 个)
Saurabh Gupta
2017-7-21
0 个投票
As the error suggests, Y should
1) either be a binary vector i.e. a vector of 0s and 1s only (other values, like 2, are not allowed),
2) or a 2-column matrix where second column is "the number of trials" as demonstrated by the example at the following link.
Hope this helps!
类别
在 帮助中心 和 File Exchange 中查找有关 Binomial Distribution 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!