File Exchange

## Four parameters logistic regression - There and back again

version 1.1 (4.46 KB) by

Fit data points with a four points logistic regression or interpolate data.

4.85714
7 Ratings

Updated

One big holes into MatLab cftool function is the absence of Logistic Functions. In particular, The Four Parameters Logistic Regression or 4PL nonlinear regression model is commonly used for curve-fitting analysis in bioassays or immunoassays such as ELISA, RIA, IRMA or dose-response curves. It is characterized by it’s classic “S” or sigmoidal shape that fits the bottom and top plateaus of the curve, the EC50, and the slope factor (Hill's slope). This curve is symmetrical around its inflection point.
The 4PL equation is:
F(x) = D+(A-D)/(1+(x/C)^B)
where:
A = Minimum asymptote. In a bioassay where you have a standard curve, this can be thought of as the response value at 0 standard concentration.

B = Hill's slope. The Hill's slope refers to the steepness of the curve. It could either be positive or negative.

C = Inflection point. The inflection point is defined as the point on the
curve where the curvature changes direction or signs. C is the concentration of analyte where y=(D-A)/2.

D = Maximum asymptote. In an bioassay where you have a standard curve, this can be thought of as the response value for infinite standard concentration.

In this submission there are 2 functions:
L4P - to find the 4 parameters and to fit your data (as calibrators...);
L4Pinv - to interpolate data of unknown samples onto calibrators curve.

Enjoy!

Giuseppe Cardillo

### Giuseppe Cardillo (view profile)

type help L4P and all will be explained. There is an example too.
Anyway mandatory data are, of course, x and y. You can also input 1x4 vector of starting point for A, B, C, D; 1x4 vector for lower bound of A, B, C, D and 1x4 vector for upper bound of A, B, C, D. These vectors are not mandatory; if you input only x and y the function will estimate these vectors by itself based on input data points.

Balandino Di Donato

### Balandino Di Donato (view profile)

Hi Giuseppe, I'm new to matlab. How do I fit a curve using this function? What shall I give in input?

Grazie!
B

Miguel Pabon

Gaetano Carlucci

### Gaetano Carlucci (view profile)

Hi Giuseppe,

what I need to do, given the dataset, is compute [A,B,C,D] for this function:

cf(x) = C*(((A-D)/(x-D))-1)^(1/B)

It does not seem I can do that with L4Pinv.

Thank you.

Giuseppe Cardillo

### Giuseppe Cardillo (view profile)

simply, use L4Pinv that is into the zip file

Gaetano Carlucci

### Gaetano Carlucci (view profile)

Hi,

I need to do the same thing with the inverse function:

cf(x) = C*(((A-D)/(x-D))-1)^(1/B)

Could you please have a suggestion on how to do this?

Thank you.

Neuropharmer

### Neuropharmer (view profile)

Hi Giuseppe. Thanks for uploading this very helpful pair of functions. I've been applying them to some analytical chemistry data, and L4P does a great job fitting a curve to my calibration data while L4Pinv provides a plausible prediction for the concentration of an unknown based on that calibration. I'm wondering though: is there any way I can calculate a standard error of prediction for the concentrations estimated by L4Pinv? I've previously been using simple linear regressions, for which there's a standard equation in the literature for standard error of the prediction, but I'm having a hard time finding any literature sources giving the equation for standard error of prediction when using a four parameter logistic regression. I'm tempted to just average several readings for each sample and report a standard error of those, but I get the impression it's rarely that simple a procedure with regression analysis.

Anders

D C

### D C (view profile)

Yes it is fiddly in MatLab, I recommend taking a look at www.mycurvefit.com or if you're running ELISAs then www.myassays.com

Giuseppe Cardillo

### Giuseppe Cardillo (view profile)

gosh!!! varargin is not a "function". It is Variable length input argument list. In particular, for L4P, the mandatory input data are, of course, X and Y data points. Varargin is a 1x4 vector of guessing parameters for logistic regression: if you pass it to L4P, it will use it for non linear regression; if you don't pass it, L4P will estimate the vector from your X,Y data. Is it clear now?

Mark Ferris

### Mark Ferris (view profile)

Hi Giuseppe, thanks for the curve fitting code, it should be exactly what I need. I'm not great with MATLAB though and I keep getting this error with your code:

Attempt to execute SCRIPT varargin as a function:
C:\Program
Files\MATLAB\R2015a\toolbox\matlab\lang\varargin.m

Error in SensorResponseCode6 (line 56)
args=cell(varargin);

Any idea how to fix this? Line 56 is referring to line 131 of your original code. SensorResponseCode6 is a combination of a code I wrote and your code.

Giuseppe Cardillo

### Giuseppe Cardillo (view profile)

I don't know. I should see your data points

Ufop

### Ufop (view profile)

why i get this error? I have two data measured, X and Y. I just put:

[cf G]=L4P(x,y) , and appears this error:

Error using fit>iFit (line 415)
NaN computed by model function, fitting cannot continue.
Try using or tightening upper and lower bounds on coefficients.

Error in fit (line 109)
[fitobj, goodness, output, convmsg] = iFit( xdatain, ydatain, fittypeobj, ...

Error in L4P (line 194)
[cf G] = fit(x(ok_),y(ok_),ft_,fo_);

thanks

Andrew Horchler

### Andrew Horchler (view profile)

Hugo Gasca-Aragon

### Hugo Gasca-Aragon (view profile)

C is the mean response point where y=(D+A)/2. The inflection point is where F''(x)=0, this is C*((B-1)/(B+1))^(1/B).

Giuseppe Cardillo

### Giuseppe Cardillo (view profile)

sorry, I did an error when I created the zip file. I'm uploading the correct version

Daniel

### Daniel (view profile)

Dear Giuseppe,
I cannot find your m file L4Pinv, is it uploaded somewhere else?
Thank you!

Daniel

Jessica Inskip

### Jessica Inskip (view profile)

My apologies. I had not read through the notes thoroughly; I have found the fitted curve plot.
Thanks!