我试图在表中的以下数据集上找到 CHI-SQUARE TEST。我正在尝试我的这个查询来找到 CHI-SQUARE TEST:
SELECT sessionnumber, sessioncount, timespent,
(dim1.cnt * dim2.cnt * dim3.cnt)/(dimall.cnt*dimall.cnt) as expected
FROM (SELECT sessionnumber, SUM(cast(cnt as bigint)) as cnt
FROM d3
GROUP BY sessionnumber) dim1 CROSS JOIN
(SELECT sessioncount, SUM(cast(cnt as bigint)) as cnt
FROM d3
GROUP BY sessioncount) dim2 CROSS JOIN
(SELECT timespent, SUM(cast(cnt as bigint)) as cnt
FROM d3
GROUP BY timespent) dim3 CROSS JOIN
(SELECT SUM(cast(cnt as bigint)) as cnt FROM d3) dimall
样本数据为:
sessionnumber sessioncount timespent cnt
1 17 28 45
2 22 8 30
3 1 1 2
4 1 1 2
5 8 111 119
6 8 65 73
7 11 5 16
8 1 1 2
9 62 64 126
10 6 42 48
但它给我的卡方检验值输出错误,它给出的输出是:
sessionnumber sessioncount timespent expected
1 23 1 0
2 23 1 0
3 23 1 0
4 23 1 0
5 23 1 0
6 23 1 0
7 23 1 0
8 23 1 0
9 23 1 0
10 23 1 0
我已经尽力了,并搜索了很多关于这个问题的信息。请帮我一个忙,请解决问题!提前致谢!