View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Four parameters logistic regression - There and back again

4.9 | 7 ratings Rate this file 23 Downloads (last 30 days) File Size: 4.46 KB File ID: #38122 Version: 1.1
image thumbnail

Four parameters logistic regression - There and back again



11 Sep 2012 (Updated )

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

| Watch this File

File Information

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)
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.


Required Products Curve Fitting Toolbox
MATLAB release MATLAB 7.11 (R2010b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (17)
18 Nov 2016 Miguel Pabon

15 Nov 2016 Gaetano Carlucci

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.

Comment only
10 Nov 2016 Giuseppe Cardillo

simply, use L4Pinv that is into the zip file

Comment only
09 Nov 2016 Gaetano Carlucci


thanks for your job!

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.

19 Aug 2016 Neuropharmer

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.

Comment only
30 Jun 2016 Anders

Anders (view profile)

29 Feb 2016 D C

D C (view profile)

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

28 Jan 2016 Giuseppe Cardillo

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?

Comment only
28 Jan 2016 Mark Ferris

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:

Error in SensorResponseCode6 (line 56)

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.

Comment only
30 Sep 2014 Giuseppe Cardillo

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

Comment only
29 Sep 2014 Ufop

Ufop (view profile)

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

load x.txt
load y.txt

[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_);


Comment only
05 Mar 2014 Andrew Horchler

23 Apr 2013 Hugo Gasca-Aragon

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).

02 Apr 2013 Giuseppe Cardillo

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

Comment only
02 Apr 2013 Daniel

Daniel (view profile)

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

Comment only
02 Apr 2013 Daniel

Daniel (view profile)

29 Jan 2013 Jessica Inskip

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

Comment only
03 Apr 2013 1.1

I uploaded L5Pinv instead of L4Pinv

Contact us