Fitting nonlinear regression model

2 次查看(过去 30 天)
I have 5 input variables organized in a table:
dt, sinday, cosday, sinhour, coshour
The dependent variable is Q (number of observations).
I wrote the following script:
tbl = table(dt,sinhour,coshour,sinday,cosday);
beta0 = [0;0;0;0;0;0];
modelfun = @(b,x) b(1) + b(2)*dt + b(3)*sinhour + b(4)*coshour + b(5)*sinday + b(6)*cosday;
md1 = fitnlm(tbl,Q,modelfun,beta0);
But it is giving the following error message while running:
Error using internal.stats.parseArgs (line 42)
Wrong number of arguments.
Error in NonLinearModel.fit (line 1379)
[coefNames,predictorVars,responseVar,weights, ...
Error in fitnlm (line 94)
model = NonLinearModel.fit(X,varargin{:});
Error in nlmfitoccu (line 57)
md1 = fitnlm(tbl,Q,modelfun,beta0);
I am not been able to sort it out.

回答(1 个)

Star Strider
Star Strider 2015-8-19
Two observations:
  1. ‘Q’ is not defined, and does not appear to be necessary in your argument list in any event;
  2. Your regression is actually linear, so you could use the regress or fitlm functions to get the parameters and statistics.

类别

Help CenterFile Exchange 中查找有关 Nonlinear Regression 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by