blob: c7adf8e5083c55344d4fc0ab2f5f38cb8ccc0469 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
Nij = [62 14; 9938 19986];
n= sum(Nij);
Ni = zeros(2,1);
Mj = zeros(2,1);
for i= 1:2
for j= 1:2
Ni(i) = Ni(i) + Nij(i,j);
end
end
for j= 1:2
for i= 1:2
Mj(j) = Mj(j) + Nij(i,j);
end
end
NM = ones(2,2);
for i=1:2
for j=1:2
NM(i,j)= Ni(i)*Mj(j);
end
end
NM= NM/n;
disp(NM);
TS = 0
for i=1:2
for j= 1:2
TS = TS + ((Nij(i,j)-NM(i,j))^2)/NM(i,j);
end
end
disp(TS, "The test statistic is")
compare = cdfchi("X", 1, 0.99, 0.01);
//disp(compare)
if(TS>compare)
disp("The null hypothesis is rejected at the 5% level of significance");
else
disp("The null hypothesis is accepted at the 5% level of significance");
end
|