フィルターのクリア

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 Center および File ExchangeSupport Vector Machine Regression についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by