-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathClean-Anonymize.html
568 lines (489 loc) · 21.8 KB
/
Clean-Anonymize.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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="pandoc" />
<meta http-equiv="X-UA-Compatible" content="IE=EDGE" />
<title>Clean & Anonymise</title>
<script src="libs/jquery-1.11.3/jquery.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="libs/bootstrap-3.3.5/css/flatly.min.css" rel="stylesheet" />
<script src="libs/bootstrap-3.3.5/js/bootstrap.min.js"></script>
<script src="libs/bootstrap-3.3.5/shim/html5shiv.min.js"></script>
<script src="libs/bootstrap-3.3.5/shim/respond.min.js"></script>
<script src="libs/navigation-1.1/tabsets.js"></script>
<meta name="robots" content="index, follow">
<title>IFHS: Integrated Framework for Household Survey</title>
<link rel="stylesheet" href="./include/ifhs2.css" />
<script type="text/javascript" src="./libs/zeroclipboard-2.2.0/ZeroClipboard.js"></script>
<link rel="stylesheet" href="./libs/colorbox-1.6.1/colorbox.css" />
<script type="text/javascript" src="./libs/colorbox-1.6.1/jquery.colorbox-min.js"></script>
<!--- favicon --->
<link rel="apple-touch-icon" sizes="57x57" href="./images/favicon/apple-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="./images/favicon/apple-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="./images/favicon/apple-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="./images/favicon/apple-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="./images/favicon/apple-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="./images/favicon/apple-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="./images/favicon/apple-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="./images/favicon/apple-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="./images/favicon/apple-icon-180x180.png">
<link rel="icon" type="image/png" sizes="192x192" href="./images/favicon/android-icon-192x192.png">
<link rel="icon" type="image/png" sizes="32x32" href="./images/favicon/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="96x96" href="./images/favicon/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="./images/favicon/favicon-16x16.png">
<link rel="manifest" href="./images/favicon/manifest.json">
<meta name="msapplication-TileColor" content="#ffffff">
<meta name="msapplication-TileImage" content="./images/favicon/ms-icon-144x144.png">
<meta name="theme-color" content="#ffffff">
<style type="text/css">
h1 {
font-size: 34px;
}
h1.title {
font-size: 38px;
}
h2 {
font-size: 30px;
}
h3 {
font-size: 24px;
}
h4 {
font-size: 18px;
}
h5 {
font-size: 16px;
}
h6 {
font-size: 12px;
}
.table th:not([align]) {
text-align: left;
}
</style>
<style type = "text/css">
.main-container {
max-width: 940px;
margin-left: auto;
margin-right: auto;
}
code {
color: inherit;
background-color: rgba(0, 0, 0, 0.04);
}
img {
max-width:100%;
}
.tabbed-pane {
padding-top: 12px;
}
.html-widget {
margin-bottom: 20px;
}
button.code-folding-btn:focus {
outline: none;
}
summary {
display: list-item;
}
</style>
<!-- tabsets -->
<style type="text/css">
.tabset-dropdown > .nav-tabs {
display: inline-table;
max-height: 500px;
min-height: 44px;
overflow-y: auto;
background: white;
border: 1px solid #ddd;
border-radius: 4px;
}
.tabset-dropdown > .nav-tabs > li.active:before {
content: "";
font-family: 'Glyphicons Halflings';
display: inline-block;
padding: 10px;
border-right: 1px solid #ddd;
}
.tabset-dropdown > .nav-tabs.nav-tabs-open > li.active:before {
content: "";
border: none;
}
.tabset-dropdown > .nav-tabs.nav-tabs-open:before {
content: "";
font-family: 'Glyphicons Halflings';
display: inline-block;
padding: 10px;
border-right: 1px solid #ddd;
}
.tabset-dropdown > .nav-tabs > li.active {
display: block;
}
.tabset-dropdown > .nav-tabs > li > a,
.tabset-dropdown > .nav-tabs > li > a:focus,
.tabset-dropdown > .nav-tabs > li > a:hover {
border: none;
display: inline-block;
border-radius: 4px;
}
.tabset-dropdown > .nav-tabs.nav-tabs-open > li {
display: block;
float: none;
}
.tabset-dropdown > .nav-tabs > li {
display: none;
}
</style>
<!-- code folding -->
</head>
<body>
<div class="container-fluid main-container">
<nav>
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.html">Integrated Framework for Household Survey</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="design" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Design <span class="caret"></span></a>
<ul class="dropdown-menu multi-column columns-3" role="menu" id="menu_design">
<div class="row">
<div class="col-sm-4">
<ul class="multi-column-dropdown">
<li class="dropdown-header">Planning</li>
<li><a href="Assessment-Project-Document.html">Assessment Project Document</a></li>
<li><a href="Memorandum-of-Understanding.html">Memorandum of Understanding</a></li>
<li><a href="Terms-of-Reference-for-Assessment-Focal-Point.html">Terms of Reference for Assessment Focal Point</a></li>
</ul>
</div>
<div class="col-sm-4">
<ul class="multi-column-dropdown">
<li class="dropdown-header">Methodology</li>
<li><a href="Sampling.html">Sampling</a></li>
<li><a href="Interview.html">Interview approach</a></li>
<li><a href="Pre-Assessment.html">Pre-Assessment</a></li>
</ul>
</div>
<div class="col-sm-4">
<ul class="multi-column-dropdown">
<li class="dropdown-header">Form</li>
<li ><a href="protection-Topics.html">Protection Topics</a></li>
<li ><a href="Module-questions.html">Questions Modules</a></li>
<li ><a href="Guidelines-for-Customisation.html">Guidelines for Customisation</a></li>
</ul>
</div>
</div>
</ul>
</li>
<li class="dropdown">
<a href="collect" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Collect <span class="caret"></span></a>
<ul class="dropdown-menu multi-column columns-3" role="menu" id="menu_collect">
<div class="row">
<div class="col-sm-4">
<ul class="multi-column-dropdown">
<li class="dropdown-header">Preparing for fieldwork</li>
<li><a href="Configure-forms.html">Configure forms</a></li>
<li><a href="Pre-test-Phase.html">Pre-test Phase</a></li>
<li><a href="Fieldwork-Training-Agenda.html">Fieldwork Training and Agenda</a></li>
</ul>
</div>
<div class="col-sm-4">
<ul class="multi-column-dropdown">
<li class="dropdown-header">Using KoboToolBox</li>
<li ><a href="Data-Protection-Impact-Assessment.html">Data Protection Impact Assessment</a></li>
<li ><a href="Server-Configuration.html">Server Configuration</a></li>
<li ><a href="Data-Entry.html">Data Entry</a></li>
</ul>
</div>
<div class="col-sm-4">
<ul class="multi-column-dropdown">
<li class="dropdown-header">Fieldwork manual</li>
<li ><a href="Instructions-for-Interviewers.html">Instructions for Interviewers</a></li>
<li ><a href="Instructions-for-Supervisors-Editors.html">Instructions for Supervisors and Editors</a></li>
<li ><a href="Instructions-for-Managers.html">Instructions for Managers</a></li>
</ul>
</div>
</div>
</ul>
</li>
<li class="dropdown">
<a href="analyse" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Analyse <span class="caret"></span></a>
<ul class="dropdown-menu multi-column columns-3" role="menu" id="menu_analyse">
<div class="row">
<div class="col-sm-4">
<ul class="multi-column-dropdown">
<li class="dropdown-header">Analytics Steps</li>
<li ><a href="Clean-Anonymize.html">Clean & Anonymize</a></li>
<li ><a href="Describe.html">Describe</a></li>
<li ><a href="Discover.html">Discover</a></li>
<li ><a href="Predict.html">Predict</a></li>
<li ><a href="Advise.html">Advise</a></li>
</ul>
</div>
<div class="col-sm-4">
<ul class="multi-column-dropdown">
<li class="dropdown-header">Analysis Process</li>
<li ><a href="Data-Crunching.html">Data Crunching</a></li>
<li ><a href="Analysis-Workshop.html">Analysis Workshop</a></li>
<li ><a href="Model-for-Final-Report.html">Model for Final Report</a></li>
</ul>
</div>
<div class="col-sm-4">
<ul class="multi-column-dropdown">
<li class="dropdown-header">Communication</li>
<li><a href="Slides-Infographics.html">Slides & Infographics</a></li>
<li><a href="Microdata.html">Sharing microdata for social scientist</a></li>
<li><a href="Open-Data.html">Open Data</a></li>
</ul>
</div>
</div>
</ul>
</li>
<li><a href="Integrated-framework-household-survey.pdf">PDF</a></li>
</ul>
<form id="rechercher" class="navbar-form navbar-right" role="search" style="padding-top: 5px;" method="get" action="https://tontonroger.org/">
<div class="form-group">
<input name="q" type="text" class="form-control input-sm" placeholder="Search">
</div>
<button type="submit" class="btn btn-default btn-sm" name="Search">
<span class="glyphicon glyphicon-search" aria-hidden="true"></span>
</button>
</form>
</div><!--/.nav-collapse -->
</div><!--/.container -->
</div><!--/.navbar -->
</nav>
<div class="row">
<div class="col-sm-9" role="main">
<article>
<div class="fluid-row" id="header">
<h1 class="title toc-ignore">Clean & Anonymise</h1>
</div>
<div id="TOC">
<ul>
<li><a href="#cleaning-linked-to-the-sample">Cleaning linked to the sample</a></li>
<li><a href="#cleaning-on-numeric-variable-filter-unwanted-outliers">Cleaning on numeric variable: Filter Unwanted Outliers</a></li>
<li><a href="#cleaning-categoric-variables-review-categories">Cleaning categoric variables: review categories</a></li>
<li><a href="#fix-labeling">Fix labeling</a></li>
<li><a href="#handle-missing-data">Handle Missing Data</a></li>
<li><a href="#anonymisation">Anonymisation</a></li>
</ul>
</div>
<div class="important">
<p>Data Cleaning is an essential step in data analysis. Most of the cleaning should allow to predect some potential errors in the dataset.</p>
</div>
<p>A multiplicity of errors can occurs during a survey. Once data are collected only a few of them can be addressed.</p>
<p><img src="images/error.png" /> ## Clean</p>
<div id="cleaning-linked-to-the-sample" class="section level3">
<h3>Cleaning linked to the sample</h3>
<p>In this case, some household were visited multiples times. The only way to address this is to have a cleaning log that contains the uniqueID (meta_instance_id) of the questionnaires that will need to be deleted.</p>
</div>
<div id="cleaning-on-numeric-variable-filter-unwanted-outliers" class="section level3">
<h3>Cleaning on numeric variable: Filter Unwanted Outliers</h3>
<p>Outliers on numeric variable can be spotted looking at the value of standard deviation.</p>
<p>Keep in mind that “outliers are innocent until proven guilty”. Sometimes they traduce a proable in data collection but sometimes it can also add important information. One must have a good reason for removing an outlier, such as suspicious measurements that are unlikely to be real data.</p>
</div>
<div id="cleaning-categoric-variables-review-categories" class="section level3">
<h3>Cleaning categoric variables: review categories</h3>
<p>xlsform allow to add the option of using <strong>or_other</strong> when raising a categoric questions. Often the results of this sub-variable needs to be reviewed to ensure that the or_other can not be affected to any existing value.</p>
<p>The other point to check is low-frequency modalities that might need to be compacted together. This is also important in the sense that it will facilitate the data anonymisation in case this variable is a key one.</p>
</div>
<div id="fix-labeling" class="section level3">
<h3>Fix labeling</h3>
<p>When recoding the data set it can appears often that the label attributed to the variables when raising the questions are not worded well, comme with typos / capitalisation issues or are too long to appear in a report. This can be fixed directly within the xlsform used for the data analysis plan.</p>
</div>
<div id="handle-missing-data" class="section level3">
<h3>Handle Missing Data</h3>
<p>This can be important when developing the analysis for the scoring.</p>
<p>The 2 most commonly recommended ways of dealing with missing data are:</p>
<ul>
<li><p>Dropping observations that have missing values: Dropping missing values is sub-optimal because when you drop observations, you drop information. The fact that the value was missing may be informative in itself.</p></li>
<li><p>Imputing the missing values based on other observations</p></li>
</ul>
<p>The best way to handle missing data for categorical features is to simply label them as ’Missing’!</p>
<ul>
<li>You’re essentially adding a new class for the feature.</li>
<li>This tells the algorithm that the value was missing.</li>
<li>This also gets around the technical requirement for no missing values.</li>
</ul>
<p>For missing numeric data, you should flag and fill the values.</p>
<ul>
<li>Flag the observation with an indicator variable of missingness.</li>
<li>Then, fill the original missing value with 0 just to meet the technical requirement of no missing values.</li>
</ul>
<p>By using this technique of flagging and filling, you are essentially allowing the algorithm to estimate the optimal constant for missingness, instead of just filling it in with the mean.</p>
</div>
<div id="anonymisation" class="section level2">
<h2>Anonymisation</h2>
</div>
</article>
</div>
<div class="col-sm-3" role="complementary">
<nav class="hidden-print hidden-xs" id="nav_sidebar">
</nav>
</div>
</div>
<script>
// manage active state of menu based on current page
$(document).ready(function () {
// active menu
href = window.location.pathname;
href = href.substr(href.lastIndexOf('/') + 1);
if (href=='') href = 'index.html';
$('a[href="' + href + '"]').parent().addClass('active');
$('a[href="' + href + '"]').parent().parents('li').addClass('active');
// élargir la page d'accueil
if (href=='index.html') $('.col-sm-9').attr('class','col-sm-12');
// rechercher
$("#rechercher").submit(function(event) {
$('input[name="q"]').val($('input[name="q"]').val() + ' site:unhcr.github.io/Integrated-framework-household-survey');
});
// sidebar
$("#nav_sidebar").append($("#TOC").html());
$("#nav_sidebar ul").addClass("nav nav-stacked");
$("#TOC").addClass("visible-xs-block");
$('body').scrollspy({
target: '#nav_sidebar',
offset: 40
});
// Identifier les <pre> fermant
$('pre').next("*:not(pre)").prev().addClass('last'); // Dernier <pre> de chaque groupe contigu de <pre>
$('pre').parent().each(function (){
$(this).children('pre').last().addClass('last');
}); // Si <pre> est le dernier enfant de son parent
// Ajout liens rdocumentation et tooltip
$("code[data-pkg]").each(function( index ) {
pkg = $(this).attr('data-pkg');
if ($(this).attr('data-rdoc') !== undefined) {
rdocumentation = $(this).attr('data-rdoc');
} else {
rdocumentation = $(this).text();
}
fonction = $(this).text();
$(this).wrap('<a href="http://www.rdocumentation.org/packages/'+pkg+'/functions/'+rdocumentation+'">');
$(this).attr('data-toggle','tooltip');
$(this).attr('data-placement','top');
$(this).attr('title','package : ' + pkg);
$('[data-toggle="tooltip"]').tooltip();
});
$("code.pkg").each(function( index ) {
$(this).wrap('<a href="http://www.rdocumentation.org/packages/'+$(this).text()+'">');
});
// Figures
$("figure").each(function( index ) {
if ($(this).children("figcaption").length > 0)
$(this).children("figcaption:first").prepend('<span class="figure-number">Figure '+(index+1)+'.</span> ');
else
$(this).append($("<figcaption>").append('<span class="figure-number">Figure '+(index+1)+'</span>'));
});
// Colorbox
jQuery('article div img').colorbox({
maxWidth: '90%',
maxHeight: '90%',
rel: 'figures',
current: "",
href: function(){
return $(this).attr('src');
},
title: function(){
return $(this).attr('alt');
}
});
jQuery('article div img').css('cursor', 'pointer');
jQuery('figure img').colorbox({
maxWidth: '90%',
maxHeight: '90%',
rel: 'figures',
current: "",
href: function(){
return $(this).attr('src');
},
title: function(){
return $(this).parent().children("figcaption").text();
}
});
jQuery('figure img').css('cursor', 'pointer');
// ZeroClipboard
$('pre.r').parent().each(function(){
$(this).children('pre.r').first().before('<div class="zero-clipboard hidden-print hidden-xs"><button class="btn-clipboard">Copy</button></div>');
}); // Il peut arriver que le pre ne soit pas précédé (cf. figures)
$('*:not(pre):not(.zero-clipboard) + pre.r').before('<div class="zero-clipboard hidden-print hidden-xs"><button class="btn-clipboard">Copy</button></div>');
$('pre.last').after(function() {
if ($(this).hasClass("r")) res = $(this).text(); else res = "";
$(this).prevUntil('*:not(pre)','pre.r').each(function() {
res = $(this).text() + '\n' + res;
});
return '<div class="clipboard">' + res + '</div>';
});
$('.zero-clipboard').each(function(index){
$(this).children('.btn-clipboard').attr('data-clipboard-target','clipboard_'+index);
$(this).nextAll("div.clipboard").first().attr('id','clipboard_'+index);
});
var client = new ZeroClipboard( $(".btn-clipboard") );
client.on( "ready", function( readyEvent ) {
// alert( "ZeroClipboard SWF is ready!" );
client.on( "aftercopy", function( event ) {
// `this` === `client`
// `event.target` === the element that was clicked
//event.target.style.display = "none";
$(event.target).parent().before('<div class="alert alert-success"><a href="#" class="close" data-dismiss="alert">×</a>The <strong>R</strong> code is now copied in your clipboard.</div>');
} );
} );
});
</script>
<!-- disqus -->
<div class="row">
<div id="disqus_thread" class="col-sm-9" role="complementary"></div>
</div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'Integrated-framework-household-survey'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Activate JavaScript to see <a href="http://disqus.com/?ref_noscript">Disqus Comments.</a></noscript>
<!--<a href="http://disqus.com" class="dsq-brlink">Comments are hosted by <span class="logo-disqus">Disqus</span>.</a>-->
<footer>
<div class="row">
<div class="col-lg-12">
<p>Powered by <a href="http://www.r-project.org/" rel="nofollow">R</a>, </a><a href="http://www.rstudio.com/" rel="nofollow">RStudio</a>, <a href="http://rmarkdown.rstudio.com/" rel="nofollow">R Markdown</a>, <a href="http://yihui.name/knitr/" rel="nofollow">knitr</a>, <a href="http://pandoc.org/" rel="nofollow">pandoc</a> and <a href="http://www.princexml.com/" rel="nofollow">Prince XML</a>. Hosted by <a href="https://github.com/" rel="nofollow">GitHub</a>.</p>
</div>
</div>
</footer>
</div>
<script>
// add bootstrap table styles to pandoc tables
function bootstrapStylePandocTables() {
$('tr.header').parent('thead').parent('table').addClass('table table-condensed');
}
$(document).ready(function () {
bootstrapStylePandocTables();
});
</script>
<!-- tabsets -->
<script>
$(document).ready(function () {
window.buildTabsets("TOC");
});
$(document).ready(function () {
$('.tabset-dropdown > .nav-tabs > li').click(function () {
$(this).parent().toggleClass('nav-tabs-open')
});
});
</script>
<!-- code folding -->
</body>
</html>