Is the code for binary logistic regression is correct using glmfit? I am new in this domain , so confused a bit

1 Ansicht (letzte 30 Tage)
%%
clc
clear all
close all
warning off
%%
g=[2.7810836 2.550537003 0
1.465489372 2.362125076 0
3.396561688 4.400293529 0
1.38807019 1.850220317 0
3.06407232 3.005305973 0
7.627531214 2.759262235 1
5.332441248 2.088626775 1
6.922596716 1.77106367 1
8.675418651 -0.242068655 1
7.673756466 3.508563011 1];
contr=g(:,[1:2]);
detection=g(:,3);
%%
b=glmfit(contr, detection, 'binomial');
%%
p = 1./(1+exp(-1*(b(1)+b(2)*g(:,1)+b(3)*g(:,3))));
s=[];
for i=1:length(p)
if(p(i)>=0.5)
s=[s 1];
else
s=[s 0];
end
end

Antworten (0)

Kategorien

Mehr zu Biological and Health Sciences finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by