How to make 3d plot to model logistic regression?

8 views (last 30 days)
I am trying to create a 3d plot of probability as the z-axis, C and P as the x-axis and y-axis. C should have the range of 0 to 320; P should have the range of 0 to 0.58. Could someone please help me out with this coding?
a0 = -3.936212854;
a1 = 0.140718658;
a2 = -0.102108952;
[C] = meshgrid(0, 320);
[P] = meshgrid(0, 0.58);
[z_TNTP30] = a0+a1.*C+a2.*P;
[Prob] = 1./(1+exp(z_TNTP30));
mesh(Prob)

Answers (1)

KSSV
KSSV on 24 Nov 2021
a0 = -3.936212854;
a1 = 0.140718658;
a2 = -0.102108952;
m = 100 ; n = 100 ;
C = linspace(0, 320,m);
P = linspace(0, 0.58,n);
[C,P] = meshgrid(C,P);
z_TNTP30 = a0+a1.*C+a2.*P;
Prob = 1./(1+exp(z_TNTP30));
surf(C,P,Prob)
shading interp
colorbar
%
mesh(Prob)

Tags

Community Treasure Hunt

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

Start Hunting!