Skip to content

Commit 8e6a2cf

Browse files
committed
rename package to dgo
1 parent 1abb106 commit 8e6a2cf

37 files changed

+444
-313
lines changed

DESCRIPTION

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Package: dgirt
2-
Title: Dynamic Group-Level IRT and Small Area Estimation
1+
Package: dgo
2+
Title: Dynamic Estimation of Group-level Opinion
33
Version: 0.2.7
44
Date: 2016-10-12
55
Description: Fit dynamic group-level IRT models from individual or aggregated
@@ -13,8 +13,8 @@ Authors@R: c(
1313
person("Christopher", "Warshaw", email = "cwarshaw@mit.edu", role = c("aut"))
1414
)
1515
License: GPL-3
16-
URL: https://github.com/jamesdunham/dgirt
17-
BugReports: https://github.com/jamesdunham/dgirt/issues
16+
URL: https://github.com/jamesdunham/dgo
17+
BugReports: https://github.com/jamesdunham/dgo/issues
1818
Depends:
1919
R (>= 3.2.2),
2020
Rcpp (>= 0.11.0),
@@ -35,7 +35,8 @@ Suggests:
3535
testthat
3636
LinkingTo: StanHeaders (>= 2.8.0), rstan (>= 2.8.1), BH (>= 1.58.0), Rcpp (>=
3737
0.11.0), RcppEigen
38-
RcppModules: stan_fit42016_09_14_mod, stan_fit42016_04_20_mod, stan_fit42015_12_16_mod
38+
RcppModules: stan_fit42016_09_14_mod, stan_fit42016_04_20_mod,
39+
stan_fit42015_12_16_mod
3940
NeedsCompilation: yes
4041
Collate:
4142
'RcppExports.R'
@@ -61,6 +62,7 @@ Collate:
6162
'methods-dgirtfit.r'
6263
'methods-dgirtin.r'
6364
'name_helpers.r'
65+
'package.R'
6466
'rake_partial.r'
6567
'restrict_input_data.r'
6668
'reweight_item_responses.r'

Makefile

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Makefile for development use
22

33
VERSION := $(shell sed -n 3p DESCRIPTION | sed 's/Version: //' | cat)
4-
BINARY := dgirt_$(VERSION).tar.gz
4+
BINARY := dgo_$(VERSION).tar.gz
55

66
all: build check install readme doc
77

@@ -11,29 +11,29 @@ build:
1111
--no-resave-data --no-manual
1212

1313
check:
14-
R CMD CHECK dgirt_$(VERSION).tar.gz
14+
R CMD CHECK dgo_$(VERSION).tar.gz
1515

1616
check-cran:
17-
R CMD CHECK --as-cran dgirt_$(VERSION).tar.gz
17+
R CMD CHECK --as-cran dgo_$(VERSION).tar.gz
1818

19-
install: dgirt_$(VERSION).tar.gz
20-
R CMD INSTALL --no-multiarch --with-keep.source dgirt_$(VERSION).tar.gz
19+
install: dgo_$(VERSION).tar.gz
20+
R CMD INSTALL --no-multiarch --with-keep.source dgo_$(VERSION).tar.gz
2121

2222
install-code:
2323
R CMD INSTALL --no-multiarch --with-keep.source --no-docs .
2424

25-
readme: dgirt_$(VERSION).tar.gz
25+
readme: dgo_$(VERSION).tar.gz
2626
R --vanilla --slave -e "rmarkdown::render('README.Rmd')"
2727

28-
doc: dgirt_$(VERSION).tar.gz
29-
R CMD CHECK --no-install --no-tests --no-examples dgirt_$(VERSION).tar.gz
28+
doc: dgo_$(VERSION).tar.gz
29+
R CMD CHECK --no-install --no-tests --no-examples dgo_$(VERSION).tar.gz
3030

3131
quick-install:
3232
R CMD INSTALL --no-multiarch --no-docs --no-html \
3333
--with-keep.source .
3434

35-
quick-check dgirt_$(VERSION).tar.gz:
35+
quick-check dgo_$(VERSION).tar.gz:
3636
R --no-site-file --no-environ \
3737
--no-save --no-restore --quiet CMD build . \
3838
--no-resave-data --no-manual
39-
R CMD CHECK dgirt_$(VERSION).tar.gz
39+
R CMD CHECK dgo_$(VERSION).tar.gz

