diff --git a/DESCRIPTION b/DESCRIPTION index 5cfb4fd..ebf7193 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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 diff --git a/NEWS.md b/NEWS.md index 9431966..9116180 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,9 @@ +## 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 @@ -5,8 +11,8 @@ 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 diff --git a/R/shape_hierarchical.r b/R/shape_hierarchical.r index 0cdb629..b7522ef 100644 --- a/R/shape_hierarchical.r +++ b/R/shape_hierarchical.r @@ -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)) diff --git a/cran-comments.md b/cran-comments.md index ea150db..aad72e2 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -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. diff --git a/data/toy_dgirt_in.rda b/data/toy_dgirt_in.rda index b045321..a14352a 100644 Binary files a/data/toy_dgirt_in.rda and b/data/toy_dgirt_in.rda differ diff --git a/data/toy_dgirtfit.rda b/data/toy_dgirtfit.rda index a2555ea..ec01515 100644 Binary files a/data/toy_dgirtfit.rda and b/data/toy_dgirtfit.rda differ diff --git a/docs/articles/index.html b/docs/articles/index.html index 97491fd..fcecaf9 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -82,7 +82,7 @@
+head(as.data.frame(toy_dgirtfit, pars = 'theta_bar'))#> dgirt samples from 4 chains of 400 iterations, 200 warmup, thinned every 1 -#> Drawn Mon Nov 13 18:15:19 2017 -#> Package version 0.2.12 +#> Drawn Fri Dec 1 11:54:14 2017 +#> Package version 0.2.13 #> Model version 2017_01_04 #> 43 parameters; 12 theta_bars (year state race3) #> 2 periods 2009 to 2010 #> #> n_eff#>-#>#> +#>#> #> Rhat#>-#>#> +#>#> #> Elapsed time#>-#> -#> -#> -#>+#>+#> +#> +#># get posterior means with a convenience function get_posterior_mean(toy_dgirtfit, pars = 'theta_bar')#> param state race3 year mean -#> 1: theta_bar SC black 2009 2.35662560 -#> 2: theta_bar SC black 2010 1.22256665 -#> 3: theta_bar SC other 2009 -1.36379358 -#> 4: theta_bar SC other 2010 0.04227331 -#> 5: theta_bar SC white 2009 -1.63196374 -#> 6: theta_bar SC white 2010 -1.47489402 -#> 7: theta_bar VA black 2009 1.90274077 -#> 8: theta_bar VA black 2010 1.52339960 -#> 9: theta_bar VA other 2009 -0.95920551 -#> 10: theta_bar VA other 2010 0.28518022 -#> 11: theta_bar VA white 2009 -0.92697350 -#> 12: theta_bar VA white 2010 -0.83419892+#> 1: theta_bar SC black 2009 2.24053065 +#> 2: theta_bar SC black 2010 1.27549292 +#> 3: theta_bar SC other 2009 -1.40019273 +#> 4: theta_bar SC other 2010 0.04084414 +#> 5: theta_bar SC white 2009 -1.67983508 +#> 6: theta_bar SC white 2010 -1.42533238 +#> 7: theta_bar VA black 2009 2.01710000 +#> 8: theta_bar VA black 2010 1.48835032 +#> 9: theta_bar VA other 2009 -1.02559194 +#> 10: theta_bar VA other 2010 0.30256578 +#> 11: theta_bar VA white 2009 -0.93711250 +#> 12: theta_bar VA white 2010 -0.82327290# generally apply functions to posterior samples after warmup; n.b. # `as.array` is iterations x chains x parameters so `MARGIN = 3` applies # `FUN` over iterations and chains -apply(as.array(toy_dgirtfit, pars = 'xi'), 3, mean)#> xi[1] xi[2] -#> 1.35546402 0.04828843+apply(as.array(toy_dgirtfit, pars = 'xi'), 3, mean)#> xi[1] xi[2] +#> 1.3134883 0.1604207# access the posterior samples -head(as.data.frame(toy_dgirtfit, pars = 'theta_bar'))#> param state race3 year iteration value -#> 1: theta_bar SC black 2009 1 0.7183680 -#> 2: theta_bar SC black 2009 2 0.7609363 -#> 3: theta_bar SC black 2009 3 0.7942637 -#> 4: theta_bar SC black 2009 4 1.4685053 -#> 5: theta_bar SC black 2009 5 1.1297978 -#> 6: theta_bar SC black 2009 6 0.6581956