Error in non-linear regression
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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!
0 Commenti
Risposte (1)
Torsten
il 8 Ott 2018
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.
Vedere anche
Categorie
Scopri di più su Linear and Nonlinear Regression in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!