NAMESPACE

+36-20
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,47 @@
1-
useDynLib(dgirt)
2-
export(shape)
1+
# Generated by roxygen2: do not edit by hand
2+
3+
S3method(as.data.frame,dgirtfit)
34
export(dgirt)
4-
export(dgirt_plot)
5-
export(get_item_names)
6-
S3method(as.data.frame, dgirtfit)
7-
exportMethods(poststratify)
8-
exportMethods(extract)
5+
export(expand_rownames)
6+
export(plot_rhats)
7+
export(shape)
8+
export(summarize)
9+
exportMethods(dgirt_plot)
910
exportMethods(get_item_n)
1011
exportMethods(get_item_names)
1112
exportMethods(get_n)
1213
exportMethods(get_posterior_mean)
13-
exportMethods(show)
14-
exportMethods(rhats)
14+
exportMethods(plot)
1515
exportMethods(plot_rhats)
16+
exportMethods(poststratify)
17+
exportMethods(rhats)
18+
exportMethods(show)
1619
exportMethods(summarize)
17-
exportMethods(print)
18-
exportMethods(plot)
1920
exportMethods(summary)
20-
import(data.table)
21-
import(rstan)
22-
importFrom("concatenate", "cc", "cc_and", "cc_or", "cn", "cn_and")
2321
import(R6)
24-
importFrom(lubridate, "seconds_to_period")
25-
import(methods)
2622
import(Rcpp)
23+
import(data.table)
2724
import(ggplot2)
28-
importFrom("stats", "as.formula", "formula", "model.frame",
29-
"model.matrix", "na.fail", "na.omit", "quantile", "sd",
30-
"setNames", "weighted.mean", "weights")
31-
importFrom("utils", "capture.output", "type.convert", "packageVersion")
25+
import(methods)
26+
import(rstan)
27+
importFrom(concatenate,cc)
28+
importFrom(concatenate,cc_and)
29+
importFrom(concatenate,cc_or)
30+
importFrom(concatenate,cn)
31+
importFrom(concatenate,cn_and)
32+
importFrom(lubridate,seconds_to_period)
33+
importFrom(stats,as.formula)
34+
importFrom(stats,formula)
35+
importFrom(stats,model.frame)
36+
importFrom(stats,model.matrix)
37+
importFrom(stats,na.fail)
38+
importFrom(stats,na.omit)
39+
importFrom(stats,quantile)
40+
importFrom(stats,sd)
41+
importFrom(stats,setNames)
42+
importFrom(stats,weighted.mean)
43+
importFrom(stats,weights)
44+
importFrom(utils,capture.output)
45+
importFrom(utils,packageVersion)
46+
importFrom(utils,type.convert)
47+
useDynLib(dgo)

NEWS.md

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
1-
# dgirt 0.2.5
1+
# 0.2.7
2+
3+
* Package renamed dgo: Dynamic Estimation of Group-level Opinion
4+
* Tweaks to pass CRAN checks: clean up examples and docs
5+
* Use roxygen2 for classes, methods, and `NAMESPACE`
6+
* Fix checks on `P`, `S` related to `group_names` change in 0.2.5
7+
* Fix Rcpp module issue from 0.2.6 (`Error in .doLoadActions(where, attach)`)
8+
* Export `expand_rownames()`
9+
10+
# 0.2.6
11+
12+
* Fix error in `dgirt_plot`
13+
* Fix path in `tools/make_cpp.R`
14+
15+
# 0.2.5
216

317
* `group_names` is no longer required. If omitted, the geographic variable given
418
by `geo_name` will define groups.

R/RcppExports.R

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# Generated by using Rcpp::compileAttributes() -> do not edit by hand
22
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
33

4-
#' @export
54
dichotomize_cpp <- function(response) {
6-
.Call('dgirt_dichotomize_cpp', PACKAGE = 'dgirt', response)
5+
.Call('dgo_dichotomize_cpp', PACKAGE = 'dgo', response)
76
}
87

