## Matlab多元非线性回归（nlinfit 函数）

#### 1. 基本语法

beta = nlinfit(X, Y, modelfun, beta0) X -> 预测变量
Y -> 响应值
modelfun -> 指定的模型
beta0 -> 参数初始值
beta = nlinfit(X, Y, modelfun, beta0, options) options -> 评估算法的选择，默认为缺省，详见 options参考内容
beta = nlinfit(___, Name, Value) 指定可选的逗号分隔的名称、值参数对。
Name是参数名，Value是对应的值，参数名必须出现在引号内。

[beta, R, J, CovB, MSE, ErrorModelInfo] = nlinfit(___) R -> 残差
J -> 雅可比矩阵
CovB -> 估计方差-协方差矩阵
MSE -> 均方差
ErrorModelInfo -> 误差模型拟合信息

#### 2. 示例

``````X = 1 : 10;
Y = [0 4 8 17 29 34 54 62 80 99];
mymodel = inline('beta(1) * X .^ beta(2)', 'beta', 'X');
beta0 = [1, 2];
beta = nlinfit(X, Y, mymodel, beta0);
``````

``````X = 1 : 10;
Y = [0 4 8 17 29 34 54 62 80 99];
mymodel = inline('beta(1) * X .^ beta(2)', 'beta', 'X');
beta0 = [1, 2];
[beta, R, J, CovB, MSE, ErrorModelInfo] = nlinfit(X, Y, mymodel, beta0);
``````

``````beta =

1.203177103441870   1.913267782105321

R =

-1.203177103441870
-0.531902426953979
-1.844423386925135
-0.069922248918235
2.839481428235956
-3.080132352538584
4.200106803860550
-2.295789744078874
-0.547303920433009
0.463452664946701

J =

1.0e+02 *

0.009999999999931                   0
0.037666127981753   0.031412881732651
0.081820231121898   0.108152737129980
0.141873719717092   0.236641274909903
0.217428643531115   0.421041233755697
0.308185129687587   0.664393679618334
0.413903226770619   0.969072093923712
0.534383368398917   1.337009450489727
0.669455022058049   1.769827653002497
0.818969511416963   2.268918061872248

CovB =

0.036203997364694  -0.013926635931111
-0.013926635931111   0.005406465988118

MSE =

5.764136230306152

ErrorModelInfo =

ErrorModel: 'constant'
ErrorParameters: 2.400861560004273
ErrorVariance: @(x)mse*ones(size(x,1),1)
MSE: 5.764136230306152
ScheffeSimPred: 3
WeightFunction: 0
FixedWeights: 0
RobustWeightFunction: 0
``````