用matlab求一元多项式回归,并求出方差,置信区间,相关系数,F值,怎么求,求大神编程

2024-12-23 01:20:17
推荐回答(2个)
回答1:

程序如下:
t0=ones(18,1);
t1=[0 4 8 9 10 18 21 23 24 25 29 37 38 39 40 41 44 46]';
t2=t1.*t1;
c=[85.90 133.54 152.33 173.28 149.00 160.00 170.40 206.85 181.79 172.48 184.67 267.67 167.50 213.76 196.24 182.59 164.60 101.33]';
T=[t0 t1 t2];
[b,bint,r,rint,s]=regress(c,T,0.05);
disp(['c =' num2str(b(3)) '+' num2str(b(2)) 't+' num2str(b(1)) 't^2'])%输出方程
b%方程系数
bint%b的置信区间
r%残差
rint%r的置信区间
s%检验回归模型的统计量(对应4个参数值:相关系数r^2,F值,与F对应的概率P, 误差估计)

结果:
c =-0.13113+7.4041t+93.8463t^2
b =
93.8463
7.4041
-0.1311

bint =
49.0695 138.6230
3.0080 11.8003
-0.2206 -0.0417

r =
-7.9463
12.1753
7.6430
23.4181
-5.7745
-24.6342
-21.1042
12.0771
-14.2239
-24.5126
-13.6148
79.3895
-18.3498
30.6032
16.0385
5.6060
-1.1579
-55.6326

rint =
-56.6714 40.7788
-46.0597 70.4102
-54.7131 69.9992
-38.1024 84.9386
-68.9365 57.3874
-86.0124 36.7440
-82.5767 40.3683
-50.1051 74.2593
-76.2751 47.8273
-85.5679 36.5427
-76.3083 49.0788
33.9153 124.8637
-81.4707 44.7712
-30.6668 91.8733
-46.5710 78.6479
-56.9761 68.1881
-60.5541 58.2383
-101.2318 -10.0333

s =
0.5007 7.5203 0.0055 933.2755

回答2:

t=[0 4 8 9 10 18 21 23 24 25 29 37 38 39 40 41 44 46];
c=[85.90 133.54 152.33 173.28 149.00 160.00 170.40 206.85 181.79 172.48 184.67 267.67 167.50 213.76 196.24 182.59 164.60 101.33];
[p,S,mu] =polyfit(t,c,2)
结果为:
p =
-0.131131380060804 7.404136387597593 93.846288472422543
分别对应beta2,beta1,beta0的系数
具体参考doc polyfit