Permalink
Browse files

rename package to dgo

  • Loading branch information...
jamesdunham committed Oct 12, 2016
1 parent 1abb106 commit 8e6a2cfbe00b2cd4a908b3067241e06124d143cd
@@ -1,5 +1,5 @@
Package: dgirt
Title: Dynamic Group-Level IRT and Small Area Estimation
Package: dgo
Title: Dynamic Estimation of Group-level Opinion
Version: 0.2.7
Date: 2016-10-12
Description: Fit dynamic group-level IRT models from individual or aggregated
@@ -13,8 +13,8 @@ Authors@R: c(
person("Christopher", "Warshaw", email = "cwarshaw@mit.edu", role = c("aut"))
)
License: GPL-3
URL: https://github.com/jamesdunham/dgirt
BugReports: https://github.com/jamesdunham/dgirt/issues
URL: https://github.com/jamesdunham/dgo
BugReports: https://github.com/jamesdunham/dgo/issues
Depends:
R (>= 3.2.2),
Rcpp (>= 0.11.0),
@@ -35,7 +35,8 @@ Suggests:
testthat
LinkingTo: StanHeaders (>= 2.8.0), rstan (>= 2.8.1), BH (>= 1.58.0), Rcpp (>=
0.11.0), RcppEigen
RcppModules: stan_fit42016_09_14_mod, stan_fit42016_04_20_mod, stan_fit42015_12_16_mod
RcppModules: stan_fit42016_09_14_mod, stan_fit42016_04_20_mod,
stan_fit42015_12_16_mod
NeedsCompilation: yes
Collate:
'RcppExports.R'
@@ -61,6 +62,7 @@ Collate:
'methods-dgirtfit.r'
'methods-dgirtin.r'
'name_helpers.r'
'package.R'
'rake_partial.r'
'restrict_input_data.r'
'reweight_item_responses.r'
@@ -1,7 +1,7 @@
# Makefile for development use

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

all: build check install readme doc

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

check:
R CMD CHECK dgirt_$(VERSION).tar.gz
R CMD CHECK dgo_$(VERSION).tar.gz

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

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

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

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

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

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

quick-check dgirt_$(VERSION).tar.gz:
quick-check dgo_$(VERSION).tar.gz:
R --no-site-file --no-environ \
--no-save --no-restore --quiet CMD build . \
--no-resave-data --no-manual
R CMD CHECK dgirt_$(VERSION).tar.gz
R CMD CHECK dgo_$(VERSION).tar.gz
@@ -1,31 +1,47 @@
useDynLib(dgirt)
export(shape)
# Generated by roxygen2: do not edit by hand

S3method(as.data.frame,dgirtfit)
export(dgirt)
export(dgirt_plot)
export(get_item_names)
S3method(as.data.frame, dgirtfit)
exportMethods(poststratify)
exportMethods(extract)
export(expand_rownames)
export(plot_rhats)
export(shape)
export(summarize)
exportMethods(dgirt_plot)
exportMethods(get_item_n)
exportMethods(get_item_names)
exportMethods(get_n)
exportMethods(get_posterior_mean)
exportMethods(show)
exportMethods(rhats)
exportMethods(plot)
exportMethods(plot_rhats)
exportMethods(poststratify)
exportMethods(rhats)
exportMethods(show)
exportMethods(summarize)
exportMethods(print)
exportMethods(plot)
exportMethods(summary)
import(data.table)
import(rstan)
importFrom("concatenate", "cc", "cc_and", "cc_or", "cn", "cn_and")
import(R6)
importFrom(lubridate, "seconds_to_period")
import(methods)
import(Rcpp)
import(data.table)
import(ggplot2)
importFrom("stats", "as.formula", "formula", "model.frame",
"model.matrix", "na.fail", "na.omit", "quantile", "sd",
"setNames", "weighted.mean", "weights")
importFrom("utils", "capture.output", "type.convert", "packageVersion")
import(methods)
import(rstan)
importFrom(concatenate,cc)
importFrom(concatenate,cc_and)
importFrom(concatenate,cc_or)
importFrom(concatenate,cn)
importFrom(concatenate,cn_and)
importFrom(lubridate,seconds_to_period)
importFrom(stats,as.formula)
importFrom(stats,formula)
importFrom(stats,model.frame)
importFrom(stats,model.matrix)
importFrom(stats,na.fail)
importFrom(stats,na.omit)
importFrom(stats,quantile)
importFrom(stats,sd)
importFrom(stats,setNames)
importFrom(stats,weighted.mean)
importFrom(stats,weights)
importFrom(utils,capture.output)
importFrom(utils,packageVersion)
importFrom(utils,type.convert)
useDynLib(dgo)
16 NEWS.md
@@ -1,4 +1,18 @@
# dgirt 0.2.5
# 0.2.7

