Can I use "fitnlm" for multiple regression ? and How?

조회 수: 3 (최근 30일)
Riyadh Muttaleb
Riyadh Muttaleb 2019년 3월 25일
댓글: Riyadh Muttaleb 2019년 3월 26일
Hi everybody,
I have mutiple nonlinear regression like (x1,x2,x3 and y) the equation is "y=x1+x2^n+x3^n" , where n is known, , can I use "fitnlm" function and how can set up it?
Thyanks in advance,
Riyadh
  댓글 수: 6
Image Analyst
Image Analyst 2019년 3월 26일
If the x are your measurements (training data) and n is some known fractional value, then what are your unknown parameters?
Is there a weighting factor in front of each x that multiplies it??? Likd "y = c1 * x1 + c2 * x2^n + c3 * x3^n" where the c are the unknowns to be solved for????
Or did you mean that actually n is unknown (to be solved for) and there are no weighting/scaling factors multiplying the x?
By the way, in cases like this I'd use fitnlm(). In fact I always use fitnlm() because I think it's more general and can automatically handle the linear case when needed.
Riyadh Muttaleb
Riyadh Muttaleb 2019년 3월 26일
I wrote the equation that I want to solve, the regeression gives the constants (a,b,c, and d)
y=a+b*x1+c*x2^n+d*x3^n;
IF this equation can be solved with "fitnlm" PLEASE let me know how? n is fractional (from 0.1-3)

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

답변 (1개)

dpb
dpb 2019년 3월 25일
Well, I take that back...actually you could do it with fitlm if you do a change of variable...
u1=x2.^n;
u2=x3.^n;
t=table(x1,u1,u2,y);
lm=fitlm(t,'y~x1+u1+u2');
I've used fitlm very little, so I'm sorta' shootin' in the dark, but I believe that's correct.
I can't figure out the doc to use the variables outside the table; it's the most confusing description and lacking in useful examples... :(
  댓글 수: 3
dpb
dpb 2019년 3월 25일
Well, post back if this works...and if you know how to use just the defined variables, I'd be interested in seeing that syntax of how to reference the X,Y arrays in the model spec...
It's just too confusing for occasional use; I suppose if one works with it continusously one would learn the nuances and how the designers intended it to work.
dpb
dpb 2019년 3월 26일
[OP Answer moved to comment...dpb]
Sure,
lm=fitlm([x1 x2 x3],y)
where x2=x^n, x3=u^n

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by