?? malthus.m
字號:
%lny=lna+bx
clear all
y=[3.9 5.3 7.2 9.6 12.9 17.1 23.2 31.4 38.6 50.2 62.9 76.0];
%Y為列向量
Y=log(y');
x=1:12;
%X為兩列
X=[ones(12,1),x'];
[b,bint,r,rint,stats]=regress(Y,X);
%b為參數的點估計
disp('b為參數的點估計')
b
%bint為參數的區間估計
disp('bint為參數的區間估計')
bint
%stats(1)為相關系數越接近1回歸方程越顯著
disp('stats(1)')
stats(1)
%stats(2)為F值越大回歸越顯著
disp('stats(2)')
stats(2)
%stats(3)為與F對應的概率P P<a時模型成立
disp('stats(3)')
stats(3)
%求均方誤差根RMSE
a=exp(b(1));
yy=a.*exp(b(2).*x);
rmse=sqrt(sum((yy-y).^2)/12);
disp('rmse')
rmse
%寫出表達式
fprintf('回歸方程為y=%5.4f*exp(%5.4fx)',a,b(2))
%做回歸圖像
figure(1)
plot(x,y,'o',x,yy)
%做參差圖
figure(2)
rcoplot(r,rint)
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -