Skip to content

Commit

Permalink
Prevent inconsistent order of XX and ZZ columns
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jamesdunham committed Dec 1, 2017
1 parent 5f5b7c1 commit 7230b90
Show file tree
Hide file tree
Showing 13 changed files with 107 additions and 88 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: dgo
Title: Dynamic Estimation of Group-Level Opinion
Version: 0.2.12
Date: 2017-11-13
Version: 0.2.13
Date: 2017-12-01
Description: Fit dynamic group-level IRT and MRP models from individual or
aggregated item response data. This package handles common preprocessing
tasks and extends functions for inspecting results, poststratification, and
Expand Down
10 changes: 8 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
## dgo 0.2.13

* Fix an issue introduced in v0.2.12 that led to an unexpected error in
`shape()` when 1) at least two `group_names` are specified in an order other
than alphabetic and 2) geographic `modifier_data` is used.

## dgo 0.2.12

* Allow modeling of unobserved groups using aggregated data. The previous
behavior was to drop rows in `aggregate_data` indicating zero trials. (They
don't represent item responses.) Preserving them has the effect that
unobserved groups, defined partially or entirely by the values of the grouping
variables in zero-trial rows in `aggregate_data`, can be included in a model.
* Fix an unexpected error when 1) `aggregate_data` is used without `item_data`,
2) no demographic groups are specified via `group_names`, and 3) geographic
* Fix an unexpected error when 1) `aggregate_data` is used without `item_data`, 2)
no demographic groups are specified via `group_names`, and 3) geographic
`modifier_data` is used.
* Fix the check for missing `modifier_data`. Geographic `modifier_data` must
cover all combinations of the geo and time variables in the item response data
Expand Down
3 changes: 1 addition & 2 deletions R/shape_hierarchical.r
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ zero_unmodeled <- function(hierarchical, modifier_names, group_grid_t, ctrl) {
paste0(x, unique(group_grid_t[[x]]))[-1]
}))
unmodeled_frame <- expand.grid(c(list(unmodeled_param_levels,
ctrl@time_filter), rep(list(0L), length(modifier_names))),
stringsAsFactors = FALSE)
ctrl@time_filter), rep(list(0L), length(modifier_names))))
unmodeled_frame <- setNames(unmodeled_frame, c(ctrl@geo_name, ctrl@time_name,
modifier_names))
data.table::setDT(unmodeled_frame, key = c(ctrl@geo_name, ctrl@time_name))
Expand Down
4 changes: 3 additions & 1 deletion cran-comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@

## R CMD check results

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

Binary file modified data/toy_dgirt_in.rda
Binary file not shown.
Binary file modified data/toy_dgirtfit.rda
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/articles/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 29 additions & 29 deletions docs/reference/dgirt_fit-class.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

100 changes: 50 additions & 50 deletions docs/reference/dgo_fit-methods.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified tests/testthat/dgirt_ret.Rds
Binary file not shown.
Binary file modified tests/testthat/dgmrp_ret.Rds
Binary file not shown.
12 changes: 12 additions & 0 deletions tests/testthat/test-zz.r
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,15 @@ test_that('ZZ_prior defaults to ZZ', {
expect_identical(hier_names, dimnames(d_tprime_only$ZZ_prior)[[2]])
})

test_that("order of ZZ and XX columns is consistent when vector of group_names is unsorted and geographic data is used", {
expect_silent(suppressMessages(shape(item_data = opinion,
item_names = "affirmative_action",
weight_name = "weight",
time_name = "year",
geo_name = "state",
group_names = c("female", "education"),
modifier_data = states,
modifier_names = 'prop_hispanic',
id_vars = "source")))
})

0 comments on commit 7230b90

Please sign in to comment.