Using a regression model to find its coefficients

조회 수: 9 (최근 30일)
Miriam Contreras Castillo
Miriam Contreras Castillo 2022년 10월 22일
댓글: Krista Blide 2023년 11월 28일
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)];
Unrecognized function or variable 'a'.
b = (X' * X) \ (X' * v)
  댓글 수: 1
John D'Errico
John D'Errico 2022년 10월 22일
편집: John D'Errico 2022년 10월 22일
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.

댓글을 달려면 로그인하십시오.

채택된 답변

Image Analyst
Image Analyst 2022년 10월 22일
That, a*(x/(x+b)), is the Michaelis-Menten rate equation. I have a demo for that. Plug in your data and try it.
%-----------------------------------------------------------------------------------------------------------------------------------
% Fit a vertically shifted version of the the Fluorescence Recovery Curve (Michaelis-Menten function).
% One common non-linear equation is the Michaelis-Menten function,
% which is used to describe the reaction rate as a function of substrate concentration.
% The Michaelis-Menten function is characterized by a steep rise that gradually flattens into a plateau.
% Initially, small increases in substrate concentration cause a substantial increase in reaction rate,
% but eventually, additional increases in concentration cause progressively smaller increases in reaction rate.
% Eventually reaction rate plateaus and does not respond to increases in concentration.
% The Michaelis-Menten function has this form:
% rate = Vmax*C / (K + C)
% where r is the growth rate (the dependent variable),
% C is the concentration (the independent variable),
% Vm is the maximum rate in the system, and
% K is the concentration at which the reaction rate is Vm/2.
% These last two parameters (Vm and K) are the Michaelis-Menten parameters to be fit.
% Rewritten in X and Y, you get:
% Y = b1 * X ./ (b2 + X)
% Ref: http://strata.uga.edu/8370/lecturenotes/nonlinearRegression.html
% https://www.graphpad.com/guides/prism/7/curve-fitting/index.htm?reg_classic_hyperbola.htm
  댓글 수: 2
Image Analyst
Image Analyst 2022년 10월 23일
@Miriam Contreras Castillo Haven't heard from you. Did you have trouble adapting the code?
Krista Blide
Krista Blide 2023년 11월 28일
Thanks for this code!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Linear Regression에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by