设自变量和因变量y的观测值为
0.4 | 0.6 | 1.7 | 1.9 | 3.1 | 4.7 | 9.4 | 10.1 | |
23 | 34 | 65 | 36 | 19 | 24 | 44 | 31 | |
163 | 157 | 123 | 143 | 37 | 59 | 46 | 117 | |
y | 60 | 61 | 77 | 54 | 71 | 54 | 81 | 93 |
利用MATLAB调用regress命令
>> y=[60,61,77,54,71,54,81,93];
>> x=[0.4 0.6 1.7 1.9 3.1 4.7 9.4 10.1;23 34 65 36 19 24 44 31;163 157 123 143 37 59 46 117]
x = 0.4000 0.6000 1.7000 1.9000 3.1000 4.7000 9.4000 10.1000
23.0000 34.0000 65.0000 36.0000 19.0000 24.0000 44.0000 31.0000
163.0000 157.0000 123.0000 143.0000 37.0000 59.0000 46.0000 117.0000
>> [b,bint,r,rint,stats]=regress(y',x')
Warning: R-square and the F statistic are not well-defined unless X has a column of ones.
Type "help regress" for more information.
> In regress at 162
b =
5.0393
0.6510
0.2243
bint =
0.9638 9.1149
-0.3599 1.6620
-0.0507 0.4994
r =
6.4459
0.6228
-1.4749
-11.08
34.7088
1.4556
-5.3333
-4.3247
rint =
-28.8627 41.7545
-39.9677 41.2133
-24.7593 21.8095
-51.8311 29.6515
19.1880 50.2295
-44.5546 47.4658
-38.0886 27.4219
-33.7044 25.0550
stats = -0.0276 5.0244 0.0636 284.2121
回归方程为