필터 지우기
필터 지우기

Non-linear regression

조회 수: 4 (최근 30일)
Keegan Carvalho
Keegan Carvalho 2018년 10월 8일
다시 열림: Walter Roberson 2018년 12월 22일
I have come across the documentations for regression but am a little confused. I wanted to obtain a non-linear regression model using the following: 'sea', 'sst' and 'at'. (See files attached). I wanted to check how sst and at affect sea levels. (something similar like: 'sea' = 'sst' + 'at')
I came across this sample code:
load carbig
tbl = table(Horsepower,Weight,MPG);
modelfun = @(b,x)b(1) + b(2)*x(:,1).^b(3) + ...
b(4)*x(:,2).^b(5);
beta0 = [-50 500 -1 500 -1];
mdl = fitnlm(tbl,modelfun,beta0)
However, when I tried it on my data, I got a bad result. I would be grateful if someone could help me obtain the non-lin reg model for my data. If possible, could you send me the code too.
Thanks!
  댓글 수: 5
Keegan Carvalho
Keegan Carvalho 2018년 10월 8일
The link is not available. The number of variables is 3 so I used the code:
beta0 = [100 100 100];
But i still get an error:
Error using internal.stats.parseArgs (line 42) Wrong number of arguments.
Error in NonLinearModel.fit (line 1385) internal.stats.parseArgs(paramNames, paramDflts, otherArgs{:});
Error in fitnlm (line 99) model = NonLinearModel.fit(X,varargin{:});
Kevin Chng
Kevin Chng 2018년 10월 8일
Edited my comment. Sorry for the missing.

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

답변 (1개)

Image Analyst
Image Analyst 2018년 10월 8일
I think you're being overly optimistic if you think that data can be modeled -- predicted by some analytical function.
data = readtable('ban1.csv')
years = data.year;
sea = data.sea;
sst = data.sst;
at = data.at;
subplot(2, 2, 1);
plot(years, sea, 'b-', 'LineWidth', 2);
grid on;
title('sea vs. year', 'FontSize', 20);
xlabel('Year', 'FontSize', 20);
ylabel('sea', 'FontSize', 20);
subplot(2, 2, 2);
plot(years, sst, 'b-', 'LineWidth', 2);
xlabel('Year', 'FontSize', 20);
grid on;
hold on;
plot(years, at, 'r-', 'LineWidth', 2);
grid on;
title('sst and at vs. year', 'FontSize', 20);
legend('sst', 'at', 'location', 'west');
subplot(2, 2, 3)
scatter(sst, sea, 'filled');
grid on;
title('sea vs. sst', 'FontSize', 20);
xlabel('sea', 'FontSize', 20);
ylabel('sst', 'FontSize', 20);
subplot(2, 2, 4)
scatter(sst, at, 'filled');
grid on;
title('at vs. sst', 'FontSize', 20);
xlabel('sea', 'FontSize', 20);
ylabel('at', 'FontSize', 20);

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by