R/class-dgirtfit.r

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
#' Class \code{dgirtfit}: fitted DGIRT model
1+
#' Class \code{dgirtfit}: a class for fitted DGIRT modelsf
22
#'
3-
#' All \code{\link{rstan}} methods for superclass
4-
#' \code{\link[rstan]{stanfit-class}} are available. Descriptive labels for
5-
#' parameters on time periods, local geographic areas, and grouping variables
6-
#' will be added to most output.
3+
#' Fitting a dgirt model results in a \code{dgirtfit} object that inherits from
4+
#' \code{\link{rstan}}'s \code{\link[rstan]{stanfit-class}}. \code{rstan}
5+
#' methods will be dispatched (only) if a \code{dgirtfit} method does
6+
#' not exist.
77
#'
88
#' @slot dgirt_in \code{\link{dgirtin-class}} data used to fit the model.
99
#'
10-
#' @aliases dgirtfit dgirtfit-class
10+
#' @aliases dgirtfit dgirtfit-class
1111
#' @seealso \code{\link{stanfit-class}} \code{\link{dgirtin-class}}
1212
#' @rdname dgirtfit-class
1313
#' @name dgirtfit-class
1414
#' @examples
1515
#' data(toy_dgirtfit)
1616
#' # summarize the fitted results
1717
#' summary(toy_dgirtfit, pars = 'xi')
18-
#'
18+
#'
1919
#' # get posterior means with a convenience function
2020
#' get_posterior_mean(toy_dgirtfit, pars = 'theta_bar')
2121
#'
@@ -29,6 +29,6 @@
2929
#' as.data.frame(toy_dgirtfit, pars = 'theta_bar')
3030
#' extract(toy_dgirtfit, pars = 'theta_bar')
3131
dgirtfit <- setClass("dgirtfit",
32-
contains = "stanfit",
33-
slots = list(dgirt_in = "ANY",
34-
call = "language"))
32+
contains = "stanfit",
33+
slots = list(dgirt_in = "ANY",
34+
call = "language"))

R/class-dgirtin.r

+17-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,27 @@
11
#' Class \code{dgirtIn}: data prepared for modeling with \code{dgirt}
2+
#'
3+
#' \code{shape} generates objects of class \code{dgirtIn} for modeling with
4+
#' \code{dgirt}.
5+
#'
6+
#' @aliases dgirtin-class, get_item_n, get_item_names, get_n, dgirtIn-method,
7+
#' print.dgirtIn,
28
#' @name dgirtin-class
39
#' @include constants.r
10+
#' @import R6
11+
#' @examples
12+
#' get_item_names(toy_dgirt_in)
13+
#' get_n(toy_dgirt_in)
14+
#' get_n(toy_dgirt_in, by = "year")
15+
#' get_n(toy_dgirt_in, by = "source")
16+
#' get_item_n(toy_dgirt_in)
17+
#' get_item_n(toy_dgirt_in, by = "year")
418
NULL
519

620
setOldClass("dgirtIn", "R6")
721
dgirtIn <- R6::R6Class("dgirtIn",
822
public = c(
923
setNames(lapply(c(model_objects, shape_objects), function(x) NULL),
10-
c(model_objects, shape_objects)),
24+
c(model_objects, shape_objects)),
1125
initialize = function(ctrl) {
1226
if (length(ctrl@constant_item)) {
1327
self$constant_item <- ctrl@constant_item
@@ -16,7 +30,7 @@ dgirtIn <- R6::R6Class("dgirtIn",
1630
self$unmod_par_names <- ctrl@group_names
1731
},
1832
as_list = function(separate_t, delta_tbar_prior_mean, delta_tbar_prior_sd,
19-
innov_sd_delta_scale, innov_sd_theta_scale) {
33+
innov_sd_delta_scale, innov_sd_theta_scale) {
2034
d_in_list <- Map(function(x) self[[x]], private$model_objects)
2135
if (!length(separate_t) == 1L && is.logical(separate_t))
2236
stop("\"separate_t\" should be a single logical value")
@@ -37,4 +51,4 @@ dgirtIn <- R6::R6Class("dgirtIn",
3751
d_in_list
3852
}),
3953
private = list(model_objects = model_objects,
40-
shape_objects = shape_objects))
54+
shape_objects = shape_objects))

R/dgirt.r