* Package renamed dgo: Dynamic Estimation of Group-level Opinion
* Tweaks to pass CRAN checks: clean up examples and docs
* Use roxygen2 for classes, methods, and `NAMESPACE`
* Fix checks on `P`, `S` related to `group_names` change in 0.2.5
* Fix Rcpp module issue from 0.2.6 (`Error in .doLoadActions(where, attach)`)
* Export `expand_rownames()`

# 0.2.6

* Fix error in `dgirt_plot`
* Fix path in `tools/make_cpp.R`

# 0.2.5

* `group_names` is no longer required. If omitted, the geographic variable given
by `geo_name` will define groups.
@@ -1,8 +1,7 @@
# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

#' @export
dichotomize_cpp <- function(response) {
.Call('dgirt_dichotomize_cpp', PACKAGE = 'dgirt', response)
.Call('dgo_dichotomize_cpp', PACKAGE = 'dgo', response)
}

@@ -1,21 +1,21 @@
#' Class \code{dgirtfit}: fitted DGIRT model
#' Class \code{dgirtfit}: a class for fitted DGIRT modelsf
#'
#' All \code{\link{rstan}} methods for superclass
#' \code{\link[rstan]{stanfit-class}} are available. Descriptive labels for
#' parameters on time periods, local geographic areas, and grouping variables
#' will be added to most output.
#' Fitting a dgirt model results in a \code{dgirtfit} object that inherits from
#' \code{\link{rstan}}'s \code{\link[rstan]{stanfit-class}}. \code{rstan}
#' methods will be dispatched (only) if a \code{dgirtfit} method does
#' not exist.
#'
#' @slot dgirt_in \code{\link{dgirtin-class}} data used to fit the model.
#'
#' @aliases dgirtfit dgirtfit-class
#' @aliases dgirtfit dgirtfit-class
#' @seealso \code{\link{stanfit-class}} \code{\link{dgirtin-class}}
#' @rdname dgirtfit-class
#' @name dgirtfit-class
#' @examples
#' data(toy_dgirtfit)
#' # summarize the fitted results
#' summary(toy_dgirtfit, pars = 'xi')
#'
#'
#' # get posterior means with a convenience function
#' get_posterior_mean(toy_dgirtfit, pars = 'theta_bar')
#'
@@ -29,6 +29,6 @@
#' as.data.frame(toy_dgirtfit, pars = 'theta_bar')
#' extract(toy_dgirtfit, pars = 'theta_bar')
dgirtfit <- setClass("dgirtfit",
contains = "stanfit",
slots = list(dgirt_in = "ANY",
call = "language"))
contains = "stanfit",
slots = list(dgirt_in = "ANY",
call = "language"))
@@ -1,13 +1,27 @@
#' Class \code{dgirtIn}: data prepared for modeling with \code{dgirt}
#'
#' \code{shape} generates objects of class \code{dgirtIn} for modeling with
#' \code{dgirt}.
#'
#' @aliases dgirtin-class, get_item_n, get_item_names, get_n, dgirtIn-method,
#' print.dgirtIn,
#' @name dgirtin-class
#' @include constants.r
#' @import R6
#' @examples
#' get_item_names(toy_dgirt_in)
#' get_n(toy_dgirt_in)
#' get_n(toy_dgirt_in, by = "year")
#' get_n(toy_dgirt_in, by = "source")
#' get_item_n(toy_dgirt_in)
#' get_item_n(toy_dgirt_in, by = "year")
NULL

