-
Notifications
You must be signed in to change notification settings - Fork 1
/
data-transformation.html
196 lines (153 loc) · 9.51 KB
/
data-transformation.html
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<!DOCTYPE html>
<html lang="" xml:lang="">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Chapter 3 Data transformation | Political views and their attributes</title>
<meta name="description" content="Chapter 3 Data transformation | Political views and their attributes" />
<meta name="generator" content="bookdown 0.24 and GitBook 2.6.7" />
<meta property="og:title" content="Chapter 3 Data transformation | Political views and their attributes" />
<meta property="og:type" content="book" />
<meta name="twitter:card" content="summary" />
<meta name="twitter:title" content="Chapter 3 Data transformation | Political views and their attributes" />
<meta name="author" content="Zhenyu Yuan and Yuki Ikeda" />
<meta name="date" content="2021-12-13" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<link rel="prev" href="data-sources.html"/>
<link rel="next" href="missing-values.html"/>
<script src="libs/header-attrs-2.11/header-attrs.js"></script>
<script src="libs/jquery-3.6.0/jquery-3.6.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/fuse.js@6.4.6/dist/fuse.min.js"></script>
<link href="libs/gitbook-2.6.7/css/style.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-table.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-bookdown.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-highlight.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-search.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-fontsettings.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-clipboard.css" rel="stylesheet" />
<link href="libs/anchor-sections-1.0.1/anchor-sections.css" rel="stylesheet" />
<script src="libs/anchor-sections-1.0.1/anchor-sections.js"></script>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<div class="book without-animation with-summary font-size-2 font-family-1" data-basepath=".">
<div class="book-summary">
<nav role="navigation">
<ul class="summary">
<li><a href="./">POA</a></li>
<li class="divider"></li>
<li class="chapter" data-level="1" data-path="index.html"><a href="index.html"><i class="fa fa-check"></i><b>1</b> Introduction</a></li>
<li class="chapter" data-level="2" data-path="data-sources.html"><a href="data-sources.html"><i class="fa fa-check"></i><b>2</b> Data sources</a>
<ul>
<li class="chapter" data-level="2.1" data-path="data-sources.html"><a href="data-sources.html#american-trends-panel-atp-by-the-pew-research-center"><i class="fa fa-check"></i><b>2.1</b> American Trends Panel (ATP) by the Pew Research Center</a></li>
<li class="chapter" data-level="2.2" data-path="data-sources.html"><a href="data-sources.html#us-election-data"><i class="fa fa-check"></i><b>2.2</b> US Election Data</a></li>
<li class="chapter" data-level="2.3" data-path="data-sources.html"><a href="data-sources.html#how-to-answer-the-questions-above-using-the-data"><i class="fa fa-check"></i><b>2.3</b> How to answer the questions above using the data</a></li>
</ul></li>
<li class="chapter" data-level="3" data-path="data-transformation.html"><a href="data-transformation.html"><i class="fa fa-check"></i><b>3</b> Data transformation</a></li>
<li class="chapter" data-level="4" data-path="missing-values.html"><a href="missing-values.html"><i class="fa fa-check"></i><b>4</b> Missing values</a>
<ul>
<li class="chapter" data-level="4.1" data-path="missing-values.html"><a href="missing-values.html#respondents-attributes-for-questions-1-3"><i class="fa fa-check"></i><b>4.1</b> Respondents’ attributes for Questions 1-3</a></li>
<li class="chapter" data-level="4.2" data-path="missing-values.html"><a href="missing-values.html#question-1"><i class="fa fa-check"></i><b>4.2</b> Question 1</a></li>
<li class="chapter" data-level="4.3" data-path="missing-values.html"><a href="missing-values.html#question-2"><i class="fa fa-check"></i><b>4.3</b> Question 2</a></li>
<li class="chapter" data-level="4.4" data-path="missing-values.html"><a href="missing-values.html#question-3"><i class="fa fa-check"></i><b>4.4</b> Question 3</a></li>
</ul></li>
<li class="chapter" data-level="5" data-path="results.html"><a href="results.html"><i class="fa fa-check"></i><b>5</b> Results</a>
<ul>
<li class="chapter" data-level="5.1" data-path="results.html"><a href="results.html#question-1-1"><i class="fa fa-check"></i><b>5.1</b> Question 1</a></li>
<li class="chapter" data-level="5.2" data-path="results.html"><a href="results.html#question-2-1"><i class="fa fa-check"></i><b>5.2</b> Question 2</a></li>
<li class="chapter" data-level="5.3" data-path="results.html"><a href="results.html#question-3-1"><i class="fa fa-check"></i><b>5.3</b> Question 3</a></li>
<li class="chapter" data-level="5.4" data-path="results.html"><a href="results.html#question-4"><i class="fa fa-check"></i><b>5.4</b> Question 4</a></li>
<li class="chapter" data-level="5.5" data-path="results.html"><a href="results.html#question-5"><i class="fa fa-check"></i><b>5.5</b> Question 5</a></li>
</ul></li>
<li class="chapter" data-level="6" data-path="interactive-component.html"><a href="interactive-component.html"><i class="fa fa-check"></i><b>6</b> Interactive component</a></li>
<li class="chapter" data-level="7" data-path="conclusion.html"><a href="conclusion.html"><i class="fa fa-check"></i><b>7</b> Conclusion</a></li>
<li class="divider"></li>
<li><a href="https://github.com/rstudio/bookdown" target="blank">Published with bookdown</a></li>
</ul>
</nav>
</div>
<div class="book-body">
<div class="body-inner">
<div class="book-header" role="navigation">
<h1>
<i class="fa fa-circle-o-notch fa-spin"></i><a href="./">Political views and their attributes</a>
</h1>
</div>
<div class="page-wrapper" tabindex="-1" role="main">
<div class="page-inner">
<section class="normal" id="section-">
<div id="data-transformation" class="section level1" number="3">
<h1><span class="header-section-number">Chapter 3</span> Data transformation</h1>
<p>In this chapter, we briefly explain the data transformation process for exploratory analyses with R.</p>
<p>Since, the data is already well-formatted as .sav files, we only imported them into dataframes and only rendered some factor re-labeings or re-namings after analyzing the missing value patterns.</p>
<p>Note that our data have weights which correct the potential bias of the attributes of the respondents of the questionnaires based on some other referenced large data. All the results in the existing report is based on those weights. Therefore, we should also consider those weights when we aggregate samples into graphs. However, for the following reasons, we employ simple aggregation for Question 1-3 (that is, just by simply counting the number of samples in the raw data, instead of aggregating the weights attached on the raw data).
Question 4-5 are based on the resampled dataset with n=100,000 by the method written below.</p>
<ul>
<li><p>Many EDVA packages including those we used in this analyses cannot deal with data with weights. Hence, it requires quite additional work.</p></li>
<li><p>Although one way to overcome this is to resample the raw data with sampling probabilities proportional to those weights.
However, it would fairly augment the raw data already not small (about from 4,000 to 10,000 rows with tens of columns for each dataset) if we try to ensure that the sampling error would be minimized, which was difficult for one of us due to the limited performance of his PC.</p></li>
<li><p>We have confirmed that there are no fatal discrepancies (that would change the conclusion) between the weighted aggregated results given in the existing report and our simply aggregated one given here.</p></li>
</ul>
</div>
</section>
</div>
</div>
</div>
<a href="data-sources.html" class="navigation navigation-prev " aria-label="Previous page"><i class="fa fa-angle-left"></i></a>
<a href="missing-values.html" class="navigation navigation-next " aria-label="Next page"><i class="fa fa-angle-right"></i></a>
</div>
</div>
<script src="libs/gitbook-2.6.7/js/app.min.js"></script>
<script src="libs/gitbook-2.6.7/js/clipboard.min.js"></script>
<script src="libs/gitbook-2.6.7/js/plugin-search.js"></script>
<script src="libs/gitbook-2.6.7/js/plugin-sharing.js"></script>
<script src="libs/gitbook-2.6.7/js/plugin-fontsettings.js"></script>
<script src="libs/gitbook-2.6.7/js/plugin-bookdown.js"></script>
<script src="libs/gitbook-2.6.7/js/jquery.highlight.js"></script>
<script src="libs/gitbook-2.6.7/js/plugin-clipboard.js"></script>
<script>
gitbook.require(["gitbook"], function(gitbook) {
gitbook.start({
"sharing": {
"github": false,
"facebook": true,
"twitter": true,
"linkedin": false,
"weibo": false,
"instapaper": false,
"vk": false,
"whatsapp": false,
"all": ["facebook", "twitter", "linkedin", "weibo", "instapaper"]
},
"fontsettings": {
"theme": "white",
"family": "sans",
"size": 2
},
"edit": {
"link": "https://github.com/Francis-ZY-Yuan/EDAV-Project/edit/main/03-cleaning.Rmd",
"text": "Edit"
},
"history": {
"link": null,
"text": null
},
"view": {
"link": "https://github.com/Francis-ZY-Yuan/EDAV-Project/blob/main/03-cleaning.Rmd",
"text": null
},
"download": null,
"search": {
"engine": "fuse",
"options": null
},
"toc": {
"collapse": "subsection"
}
});
});
</script>
</body>
</html>