Skip to content

Commit ea7eb71

Browse files
committed
add a cube with no row/col differences
1 parent b3877f5 commit ea7eb71

File tree

3 files changed

+204
-0
lines changed

3 files changed

+204
-0
lines changed

cubes/same-counts-3x4.json

+190
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
{
2+
"element": "shoji:view",
3+
"self": "/api/datasets/9c9001/cube/?query=%7B%22dimensions%22%3A%5B%7B%22variable%22%3A%22%2Fapi%2Fdatasets%2F9c9001%2Fvariables%2F000000%2F%22%7D%2C%7B%22variable%22%3A%22%2Fapi%2Fdatasets%2F9c9001%2Fvariables%2F000001%2F%22%7D%5D%2C%22measures%22%3A%7B%22count%22%3A%7B%22function%22%3A%22cube_count%22%2C%22args%22%3A%5B%5D%7D%7D%2C%22weight%22%3Anull%7D&filter=%7B%7D",
4+
"value": {
5+
"query": {
6+
"measures": {
7+
"count": {
8+
"function": "cube_count",
9+
"args": [
10+
11+
]
12+
}
13+
},
14+
"dimensions": [
15+
{
16+
"variable": "/api/datasets/9c9001/variables/000000/"
17+
},
18+
{
19+
"variable": "/api/datasets/9c9001/variables/000001/"
20+
}
21+
],
22+
"weight": null
23+
},
24+
"query_environment": {
25+
"filter": [
26+
27+
]
28+
},
29+
"result": {
30+
"dimensions": [
31+
{
32+
"references": {
33+
"alias": "Var1",
34+
"name": "Var1"
35+
},
36+
"derived": false,
37+
"type": {
38+
"ordinal": false,
39+
"class": "categorical",
40+
"categories": [
41+
{
42+
"numeric_value": 1,
43+
"id": 1,
44+
"name": "1",
45+
"missing": false
46+
},
47+
{
48+
"numeric_value": 2,
49+
"id": 2,
50+
"name": "2",
51+
"missing": false
52+
},
53+
{
54+
"numeric_value": 3,
55+
"id": 3,
56+
"name": "3",
57+
"missing": false
58+
},
59+
{
60+
"numeric_value": null,
61+
"id": -1,
62+
"name": "No Data",
63+
"missing": true
64+
}
65+
]
66+
}
67+
},
68+
{
69+
"references": {
70+
"alias": "Var2",
71+
"name": "Var2"
72+
},
73+
"derived": false,
74+
"type": {
75+
"ordinal": false,
76+
"class": "categorical",
77+
"categories": [
78+
{
79+
"numeric_value": 1,
80+
"id": 1,
81+
"name": "a",
82+
"missing": false
83+
},
84+
{
85+
"numeric_value": 2,
86+
"id": 2,
87+
"name": "b",
88+
"missing": false
89+
},
90+
{
91+
"numeric_value": 3,
92+
"id": 3,
93+
"name": "c",
94+
"missing": false
95+
},
96+
{
97+
"numeric_value": 4,
98+
"id": 4,
99+
"name": "d",
100+
"missing": false
101+
},
102+
{
103+
"numeric_value": null,
104+
"id": -1,
105+
"name": "No Data",
106+
"missing": true
107+
}
108+
]
109+
}
110+
}
111+
],
112+
"missing": 0,
113+
"measures": {
114+
"count": {
115+
"data": [
116+
10,
117+
10,
118+
10,
119+
10,
120+
0,
121+
20,
122+
20,
123+
20,
124+
20,
125+
0,
126+
30,
127+
30,
128+
30,
129+
30,
130+
0,
131+
0,
132+
0,
133+
0,
134+
0,
135+
0
136+
],
137+
"n_missing": 0,
138+
"metadata": {
139+
"references": {
140+
141+
},
142+
"derived": true,
143+
"type": {
144+
"integer": true,
145+
"missing_rules": {
146+
147+
},
148+
"missing_reasons": {
149+
"No Data": -1
150+
},
151+
"class": "numeric"
152+
}
153+
}
154+
}
155+
},
156+
"n": 240,
157+
"unfiltered": {
158+
"unweighted_n": 240,
159+
"weighted_n": 240
160+
},
161+
"filtered": {
162+
"unweighted_n": 240,
163+
"weighted_n": 240
164+
},
165+
"counts": [
166+
10,
167+
10,
168+
10,
169+
10,
170+
0,
171+
20,
172+
20,
173+
20,
174+
20,
175+
0,
176+
30,
177+
30,
178+
30,
179+
30,
180+
0,
181+
0,
182+
0,
183+
0,
184+
0,
185+
0
186+
],
187+
"element": "crunch:cube"
188+
}
189+
}
190+
}

inst/cubes.tgz

355 Bytes
Binary file not shown.

tests/testthat/test-cube-pairwise.R

+14
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ context("Cube pairwise multiple comparisons")
66
hirotsu <- loadCube("cubes/pairwise-hirotsu-illness-x-occupation.json")
77
hirotsuTranspose <- loadCube("cubes/pairwise-hirotsu-occupation-x-illness.json")
88
sampled <- loadCube("cubes/cube-random-3x4.json")
9+
samecounts <- loadCube("cubes/same-counts-3x4.json")
910

1011
test_that("Reference Chi-square from Z-tests.Rmd, 2017-10-26", {
1112
reference <- structure(c(NA, 1.79366044505363, 1.44505144460352, 1.52650609891684,
@@ -150,3 +151,16 @@ test_that("Wishart P-values from reference in Hirotsu paper", {
150151
out_t <- wishartPvalues(hirotsuTranspose, dim="row")
151152
expect_equal(out, out_t)
152153
})
154+
155+
test_that("a matrix where each row and column is the same", {
156+
referenceChisq <- structure(rep(0, 16),
157+
.Dim = c(4L, 4L),
158+
.Dimnames = list(c("a", "b", "c", "d"), c("a", "b", "c", "d")))
159+
referencePvals <- structure(rep(1, 16),
160+
.Dim = c(4L, 4L),
161+
.Dimnames = list(c("a", "b", "c", "d"), c("a", "b", "c", "d")))
162+
out1 <- wishartMatrix(samecounts)
163+
expect_equal(out1, referenceChisq)
164+
out2 <- wishartPvalues(samecounts)
165+
expect_equal(out2, referencePvals)
166+
})

0 commit comments

Comments
 (0)