**前置作業**
先至記事本 打入以下DATA
36 20
41 25
39 24
42 25
49 32
40 22
48 28
39 22
45 30
44 28
35 21
37 23
42 26
34 21
32 15
然後存在devcpp 檔名打anacova.dat
然後即可開啟C++
**前置作業結束**
===================================開始複製===================================
#include <C:\devcpp\all.h>
int main()
{
long int i, j;
srand((unsigned)time(NULL));
cout.setf(ios::fixed); cout.precision(10);
// $$$$$$$$ Start your program here $$$$$$$$$$$$$$$$$$$$$
Matrix Y;
Y.read_from_file("c:\\devcpp\\anacova.dat",2);
Y.print(0);
Matrix X2;
Y.split_column(Y,1,X2);
Y.print(0); X2.print(0);
Matrix D = gen_dummy(One_way_class(3,5));
D.print(0);
Matrix SST, SSR, SSE;
Matrix X = J_Mat(Y.row(),1);
X.append_column(X2);
X.print(0);
Part_SS_X_full(Y,X,SST,SSR,SSE);
SSR.print(2);
SSE.print(2);
SST.print(2);
X.append_column(D);
X.print(0);
Part_SS_X_full(Y,X,SST,SSR,SSE);
cout << "full Model SS = " << endl;
SSR.print(2);
SSE.print(2);
SST.print(2);
double F = (13.28/2)/(27.99/11);
cout << "F = " << F << endl;
double P_value = F_r_tailed_prob(F,2,11);
cout.precision(4);
cout << " P_value = " << P_value << endl;
Partial_F_test(Y,X,2,3);
Partial_F_test(Y,X,1,1);
Matrix B = (X.T()*X).inv()*X.T()*Y;
B.print(4);
Partial_t_test(Y,X);
// $$$$$$$ End of your program $$$$$$$$$$$$$$$$$$$$$$$$$
cin.get();
return 0;
}
=====================================複製結束==================================
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.136.161.81
※ 編輯: weiching0323 來自: 140.136.161.81 (06/08 15:26)
※ 編輯: weiching0323 來自: 140.136.161.81 (06/08 15:31)