How to do a Four Parameters logistic regression fit without the Curve fitting toolbox?
12 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Johnny Birch
le 16 Oct 2018
Modifié(e) : Johnny Birch
le 16 Oct 2018
I have an 'X' and 'Y' vector (see below) which I want to fit to a Four Parameters logistic model: Y=D+(A-D)/(1+(X/C)^B), but I don't have access to any Matlab toolboxes. How can I do this so I end up with the A,B,C and D parameters?
X=[0.000; 0.012; 0.023; 0.047; 0.094; 0.188; 0.375; 0.750; 1.500; 3.000; 6.000; 12.000]
Y=[0.034; 0.018; 0.023; 0.036; 0.051; 0.065; 0.077; 0.128; 0.224; 0.399; 0.660; 1.0350]
0 commentaires
Réponse acceptée
Torsten
le 16 Oct 2018
Modifié(e) : Torsten
le 16 Oct 2018
function main
X = [0.000; 0.012; 0.023; 0.047; 0.094; 0.188; 0.375; 0.750; 1.500; 3.000; 6.000; 12.000];
Y = [0.034; 0.018; 0.023; 0.036; 0.051; 0.065; 0.077; 0.128; 0.224; 0.399; 0.660; 1.0350];
p0 = [2 1 1 1]; %Set initial guess for parameter vector
p = fminsearch(@(p)fun(p,X,Y),p0); % Call optimizer for fitting
Ysim = p(4)+(p(1)-p(4))./(1+(X/p(3)).^p(2)); % evaluate final logistic function at measurement points
plot(X,Y,X,Ysim) %plot measured and fitted values
end
function obj = fun(p,X,Y)
Ysim = p(4)+(p(1)-p(4))./(1+(X/p(3)).^p(2)) % evaluate logistic function at measurement points
obj = (Y-Ysim).'*(Y-Ysim) % calculate sum of squared differences between measured and fitted values
end
1 commentaire
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Least Squares dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!