Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

using logistic regression on matlab for given x and y

Asked by seongwoo oh on 18 Nov 2012

Hello

I have a set of x and y values that i want to plot the logistic regression of.

I was looking at glmft built in function but it seems to take more than inputs x and y

All i wanna do is to come up with logistic fit of the given x and y values on x y plane.

Any thoughts?

(I do have cf toolbox but the program needs to be self contained and i m looking for a built in function or a code that spits out coefficients for logistic model)

0 Comments

seongwoo oh

Products

No products are associated with this question.

1 Answer

Answer by Tom Lane on 19 Nov 2012

Here's a way to fit a logistic curve to continuous data using Curve Fitting:

>> x = rand(100,1);
>> y = 1./(1+exp(-3*(x-.5))) + randn(size(x))/100;
>> fit(x,y,'1./(1+exp(b1+b2*x))','start',[ -1 1])
ans = 
     General model:
     ans(x) = 1./(1+exp(b1+b2*x))
     Coefficients (with 95% confidence bounds):
       b1 =       1.517  (1.494, 1.54)
       b2 =      -3.037  (-3.079, -2.996)

2 Comments

Lalit Patil on 15 Dec 2012

Sir, i seen your answer, and i have done the same thing at below link using SVD.. Here i am getting four coefficients..

http://www.mathworks.in/matlabcentral/answers/54780-how-to-do-svd-without-function

So, can i do the same thing with your method to find the coefficients..?

Tom Lane on 20 Dec 2012

I don't see the connection between your logistic question and the svd issue.

Tom Lane

Contact us