/
README.Rmd
68 lines (47 loc) · 1.56 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# ccesMRPviz
<!-- badges: start -->
<!-- badges: end -->
The goal of ccesMRPviz is to visualize and diagnose common tasks in MRP and survey analysis. It was formerly a part of the [ccesMRPrun](https://github.com/kuriwaki/ccesMRPrun) package.
```{r, messages=FALSE, warnings=FALSE}
library(dplyr)
library(ccesMRPrun)
library(ccesMRPviz)
```
```{r}
# MRP sims setup
mrp_df <- summ_sims(poststrat_draws(fit_GA, poststrat_tgt = acs_GA)) %>%
left_join(elec_GA)
mrp_df
```
## scatter_45
Currently, the only function is `scatter_45`, which is a wrapper around ggplot which enforces a visualization of a simple scatterplot that I [argue](https://github.com/RohanAlexander/mrpbook) is important for finding patterns in survey estimates relative to ground truth. These graphs:
- Enforce a 1:1 aspect ratio
- Uses the same range for both axes
which makes the plot into a square.
In addition, this wrapper easily enables:
- Computation and listing of summary stats (RMSE, Correlation, Mean Deviance)
- Facetting scatterplots using `facet_wrap`
- Adding confidence intervals
- Coloring and labeling points.
```{r viz1}
scatter_45(mrp_df,
clinton_vote,
p_mrp_est,
lblvar = cd,
lbvar = p_mrp_050,
ubvar = p_mrp_950,
xlab = "Clinton Vote",
ylab = "MRP Estimate")
```