Skip to content

Commit

Permalink
add a cube with no row/col differences
Browse files Browse the repository at this point in the history
  • Loading branch information
malecki committed Jan 4, 2019
1 parent 9bbe7b8 commit 574b1ff
Show file tree
Hide file tree
Showing 2 changed files with 199 additions and 0 deletions.
190 changes: 190 additions & 0 deletions cubes/same-counts-3x4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
{
"element": "shoji:view",
"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",
"value": {
"query": {
"measures": {
"count": {
"function": "cube_count",
"args": [

]
}
},
"dimensions": [
{
"variable": "/api/datasets/9c9001/variables/000000/"
},
{
"variable": "/api/datasets/9c9001/variables/000001/"
}
],
"weight": null
},
"query_environment": {
"filter": [

]
},
"result": {
"dimensions": [
{
"references": {
"alias": "Var1",
"name": "Var1"
},
"derived": false,
"type": {
"ordinal": false,
"class": "categorical",
"categories": [
{
"numeric_value": 1,
"id": 1,
"name": "1",
"missing": false
},
{
"numeric_value": 2,
"id": 2,
"name": "2",
"missing": false
},
{
"numeric_value": 3,
"id": 3,
"name": "3",
"missing": false
},
{
"numeric_value": null,
"id": -1,
"name": "No Data",
"missing": true
}
]
}
},
{
"references": {
"alias": "Var2",
"name": "Var2"
},
"derived": false,
"type": {
"ordinal": false,
"class": "categorical",
"categories": [
{
"numeric_value": 1,
"id": 1,
"name": "a",
"missing": false
},
{
"numeric_value": 2,
"id": 2,
"name": "b",
"missing": false
},
{
"numeric_value": 3,
"id": 3,
"name": "c",
"missing": false
},
{
"numeric_value": 4,
"id": 4,
"name": "d",
"missing": false
},
{
"numeric_value": null,
"id": -1,
"name": "No Data",
"missing": true
}
]
}
}
],
"missing": 0,
"measures": {
"count": {
"data": [
10,
10,
10,
10,
0,
20,
20,
20,
20,
0,
30,
30,
30,
30,
0,
0,
0,
0,
0,
0
],
"n_missing": 0,
"metadata": {
"references": {

},
"derived": true,
"type": {
"integer": true,
"missing_rules": {

},
"missing_reasons": {
"No Data": -1
},
"class": "numeric"
}
}
}
},
"n": 240,
"unfiltered": {
"unweighted_n": 240,
"weighted_n": 240
},
"filtered": {
"unweighted_n": 240,
"weighted_n": 240
},
"counts": [
10,
10,
10,
10,
0,
20,
20,
20,
20,
0,
30,
30,
30,
30,
0,
0,
0,
0,
0,
0
],
"element": "crunch:cube"
}
}
}
9 changes: 9 additions & 0 deletions tests/testthat/test-cube-pairwise.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ context("Cube pairwise multiple comparisons")
hirotsu <- loadCube("cubes/pairwise-hirotsu-illness-x-occupation.json")
hirotsuTranspose <- loadCube("cubes/pairwise-hirotsu-occupation-x-illness.json")
sampled <- loadCube("cubes/cube-random-3x4.json")
samecounts <- loadCube("cubes/same-counts-3x4.json")

test_that("Reference Chi-square from Z-tests.Rmd, 2017-10-26", {
reference <- structure(c(NA, 1.79366044505363, 1.44505144460352, 1.52650609891684,
Expand Down Expand Up @@ -150,3 +151,11 @@ test_that("Wishart P-values from reference in Hirotsu paper", {
out_t <- wishartPvalues(hirotsuTranspose, dim="row")
expect_equal(out, out_t)
})

test_that("a matrix where each row and column is the same", {
reference <- structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
.Dim = c(4L, 4L),
.Dimnames = list(c("a", "b", "c", "d"), c("a", "b", "c","d")))
out <- wishartPvalues(samecounts)
expect_equal(out, reference)
})

0 comments on commit 574b1ff

Please sign in to comment.