Skip to content

Commit 7230b90

Browse files
committed
Prevent inconsistent order of XX and ZZ columns
v0.2.12 introduced an issue in which the columns of XX and ZZ could be ordered inconsistently, leading to an error when shape() validated these objects. The issue could be reproduced by passing at least two variable names to the group_names argument to shape(), in an order other than alphabetic.
1 parent 5f5b7c1 commit 7230b90

13 files changed

+107
-88
lines changed

DESCRIPTION

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: dgo
22
Title: Dynamic Estimation of Group-Level Opinion
3-
Version: 0.2.12
4-
Date: 2017-11-13
3+
Version: 0.2.13
4+
Date: 2017-12-01
55
Description: Fit dynamic group-level IRT and MRP models from individual or
66
aggregated item response data. This package handles common preprocessing
77
tasks and extends functions for inspecting results, poststratification, and

NEWS.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1+
## dgo 0.2.13
2+
3+
* Fix an issue introduced in v0.2.12 that led to an unexpected error in
4+
`shape()` when 1) at least two `group_names` are specified in an order other
5+
than alphabetic and 2) geographic `modifier_data` is used.
6+
17
## dgo 0.2.12
28

39
* Allow modeling of unobserved groups using aggregated data. The previous
410
behavior was to drop rows in `aggregate_data` indicating zero trials. (They
511
don't represent item responses.) Preserving them has the effect that
612
unobserved groups, defined partially or entirely by the values of the grouping
713
variables in zero-trial rows in `aggregate_data`, can be included in a model.
8-
* Fix an unexpected error when 1) `aggregate_data` is used without `item_data`,
9-
2) no demographic groups are specified via `group_names`, and 3) geographic
14+
* Fix an unexpected error when 1) `aggregate_data` is used without `item_data`, 2)
15+
no demographic groups are specified via `group_names`, and 3) geographic
1016
`modifier_data` is used.
1117
* Fix the check for missing `modifier_data`. Geographic `modifier_data` must
1218
cover all combinations of the geo and time variables in the item response data

R/shape_hierarchical.r

+1-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ zero_unmodeled <- function(hierarchical, modifier_names, group_grid_t, ctrl) {
4242
paste0(x, unique(group_grid_t[[x]]))[-1]
4343
}))
4444
unmodeled_frame <- expand.grid(c(list(unmodeled_param_levels,
45-
ctrl@time_filter), rep(list(0L), length(modifier_names))),
46-
stringsAsFactors = FALSE)
45+
ctrl@time_filter), rep(list(0L), length(modifier_names))))
4746
unmodeled_frame <- setNames(unmodeled_frame, c(ctrl@geo_name, ctrl@time_name,
4847
modifier_names))
4948
data.table::setDT(unmodeled_frame, key = c(ctrl@geo_name, ctrl@time_name))

cran-comments.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,7 @@
77

88
## R CMD check results
99

10-
There were no ERRORs, WARNINGs, or NOTEs.
10+
There were no ERRORs or WARNINGs. There was one NOTE. (Days since last update:
11+
1). This update fixes a bug introduced in the most recent version and undetected
12+
until today.
1113

data/toy_dgirt_in.rda

5 Bytes
Binary file not shown.

data/toy_dgirtfit.rda

7.27 KB
Binary file not shown.

docs/articles/index.html

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/dgirt_fit-class.html

+29-29
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/dgo_fit-methods.html

+50-50
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/index.html

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/dgirt_ret.Rds

-10 Bytes
Binary file not shown.

tests/testthat/dgmrp_ret.Rds

-10 Bytes
Binary file not shown.

tests/testthat/test-zz.r

+12
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,15 @@ test_that('ZZ_prior defaults to ZZ', {
103103
expect_identical(hier_names, dimnames(d_tprime_only$ZZ_prior)[[2]])
104104
})
105105

106+
test_that("order of ZZ and XX columns is consistent when vector of group_names is unsorted and geographic data is used", {
107+
expect_silent(suppressMessages(shape(item_data = opinion,
108+
item_names = "affirmative_action",
109+
weight_name = "weight",
110+
time_name = "year",
111+
geo_name = "state",
112+
group_names = c("female", "education"),
113+
modifier_data = states,
114+
modifier_names = 'prop_hispanic',
115+
id_vars = "source")))
116+
})
117+

0 commit comments

Comments
 (0)