Using a regression model to find its coefficients
Afficher commentaires plus anciens
Hello,
I am testing different regression models and finding the a and b coefficents. I am having trouble puting the following model: V = a*(x/(x+b))
So far this is what I have but it gives me an error that 'a' is an unreconized variable. Please help, thank you!
w= [0.3 3 4 15 35 80 600 1100]';
v = log([0.01 0.3 0.4 2 6 7 10 100]');
plot(w, v, 'b.-', 'LineWidth', 2, 'MarkerSize', 20)
grid on;
X = [ log(a) log(x) log(x-b)];
b = (X' * X) \ (X' * v)
1 commentaire
John D'Errico
le 22 Oct 2022
Modifié(e) : John D'Errico
le 22 Oct 2022
Why do you think you can use a bad formula to compute the results of a LINEAR regression to solve a nonlinear regression? In fact, what you have written will not even work crrectly for a LINEAR regression! (You got that formula wrong anyway.)
Why are you computing the logs of those terms? Yes, I know. You think that by computing the log, you have linearized the model. That does not work here.
This is a NONLINEAR regression. It cannot be linearized for a solution by taking the log.
My guess is you were told to linearize the problem, and your teacher only showed you how to linearize a model by taking the log, then threw you into the deep end of the pool for this assignment.
CAN you linearize it, by transforming the model in other ways? Well, yes. Technically, it can, though that screws around with the error structure in a very different way. But if you don't care about no steenkin error structure, then consider what happens if you multiply both sides of the expression
y = a*x/(x+b)
by the term (x+b). What happens now? Is this relation now linear in the unknowns, thus a and b?
Finally, learn how to correctly compute the unknowns. That is NOT by the expression (X' * X) \ (X' * v), which is not ony a bad way to solve it, it is not even correct at all. In fact, in the case of your problem, you can just use polyfit to estimate the unknowns at the end.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Linear Regression dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

