Skip to content

Commit

Permalink
v0.2.14
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesdunham authored Dec 21, 2017
2 parents 288a372 + de16a7b commit 022d509
Show file tree
Hide file tree
Showing 12 changed files with 509 additions and 427 deletions.
16 changes: 10 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
Package: dgo
Title: Dynamic Estimation of Group-Level Opinion
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
quick iteration over alternative models.
Version: 0.2.14
Date: 2017-12-20
Description: Fit dynamic group-level item response theory (IRT) and multilevel
regression and poststratification (MRP) models from item response data. dgo
models latent traits at the level of demographic and geographic groups,
rather than individuals, in a Bayesian group-level IRT approach developed by
Caughey and Warshaw (2015) <doi:10.1093/pan/mpu021>. The package also
estimates subpopulations' average responses to single survey items with a
dynamic MRP model proposed by Park, Gelman, and Bafumi (2004)
<doi:10.11126/stanford/9780804753005.003.0011>.
Maintainer: James Dunham <james@jdunham.io>
Authors@R: c(
person("James", "Dunham", email = "james@jdunham.io", role = c("aut", "cre")),
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ CURRENT_DIR := $(notdir $(patsubst %/,%,$(dir $(MAKEFILE_PATH))))
R_ARGS := --no-site-file --no-environ --no-save \
--no-restore --no-resave-data --no-manual --quiet
ifneq (, $(findstring r-devel,$(CURRENT_DIR)))
R := R_devel.sh
R := Rdevel.sh
else
R := R
endif
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## dgo 0.2.14

* Avoid an error during testing, on R built `--without-long-double`.

## dgo 0.2.13

* Fix an issue introduced in v0.2.12 that led to an unexpected error in
Expand Down
129 changes: 40 additions & 89 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,70 +1,41 @@
dgo: Dynamic Estimation of Group-Level Opinion
================

[![Build
Status](https://travis-ci.org/jamesdunham/dgo.svg?branch=master)](https://travis-ci.org/jamesdunham/dgo)
[![Build
status](https://ci.appveyor.com/api/projects/status/1ta36kmoqen98k87?svg=true)](https://ci.appveyor.com/project/jamesdunham/dgo)
[![codecov](https://codecov.io/gh/jamesdunham/dgo/branch/master/graph/badge.svg)](https://codecov.io/gh/jamesdunham/dgo)

# Introduction

dgo is an R package for the dynamic estimation of group-level public
opinion. You can use the package to estimate latent trait means in
subpopulations from survey data. For example, dgo can estimate the
average policy liberalism in each American state over time among
Democrats, Independents, and Republicans, given their answers to survey
questions about policy proposals.

dgo accomplishes this using a Bayesian group-level IRT approach
developed by [Caughey and Warshaw
2015](http://pan.oxfordjournals.org/content/early/2015/02/04/pan.mpu021.full.pdf+html).
It models latent traits at the level of demographic and geographic
groups rather than individuals. It uses a hierarchical model to borrow
strength cross-sectionally and dynamic linear models to do so across
time.

The package can also be used to estimate smoothed estimates of
subpopulations’ average responses to single survey items, using a
dynamic multi-level regression and poststratification (MRP) model
([Park, Gelman, and Bafumi
2004](http://stat.columbia.edu/~gelman/research/published/StateOpinionsNationalPolls.050712.dkp.pdf)).
For instance, you can use dgo to estimate public opinion in each state
on same-sex marriage or the Affordable Care Act.

This model opens up new areas of research on historical public opinion
in the United States at the subnational level. It also allows scholars
of comparative politics to estimate dynamic cross-national models of
public opinion.

# Installation

dgo can be installed from
[CRAN](https://CRAN.R-project.org/package=dgo):
[![Build Status](https://travis-ci.org/jamesdunham/dgo.svg?branch=master)](https://travis-ci.org/jamesdunham/dgo) [![Build status](https://ci.appveyor.com/api/projects/status/1ta36kmoqen98k87?svg=true)](https://ci.appveyor.com/project/jamesdunham/dgo) [![codecov](https://codecov.io/gh/jamesdunham/dgo/branch/master/graph/badge.svg)](https://codecov.io/gh/jamesdunham/dgo)

Introduction
============

dgo is an R package for the dynamic estimation of group-level public opinion. You can use the package to estimate latent trait means in subpopulations from survey data. For example, dgo can estimate the average policy liberalism in each American state over time among Democrats, Independents, and Republicans, given their answers to survey questions about policy proposals.

dgo accomplishes this using a Bayesian group-level IRT approach developed by [Caughey and Warshaw 2015](http://pan.oxfordjournals.org/content/early/2015/02/04/pan.mpu021.full.pdf+html). It models latent traits at the level of demographic and geographic groups rather than individuals. It uses a hierarchical model to borrow strength cross-sectionally and dynamic linear models to do so across time.

The package can also be used to estimate smoothed estimates of subpopulations' average responses to single survey items, using a dynamic multi-level regression and poststratification (MRP) model ([Park, Gelman, and Bafumi 2004](http://stat.columbia.edu/~gelman/research/published/StateOpinionsNationalPolls.050712.dkp.pdf)). For instance, you can use dgo to estimate public opinion in each state on same-sex marriage or the Affordable Care Act.

This model opens up new areas of research on historical public opinion in the United States at the subnational level. It also allows scholars of comparative politics to estimate dynamic cross-national models of public opinion.

Installation
============

dgo can be installed from [CRAN](https://CRAN.R-project.org/package=dgo):

``` r
install.packages("dgo")
```

Or get the latest version from
[GitHub](https://github.com/jamesdunham/dgo) using
[devtools](https://github.com/hadley/devtools/):
Or get the latest version from [GitHub](https://github.com/jamesdunham/dgo) using [devtools](https://github.com/hadley/devtools/):

``` r
if (!require(devtools, quietly = TRUE)) install.packages("devtools")
devtools::install_github("jamesdunham/dgo")
```

dgo requires a working installation of
[RStan](http://mc-stan.org/interfaces/rstan.html). If you don’t have
already have RStan, follow its “[Getting
Started](https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started)
guide.
dgo requires a working installation of [RStan](http://mc-stan.org/interfaces/rstan.html). If you don't have already have RStan, follow its "[Getting Started](https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started)" guide.

# Usage
Usage
=====

Load the package and set RStan’s recommended options for a local,
multicore machine with excess RAM:
Load the package and set RStan's recommended options for a local, multicore machine with excess RAM:

``` r
library(dgo)
Expand All @@ -75,44 +46,24 @@ options(mc.cores = parallel::detectCores())
The minimal workflow from raw data to estimation is:

1. shape input data using the `shape()` function; and
2. pass the result to the `dgirt()` function to estimate a latent trait
(e.g., conservatism) or `dgmrp()` function to estimate opinion on a
single survey question.

# Troubleshooting

Please [report issues](https://github.com/jamesdunham/dgo/issues) that
you encounter.

- OS X only: RStan creates temporary files during estimation in a
location given by `tempdir()`, typically an arbitrary location in
`/var/folders`. If a model runs for days, these files can be cleaned
up while still needed, which induces an error. A good solution is to
set a safer path for temporary files, using an environment variable
checked at session startup. For help setting environment variables,
see the Stack Overflow question
[here](https://stackoverflow.com/questions/17107206/change-temporary-directory).
Confirm the new path before starting your model run by restarting R
and checking the output from `tempdir()`.

- Models fitted before October 2016 (specifically \<
[\#8e6a2cf](https://github.com/jamesdunham/dgo/commit/8e6a2cfbe00b2cd4a908b3067241e06124d143cd))
using dgirt are not fully compatible with dgo. Their contents can be
extracted without using dgo, however, with the `$` indexing
operator. For example: `as.data.frame(dgirtfit_object$stan.cmb)`.

- Calling `dgirt()` or `dgmrp()` can generate
[warnings](http://mc-stan.org/misc/warnings#compiler-warnings)
during model compilation. These are safe to ignore, or can be
suppressed by following the linked instructions.

# Contributing and citing

dgo is under development and we welcome
[suggestions](https://github.com/jamesdunham/dgo/issues).
2. pass the result to the `dgirt()` function to estimate a latent trait (e.g., conservatism) or `dgmrp()` function to estimate opinion on a single survey question.

Troubleshooting
===============

Please [report issues](https://github.com/jamesdunham/dgo/issues) that you encounter.

- OS X only: RStan creates temporary files during estimation in a location given by `tempdir()`, typically an arbitrary location in `/var/folders`. If a model runs for days, these files can be cleaned up while still needed, which induces an error. A good solution is to set a safer path for temporary files, using an environment variable checked at session startup. For help setting environment variables, see the Stack Overflow question [here](https://stackoverflow.com/questions/17107206/change-temporary-directory). Confirm the new path before starting your model run by restarting R and checking the output from `tempdir()`.

- Models fitted before October 2016 (specifically &lt; [\#8e6a2cf](https://github.com/jamesdunham/dgo/commit/8e6a2cfbe00b2cd4a908b3067241e06124d143cd)) using dgirt are not fully compatible with dgo. Their contents can be extracted without using dgo, however, with the `$` indexing operator. For example: `as.data.frame(dgirtfit_object$stan.cmb)`.

- Calling `dgirt()` or `dgmrp()` can generate [warnings](http://mc-stan.org/misc/warnings#compiler-warnings) during model compilation. These are safe to ignore, or can be suppressed by following the linked instructions.

Contributing and citing
=======================

dgo is under development and we welcome [suggestions](https://github.com/jamesdunham/dgo/issues).

The package citation is:

Dunham, James, Devin Caughey, and Christopher Warshaw. 2017. dgo:
Dynamic Estimation of Group-level Opinion. R package.
<https://jdunham.io/dgo/>.
Dunham, James, Devin Caughey, and Christopher Warshaw. 2017. dgo: Dynamic Estimation of Group-level Opinion. R package. <https://jdunham.io/dgo/>.
15 changes: 7 additions & 8 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
## Test environments

* Ubuntu 14.04.5 LTS (on travis-ci), R 3.4.2 (devel, release) and R 3.3.3
* macOS 10.12.5 and 10.11.6 (on travis-ci), R 3.4.2 (devel, release) and R 3.3.3
* Windows Server 2012 R2 x64 (on appveyor), R 3.4.2 (release) i386 and x64

* Ubuntu 14.04.5 LTS (on travis-ci), R 3.4.2 and R 3.3.3
* macOS 10.12.6 and 10.11.6 (on travis-ci), R 3.4.3 and R 3.3.3
* Windows Server 2012 R2 x64 (on appveyor), R 3.4.3 (release) i386 and x64
* Fedora 27 (local), R 3.4.3 and R-devel 2017-12-20 r73933 with --disable-long-double

## R CMD check results

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.

There were no ERRORs or WARNINGs; there was one NOTE. This submission resolves a
failing noLD check. Confirmed using a local build of R-devel with
--disable-long-double.
Loading

0 comments on commit 022d509

Please sign in to comment.