+12-14
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,42 @@
11
#' \code{dgirt}: fit a DGIRT model
22
#'
33
#' \code{dgirt} makes a call to \code{\link[rstan]{stan}} with the Stan code and
4-
#' data for a DGIRT model. By default the call overrides the
5-
#' \code{\link[rstan]{stan}} defaults for \code{pars} to specify typical DGIRT
6-
#' parameters of interest and sets \code{iter_r} to \code{1L}.
4+
#' data for a DGIRT model.
75
#'
8-
#' @param shaped_data Output from \code{\link{shape}}.
6+
#' The user will typically pass further arguments to \code{\link[rstan]{stan}}
7+
#' via the \code{...} argument, at a minimum \code{iters} and \code{cores}.
8+
#'
9+
#' By default \code{dgirt} overrides the \code{\link[rstan]{stan}} default for its
10+
#' \code{pars} argument to specify typical DGIRT parameters of interest.
11+
#' \code{dgirt} also sets \code{iter_r} to \code{1L}.
912
#'
13+
#' @param shaped_data Output from \code{\link{shape}}.
1014
#' @param separate_t Whether smoothing of estimates over time should be
1115
#' disabled. Default \code{FALSE}.
12-
#'
1316
#' @param delta_tbar_prior_mean Prior mean for \code{delta_tbar}, the normal
1417
#' weight on \code{theta_bar} in the previous period. Default \code{0.5}.
15-
#'
1618
#' @param delta_tbar_prior_sd Prior standard deviation for \code{delta_bar}.
1719
#' Default \code{0.5}.
18-
#'
1920
#' @param innov_sd_delta_scale Prior scale for \code{sd_innov_delta}, the Cauchy
2021
#' innovation standard deviation of \code{nu_geo} and \code{delta_gamma}.
2122
#' Default \code{2.5}.
22-
#'
2323
#' @param innov_sd_theta_scale Prior scale for \code{sd_innov_theta}, the Cauchy
2424
#' innovation standard deviation of \code{gamma}, \code{xi}, and if
2525
#' \code{constant_item} is \code{FALSE} the item difficulty \code{diff}. Default
2626
#' \code{2.5}.
27-
#'
2827
#' @param version The version of the DGIRT model to use.
29-
#'
3028
#' @param ... Further arguments passed to \code{\link[rstan]{stan}}.
3129
#'
3230
#' @return A \code{\link{dgirtfit-class}} object that extends
3331
#' \code{\link[rstan]{stanfit-class}}.
34-
#'
35-
#' @seealso \code{\link{dgirtfit-class}} \code{\link{shape}}
32+
#' @seealso \code{dgirt} expects \code{shaped_data} created by
33+
#' \code{\link{shape}} and returns an object of class
34+
#' \code{\link{dgirtfit-class}}.
35+
#' \code{\link{dgirtfit-class}} \code{\link{shape}}
3636
#'
3737
#' @import rstan
3838
#' @export
3939
#' @include constants.r
40-
#' @examples
41-
#' dgirt(toy_dgirt_in, iter = 25, chains = 1)
4240
dgirt <- function(shaped_data, ..., separate_t = FALSE, delta_tbar_prior_mean = 0.5,
4341
delta_tbar_prior_sd = 0.5, innov_sd_delta_scale = 2.5,
4442
innov_sd_theta_scale = 2.5, version = "2016_09_14") {

R/expand_rownames.r

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#' by group and time period, or \code{param[t]} for parameters indexed by time
99
#' period. \code{expand_rownames} moves this information to columns whose names
1010
#' are given by the \code{col_names} argument. The rownames in their original
11-
#' format will appear in another column called \code{rn}.
11+
#' format will appear in another column called \code{rn}.
1212
#'
1313
#' @param x A table with rownames in the format \code{param[group1__groupK,t]}
1414
#' or \code{param[t]}.
@@ -22,6 +22,7 @@
2222
#' @return \code{x} with additional columns (see details).
2323
#' @seealso \code{\link{dgirtfit-class}}
2424
#' @include data-toy_dgirtfit.r
25+
#' @export
2526
expand_rownames <- function(x, time_name, geo_name, group_names) {
2627
if (is.matrix(x)) x <- as.data.frame(x, stringsAsFactors = FALSE,
2728
rownames = rownames(x))

0 commit comments

Comments
 (0)