syntax regression model variables
2 次查看(过去 30 天)
显示 更早的评论
Hey! Can someone explain me the following syntax:
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(ds,modelfun,beta0)
mdl = MPG~ b1 + b2*Horsepower^b3 + b4*Weight^b5
In particular I dont understand: (b,x)- this doesnt take any column of the dataset,right? x(:,1)- does this give me the first column of the dataset? x(:,1)-does this give me the second column of the dataset?
In beta0 I specify then the values of b1, b2 and b4? Or what is it for?
Thanks for your help!
0 个评论
采纳的回答
Roger Wohlwend
2014-6-16
The variable modelfun is a function handle and it defines the nonlinear model. Perhaps you should read the Matlab documentation about function handles first before you proceed with the regression. The first part of the handle - @(b,x) - tells matlab that the equation contains two variables: b (the coefficients) and x (the independent variables). Afterwards it shows the model.
Yes, x(:,1) is the first column of the matrix x.
beta0 specifys the inital values for the regression coefficients. Matlab needs them as a starting point for the optimization.
6 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Nonlinear Regression 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!