setOldClass("dgirtIn", "R6")
dgirtIn <- R6::R6Class("dgirtIn",
public = c(
setNames(lapply(c(model_objects, shape_objects), function(x) NULL),
c(model_objects, shape_objects)),
c(model_objects, shape_objects)),
initialize = function(ctrl) {
if (length(ctrl@constant_item)) {
self$constant_item <- ctrl@constant_item
@@ -16,7 +30,7 @@ dgirtIn <- R6::R6Class("dgirtIn",
self$unmod_par_names <- ctrl@group_names
},
as_list = function(separate_t, delta_tbar_prior_mean, delta_tbar_prior_sd,
innov_sd_delta_scale, innov_sd_theta_scale) {
innov_sd_delta_scale, innov_sd_theta_scale) {
d_in_list <- Map(function(x) self[[x]], private$model_objects)
if (!length(separate_t) == 1L && is.logical(separate_t))
stop("\"separate_t\" should be a single logical value")
@@ -37,4 +51,4 @@ dgirtIn <- R6::R6Class("dgirtIn",
d_in_list
}),
private = list(model_objects = model_objects,
shape_objects = shape_objects))
shape_objects = shape_objects))
@@ -1,44 +1,42 @@
#' \code{dgirt}: fit a DGIRT model
#'
#' \code{dgirt} makes a call to \code{\link[rstan]{stan}} with the Stan code and
#' data for a DGIRT model. By default the call overrides the
#' \code{\link[rstan]{stan}} defaults for \code{pars} to specify typical DGIRT
#' parameters of interest and sets \code{iter_r} to \code{1L}.
#' data for a DGIRT model.
#'
#' @param shaped_data Output from \code{\link{shape}}.
#' The user will typically pass further arguments to \code{\link[rstan]{stan}}
#' via the \code{...} argument, at a minimum \code{iters} and \code{cores}.
#'
#' By default \code{dgirt} overrides the \code{\link[rstan]{stan}} default for its
#' \code{pars} argument to specify typical DGIRT parameters of interest.
#' \code{dgirt} also sets \code{iter_r} to \code{1L}.
#'
#' @param shaped_data Output from \code{\link{shape}}.
#' @param separate_t Whether smoothing of estimates over time should be
#' disabled. Default \code{FALSE}.
#'
#' @param delta_tbar_prior_mean Prior mean for \code{delta_tbar}, the normal
#' weight on \code{theta_bar} in the previous period. Default \code{0.5}.
#'
#' @param delta_tbar_prior_sd Prior standard deviation for \code{delta_bar}.
#' Default \code{0.5}.
#'
#' @param innov_sd_delta_scale Prior scale for \code{sd_innov_delta}, the Cauchy
#' innovation standard deviation of \code{nu_geo} and \code{delta_gamma}.
#' Default \code{2.5}.
#'
#' @param innov_sd_theta_scale Prior scale for \code{sd_innov_theta}, the Cauchy
#' innovation standard deviation of \code{gamma}, \code{xi}, and if
#' \code{constant_item} is \code{FALSE} the item difficulty \code{diff}. Default
#' \code{2.5}.
#'
#' @param version The version of the DGIRT model to use.
#'
#' @param ... Further arguments passed to \code{\link[rstan]{stan}}.
#'
#' @return A \code{\link{dgirtfit-class}} object that extends
#' \code{\link[rstan]{stanfit-class}}.
#'
#' @seealso \code{\link{dgirtfit-class}} \code{\link{shape}}
#' @seealso \code{dgirt} expects \code{shaped_data} created by
#' \code{\link{shape}} and returns an object of class
#' \code{\link{dgirtfit-class}}.
#' \code{\link{dgirtfit-class}} \code{\link{shape}}
#'
#' @import rstan
#' @export
#' @include constants.r
#' @examples
#' dgirt(toy_dgirt_in, iter = 25, chains = 1)
dgirt <- function(shaped_data, ..., separate_t = FALSE, delta_tbar_prior_mean = 0.5,
delta_tbar_prior_sd = 0.5, innov_sd_delta_scale = 2.5,
innov_sd_theta_scale = 2.5, version = "2016_09_14") {
@@ -8,7 +8,7 @@
#' by group and time period, or \code{param[t]} for parameters indexed by time
#' period. \code{expand_rownames} moves this information to columns whose names
#' are given by the \code{col_names} argument. The rownames in their original
#' format will appear in another column called \code{rn}.
#' format will appear in another column called \code{rn}.
#'
#' @param x A table with rownames in the format \code{param[group1__groupK,t]}
#' or \code{param[t]}.
@@ -22,6 +22,7 @@
#' @return \code{x} with additional columns (see details).
#' @seealso \code{\link{dgirtfit-class}}
#' @include data-toy_dgirtfit.r
#' @export
expand_rownames <- function(x, time_name, geo_name, group_names) {
if (is.matrix(x)) x <- as.data.frame(x, stringsAsFactors = FALSE,
rownames = rownames(x))
Oops, something went wrong.

0 comments on commit 8e6a2cf

Please sign in to comment.