run regression, change the value of x and calculate how y changes, and then plot both

조회 수: 1 (최근 30일)
(Revised) Suppose I have a table T
y x1 x2
10 3 4
7 2 3
5 1 2
run a regression
mdl =fitlm([T.X1, T.X2],T.y)
Then I now want to calculate T.y1 for T.x3= T.x1-1 using the above fitlm formula
y x1 x2 x3
10 3 4 2
7 2 3 1
5 1 2 0

채택된 답변

Image Analyst
Image Analyst 2021년 7월 28일
Use a for loop to alter T.X1
for numRuns = 1 : 10 % However many you want
x = [T.X1, T.X2];
mdl =fitlm(x, T.y)
% Plot stuff...
plot(x, T.y, '-');
grid on;
hold on;
% Now do something with mdl, like get T.y1.
% Now decrement T.X1 by 1 and do the next run.
T.X1 = T.X1 - 1;
end
  댓글 수: 5
Image Analyst
Image Analyst 2021년 7월 28일
Wow, that's helpful.
Maybe I'll get to it someday then.
So, did you try to adapt the for loop where I reduced X1 by 1 on each iteration? If not, why not?
alpedhuez
alpedhuez 2021년 7월 28일
https://www.mathworks.com/help/stats/linearmodel.predict.html

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Support Vector Machine Regression에 대해 자세히 알아보기

태그

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by