Binomial Logistic regression & the posterior probability
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (0)
Vedere anche
Categorie
Scopri di più su Linear Regression in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!