필터 지우기
필터 지우기

Binomial Logistic regression & the posterior probability

조회 수: 2 (최근 30일)
Iana Ladygina
Iana Ladygina 2020년 4월 18일
Hi everyone! I have a question regarding a logistic regression model and the prediction of the posterior probability. I have the matrix of A, where the column 2 and 3 are the predictors, and the last column 4 is the target variable. I'm trying to apply the logistic regression model to get the coefficients, and then to use it to predict the posterior probability. In my case, using the model I did, I get 7.6060 which is wrong. Can anyone point out on my mistake? P.S. I believe that the model glm is incorrect since the estimates seem to be wrong.
student_ID = {'5003','5190','5090','5670'}';
hours_studied = [4.85 8.62 5.43 9.21]';
hours_slept = [9.63 3.23 8.23 6.34]';
passed = [1 0 1 0]';
T = table(student_ID, hours_studied, hours_slept, passed);
A = table2array(T(:,2:4));
XX = double(A(:,[1,2]));
YY = logical(A(:,3));
%Fit a logistic regression model using the data
glm = GeneralizedLinearModel.fit(XX,YY,'linear','Distribution','binomial','link','logit');
Xpred = [6.5 2];
ppred = glm.predict(Xpred) %the answer is 7.6060

답변 (0개)

카테고리

Help CenterFile Exchange에서 Linear Regression에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by