フィルターのクリア

Error in non-linear regression

3 ビュー (過去 30 日間)
Keegan Carvalho
Keegan Carvalho 2018 年 10 月 8 日
コメント済み: Keegan Carvalho 2018 年 10 月 8 日
I am trying to prepare a non-linear reg model with the following variables in the following way: sea ~ sst + at
I am receiving an error when applying the beta) function and the fitnlm function. So far, this is what I've done:
t=readtable('ban1.csv')
sea=t(:,2)
sst=t(:,3)
at=t(:,4)
tbl=table(sea,sst,at)
modelfun = @(b,x)b(1) + b(2)*sst + b(3)*at;
When i try to apply the beta0:
beta0 = 10*rand(var,1);
I get the error:
Not enough input arguments.
Error in var (line 65) if isinteger(x)
And when i tried beta0 = [-50 500 -1 500 -1]; mdl = fitnlm(tbl,modelfun,beta0);
I get the following errors:
Error using classreg.regr.FitObject/selectVariables (line 289) Predictor variables must be numeric vectors or matrices.
Error in NonLinearModel/selectVariables (line 1157) model = selectVariables@classreg.regr.ParametricRegression(model);
Error in classreg.regr.FitObject/doFit (line 91) model = selectVariables(model);
Error in NonLinearModel.fit (line 1434) model = doFit(model);
Error in fitnlm (line 99) model = NonLinearModel.fit(X,varargin{:});
I would be grateful if someone could help me with this problem, preferably with the code. I have attached the csv file. Thanks!

回答 (1 件)

Torsten
Torsten 2018 年 10 月 8 日
t = readtable('ban1.csv')
sea = t(:,2)
sst = t(:,3)
at = t(:,4)
A = [ones(numel(sea),1),sst,at];
rhs = sea;
b = A\rhs
give you the parameters you are looking for.
Best wishes
Torsten.
  1 件のコメント
Keegan Carvalho
Keegan Carvalho 2018 年 10 月 8 日
Thanks @Torsten. I still am getting some errors.
>> A = [ones(numel(sea),1),sst,at]; All input arguments must be tables.
>> rhs = sea; >> b = A\rhs Undefined function or variable 'A'.
Also, how do I know what the equation?
Please excuse my questions, as I am a beginner in this.

サインインしてコメントする。

カテゴリ

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