<!DOCTYPE html>
<html lang="" xml:lang="">
<head>

  <meta charset="utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <title>National Crime Victimization Survey (NCVS) | Analyze Survey Data for Free</title>
  <meta name="description" content="National Crime Victimization Survey (NCVS) | Analyze Survey Data for Free" />
  <meta name="generator" content="bookdown 0.41 and GitBook 2.6.7" />

  <meta property="og:title" content="National Crime Victimization Survey (NCVS) | Analyze Survey Data for Free" />
  <meta property="og:type" content="book" />
  
  
  <meta name="github-repo" content="ajdamico/asdfree" />

  <meta name="twitter:card" content="summary" />
  <meta name="twitter:title" content="National Crime Victimization Survey (NCVS) | Analyze Survey Data for Free" />
  
  
  




  <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="national-beneficiary-survey-nbs.html"/>
<link rel="next" href="national-financial-capability-study-nfcs.html"/>
<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.1.0/anchor-sections.css" rel="stylesheet" />
<link href="libs/anchor-sections-1.1.0/anchor-sections-hash.css" rel="stylesheet" />
<script src="libs/anchor-sections-1.1.0/anchor-sections.js"></script>


<style type="text/css">
pre > code.sourceCode { white-space: pre; position: relative; }
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
pre > code.sourceCode > span:empty { height: 1.2em; }
.sourceCode { overflow: visible; }
code.sourceCode > span { color: inherit; text-decoration: inherit; }
pre.sourceCode { margin: 0; }
@media screen {
div.sourceCode { overflow: auto; }
}
@media print {
pre > code.sourceCode { white-space: pre-wrap; }
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
}
pre.numberSource code
  { counter-reset: source-line 0; }
pre.numberSource code > span
  { position: relative; left: -4em; counter-increment: source-line; }
pre.numberSource code > span > a:first-child::before
  { content: counter(source-line);
    position: relative; left: -1em; text-align: right; vertical-align: baseline;
    border: none; display: inline-block;
    -webkit-touch-callout: none; -webkit-user-select: none;
    -khtml-user-select: none; -moz-user-select: none;
    -ms-user-select: none; user-select: none;
    padding: 0 4px; width: 4em;
    color: #aaaaaa;
  }
pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa;  padding-left: 4px; }
div.sourceCode
  {   }
@media screen {
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
code span.al { color: #ff0000; font-weight: bold; } /* Alert */
code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
code span.at { color: #7d9029; } /* Attribute */
code span.bn { color: #40a070; } /* BaseN */
code span.bu { color: #008000; } /* BuiltIn */
code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
code span.ch { color: #4070a0; } /* Char */
code span.cn { color: #880000; } /* Constant */
code span.co { color: #60a0b0; font-style: italic; } /* Comment */
code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
code span.do { color: #ba2121; font-style: italic; } /* Documentation */
code span.dt { color: #902000; } /* DataType */
code span.dv { color: #40a070; } /* DecVal */
code span.er { color: #ff0000; font-weight: bold; } /* Error */
code span.ex { } /* Extension */
code span.fl { color: #40a070; } /* Float */
code span.fu { color: #06287e; } /* Function */
code span.im { color: #008000; font-weight: bold; } /* Import */
code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
code span.kw { color: #007020; font-weight: bold; } /* Keyword */
code span.op { color: #666666; } /* Operator */
code span.ot { color: #007020; } /* Other */
code span.pp { color: #bc7a00; } /* Preprocessor */
code span.sc { color: #4070a0; } /* SpecialChar */
code span.ss { color: #bb6688; } /* SpecialString */
code span.st { color: #4070a0; } /* String */
code span.va { color: #19177c; } /* Variable */
code span.vs { color: #4070a0; } /* VerbatimString */
code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
</style>

<style type="text/css">
  
  div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
</style>

<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="./">Analyze Survey Data for Free</a></li>
<b><li><a href="https://www.eventbrite.com/e/1032151692497">Free 3hr Workshop @ DCPL Nov 13</a></li></b>

<li class="divider"></li>
<li class="chapter" data-level="" data-path="index.html"><a href="index.html"><i class="fa fa-check"></i>Forty-Nine Public Microdatasets To Analyze Before You Die From An Easy To Type Website</a></li>
<li class="chapter" data-level="" data-path="trend-analysis-of-complex-survey-data.html"><a href="trend-analysis-of-complex-survey-data.html"><i class="fa fa-check"></i>Trend Analysis of Complex Survey Data</a>
<ul>
<li class="chapter" data-level="" data-path="trend-analysis-of-complex-survey-data.html"><a href="trend-analysis-of-complex-survey-data.html#download-import-preparation"><i class="fa fa-check"></i>Download, Import, Preparation</a></li>
<li class="chapter" data-level="" data-path="trend-analysis-of-complex-survey-data.html"><a href="trend-analysis-of-complex-survey-data.html#append-polynomials-to-each-year"><i class="fa fa-check"></i>Append Polynomials to Each Year</a></li>
<li class="chapter" data-level="" data-path="trend-analysis-of-complex-survey-data.html"><a href="trend-analysis-of-complex-survey-data.html#unadjusted-analysis-examples"><i class="fa fa-check"></i>Unadjusted Analysis Examples</a></li>
<li class="chapter" data-level="" data-path="trend-analysis-of-complex-survey-data.html"><a href="trend-analysis-of-complex-survey-data.html#calculate-joinpoints-needed"><i class="fa fa-check"></i>Calculate Joinpoints Needed</a></li>
<li class="chapter" data-level="" data-path="trend-analysis-of-complex-survey-data.html"><a href="trend-analysis-of-complex-survey-data.html#calculate-predicted-marginals"><i class="fa fa-check"></i>Calculate Predicted Marginals</a></li>
<li class="chapter" data-level="" data-path="trend-analysis-of-complex-survey-data.html"><a href="trend-analysis-of-complex-survey-data.html#identify-joinpoints-or-breakpoints"><i class="fa fa-check"></i>Identify Joinpoint(s) or Breakpoint(s)</a></li>
<li class="chapter" data-level="" data-path="trend-analysis-of-complex-survey-data.html"><a href="trend-analysis-of-complex-survey-data.html#interpret-and-conclude"><i class="fa fa-check"></i>Interpret and Conclude</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="american-community-survey-acs.html"><a href="american-community-survey-acs.html"><i class="fa fa-check"></i>American Community Survey (ACS)</a>
<ul>
<li class="chapter" data-level="" data-path="american-community-survey-acs.html"><a href="american-community-survey-acs.html#download-import-preparation-1"><i class="fa fa-check"></i>Download, Import, Preparation</a>
<ul>
<li class="chapter" data-level="" data-path="american-community-survey-acs.html"><a href="american-community-survey-acs.html#save-locally"><i class="fa fa-check"></i>Save Locally  </a></li>
<li class="chapter" data-level="" data-path="american-community-survey-acs.html"><a href="american-community-survey-acs.html#survey-design-definition"><i class="fa fa-check"></i>Survey Design Definition</a></li>
<li class="chapter" data-level="" data-path="american-community-survey-acs.html"><a href="american-community-survey-acs.html#variable-recoding"><i class="fa fa-check"></i>Variable Recoding</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="american-community-survey-acs.html"><a href="american-community-survey-acs.html#analysis-examples-with-the-survey-library"><i class="fa fa-check"></i>Analysis Examples with the <code>survey</code> library  </a>
<ul>
<li class="chapter" data-level="" data-path="american-community-survey-acs.html"><a href="american-community-survey-acs.html#unweighted-counts"><i class="fa fa-check"></i>Unweighted Counts</a></li>
<li class="chapter" data-level="" data-path="american-community-survey-acs.html"><a href="american-community-survey-acs.html#weighted-counts"><i class="fa fa-check"></i>Weighted Counts</a></li>
<li class="chapter" data-level="" data-path="american-community-survey-acs.html"><a href="american-community-survey-acs.html#descriptive-statistics"><i class="fa fa-check"></i>Descriptive Statistics</a></li>
<li class="chapter" data-level="" data-path="american-community-survey-acs.html"><a href="american-community-survey-acs.html#subsetting"><i class="fa fa-check"></i>Subsetting</a></li>
<li class="chapter" data-level="" data-path="american-community-survey-acs.html"><a href="american-community-survey-acs.html#measures-of-uncertainty"><i class="fa fa-check"></i>Measures of Uncertainty</a></li>
<li class="chapter" data-level="" data-path="american-community-survey-acs.html"><a href="american-community-survey-acs.html#regression-models-and-tests-of-association"><i class="fa fa-check"></i>Regression Models and Tests of Association</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="american-community-survey-acs.html"><a href="american-community-survey-acs.html#replication-example"><i class="fa fa-check"></i>Replication Example</a></li>
<li class="chapter" data-level="" data-path="american-community-survey-acs.html"><a href="american-community-survey-acs.html#poverty-and-inequality-estimation-with-convey"><i class="fa fa-check"></i>Poverty and Inequality Estimation with <code>convey</code>  </a></li>
<li class="chapter" data-level="" data-path="american-community-survey-acs.html"><a href="american-community-survey-acs.html#analysis-examples-with-srvyr"><i class="fa fa-check"></i>Analysis Examples with <code>srvyr</code>  </a></li>
</ul></li>
<li class="chapter" data-level="" data-path="area-health-resources-files-ahrf.html"><a href="area-health-resources-files-ahrf.html"><i class="fa fa-check"></i>Area Health Resources Files (AHRF)</a>
<ul>
<li class="chapter" data-level="" data-path="area-health-resources-files-ahrf.html"><a href="area-health-resources-files-ahrf.html#download-import-preparation-2"><i class="fa fa-check"></i>Download, Import, Preparation</a>
<ul>
<li class="chapter" data-level="" data-path="area-health-resources-files-ahrf.html"><a href="area-health-resources-files-ahrf.html#save-locally-1"><i class="fa fa-check"></i>Save Locally  </a></li>
<li class="chapter" data-level="" data-path="area-health-resources-files-ahrf.html"><a href="area-health-resources-files-ahrf.html#variable-recoding-1"><i class="fa fa-check"></i>Variable Recoding</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="area-health-resources-files-ahrf.html"><a href="area-health-resources-files-ahrf.html#analysis-examples-with-base-r"><i class="fa fa-check"></i>Analysis Examples with base R  </a>
<ul>
<li class="chapter" data-level="" data-path="area-health-resources-files-ahrf.html"><a href="area-health-resources-files-ahrf.html#unweighted-counts-1"><i class="fa fa-check"></i>Unweighted Counts</a></li>
<li class="chapter" data-level="" data-path="area-health-resources-files-ahrf.html"><a href="area-health-resources-files-ahrf.html#descriptive-statistics-1"><i class="fa fa-check"></i>Descriptive Statistics</a></li>
<li class="chapter" data-level="" data-path="area-health-resources-files-ahrf.html"><a href="area-health-resources-files-ahrf.html#subsetting-1"><i class="fa fa-check"></i>Subsetting</a></li>
<li class="chapter" data-level="" data-path="area-health-resources-files-ahrf.html"><a href="area-health-resources-files-ahrf.html#measures-of-uncertainty-1"><i class="fa fa-check"></i>Measures of Uncertainty</a></li>
<li class="chapter" data-level="" data-path="area-health-resources-files-ahrf.html"><a href="area-health-resources-files-ahrf.html#regression-models-and-tests-of-association-1"><i class="fa fa-check"></i>Regression Models and Tests of Association</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="area-health-resources-files-ahrf.html"><a href="area-health-resources-files-ahrf.html#replication-example-1"><i class="fa fa-check"></i>Replication Example</a></li>
<li class="chapter" data-level="" data-path="area-health-resources-files-ahrf.html"><a href="area-health-resources-files-ahrf.html#analysis-examples-with-dplyr"><i class="fa fa-check"></i>Analysis Examples with <code>dplyr</code>  </a></li>
<li class="chapter" data-level="" data-path="area-health-resources-files-ahrf.html"><a href="area-health-resources-files-ahrf.html#analysis-examples-with-data.table"><i class="fa fa-check"></i>Analysis Examples with <code>data.table</code>  </a></li>
<li class="chapter" data-level="" data-path="area-health-resources-files-ahrf.html"><a href="area-health-resources-files-ahrf.html#analysis-examples-with-duckdb"><i class="fa fa-check"></i>Analysis Examples with <code>duckdb</code>  </a></li>
</ul></li>
<li class="chapter" data-level="" data-path="american-housing-survey-ahs.html"><a href="american-housing-survey-ahs.html"><i class="fa fa-check"></i>American Housing Survey (AHS)</a>
<ul>
<li class="chapter" data-level="" data-path="american-housing-survey-ahs.html"><a href="american-housing-survey-ahs.html#download-import-preparation-3"><i class="fa fa-check"></i>Download, Import, Preparation</a>
<ul>
<li class="chapter" data-level="" data-path="american-housing-survey-ahs.html"><a href="american-housing-survey-ahs.html#save-locally-2"><i class="fa fa-check"></i>Save Locally  </a></li>
<li class="chapter" data-level="" data-path="american-housing-survey-ahs.html"><a href="american-housing-survey-ahs.html#survey-design-definition-1"><i class="fa fa-check"></i>Survey Design Definition</a></li>
<li class="chapter" data-level="" data-path="american-housing-survey-ahs.html"><a href="american-housing-survey-ahs.html#variable-recoding-2"><i class="fa fa-check"></i>Variable Recoding</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="american-housing-survey-ahs.html"><a href="american-housing-survey-ahs.html#analysis-examples-with-the-survey-library-1"><i class="fa fa-check"></i>Analysis Examples with the <code>survey</code> library  </a>
<ul>
<li class="chapter" data-level="" data-path="american-housing-survey-ahs.html"><a href="american-housing-survey-ahs.html#unweighted-counts-2"><i class="fa fa-check"></i>Unweighted Counts</a></li>
<li class="chapter" data-level="" data-path="american-housing-survey-ahs.html"><a href="american-housing-survey-ahs.html#weighted-counts-1"><i class="fa fa-check"></i>Weighted Counts</a></li>
<li class="chapter" data-level="" data-path="american-housing-survey-ahs.html"><a href="american-housing-survey-ahs.html#descriptive-statistics-2"><i class="fa fa-check"></i>Descriptive Statistics</a></li>
<li class="chapter" data-level="" data-path="american-housing-survey-ahs.html"><a href="american-housing-survey-ahs.html#subsetting-2"><i class="fa fa-check"></i>Subsetting</a></li>
<li class="chapter" data-level="" data-path="american-housing-survey-ahs.html"><a href="american-housing-survey-ahs.html#measures-of-uncertainty-2"><i class="fa fa-check"></i>Measures of Uncertainty</a></li>
<li class="chapter" data-level="" data-path="american-housing-survey-ahs.html"><a href="american-housing-survey-ahs.html#regression-models-and-tests-of-association-2"><i class="fa fa-check"></i>Regression Models and Tests of Association</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="american-housing-survey-ahs.html"><a href="american-housing-survey-ahs.html#replication-example-2"><i class="fa fa-check"></i>Replication Example</a></li>
<li class="chapter" data-level="" data-path="american-housing-survey-ahs.html"><a href="american-housing-survey-ahs.html#analysis-examples-with-srvyr-1"><i class="fa fa-check"></i>Analysis Examples with <code>srvyr</code>  </a></li>
</ul></li>
<li class="chapter" data-level="" data-path="american-national-election-studies-anes.html"><a href="american-national-election-studies-anes.html"><i class="fa fa-check"></i>American National Election Studies (ANES)</a>
<ul>
<li class="chapter" data-level="" data-path="american-national-election-studies-anes.html"><a href="american-national-election-studies-anes.html#function-definitions"><i class="fa fa-check"></i>Function Definitions</a></li>
<li class="chapter" data-level="" data-path="american-national-election-studies-anes.html"><a href="american-national-election-studies-anes.html#download-import-preparation-4"><i class="fa fa-check"></i>Download, Import, Preparation</a>
<ul>
<li class="chapter" data-level="" data-path="american-national-election-studies-anes.html"><a href="american-national-election-studies-anes.html#save-locally-3"><i class="fa fa-check"></i>Save Locally  </a></li>
<li class="chapter" data-level="" data-path="american-national-election-studies-anes.html"><a href="american-national-election-studies-anes.html#survey-design-definition-2"><i class="fa fa-check"></i>Survey Design Definition</a></li>
<li class="chapter" data-level="" data-path="american-national-election-studies-anes.html"><a href="american-national-election-studies-anes.html#variable-recoding-3"><i class="fa fa-check"></i>Variable Recoding</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="american-national-election-studies-anes.html"><a href="american-national-election-studies-anes.html#analysis-examples-with-the-survey-library-2"><i class="fa fa-check"></i>Analysis Examples with the <code>survey</code> library  </a>
<ul>
<li class="chapter" data-level="" data-path="american-national-election-studies-anes.html"><a href="american-national-election-studies-anes.html#unweighted-counts-3"><i class="fa fa-check"></i>Unweighted Counts</a></li>
<li class="chapter" data-level="" data-path="american-national-election-studies-anes.html"><a href="american-national-election-studies-anes.html#weighted-counts-2"><i class="fa fa-check"></i>Weighted Counts</a></li>
<li class="chapter" data-level="" data-path="american-national-election-studies-anes.html"><a href="american-national-election-studies-anes.html#descriptive-statistics-3"><i class="fa fa-check"></i>Descriptive Statistics</a></li>
<li class="chapter" data-level="" data-path="american-national-election-studies-anes.html"><a href="american-national-election-studies-anes.html#subsetting-3"><i class="fa fa-check"></i>Subsetting</a></li>
<li class="chapter" data-level="" data-path="american-national-election-studies-anes.html"><a href="american-national-election-studies-anes.html#measures-of-uncertainty-3"><i class="fa fa-check"></i>Measures of Uncertainty</a></li>
<li class="chapter" data-level="" data-path="american-national-election-studies-anes.html"><a href="american-national-election-studies-anes.html#regression-models-and-tests-of-association-3"><i class="fa fa-check"></i>Regression Models and Tests of Association</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="american-national-election-studies-anes.html"><a href="american-national-election-studies-anes.html#replication-example-3"><i class="fa fa-check"></i>Replication Example</a></li>
<li class="chapter" data-level="" data-path="american-national-election-studies-anes.html"><a href="american-national-election-studies-anes.html#analysis-examples-with-srvyr-2"><i class="fa fa-check"></i>Analysis Examples with <code>srvyr</code>  </a></li>
</ul></li>
<li class="chapter" data-level="" data-path="american-time-use-survey-atus.html"><a href="american-time-use-survey-atus.html"><i class="fa fa-check"></i>American Time Use Survey (ATUS)</a>
<ul>
<li class="chapter" data-level="" data-path="american-time-use-survey-atus.html"><a href="american-time-use-survey-atus.html#function-definitions-1"><i class="fa fa-check"></i>Function Definitions</a></li>
<li class="chapter" data-level="" data-path="american-time-use-survey-atus.html"><a href="american-time-use-survey-atus.html#download-import-preparation-5"><i class="fa fa-check"></i>Download, Import, Preparation</a>
<ul>
<li class="chapter" data-level="" data-path="american-time-use-survey-atus.html"><a href="american-time-use-survey-atus.html#save-locally-4"><i class="fa fa-check"></i>Save Locally  </a></li>
<li class="chapter" data-level="" data-path="american-time-use-survey-atus.html"><a href="american-time-use-survey-atus.html#survey-design-definition-3"><i class="fa fa-check"></i>Survey Design Definition</a></li>
<li class="chapter" data-level="" data-path="american-time-use-survey-atus.html"><a href="american-time-use-survey-atus.html#variable-recoding-4"><i class="fa fa-check"></i>Variable Recoding</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="american-time-use-survey-atus.html"><a href="american-time-use-survey-atus.html#analysis-examples-with-the-survey-library-3"><i class="fa fa-check"></i>Analysis Examples with the <code>survey</code> library  </a>
<ul>
<li class="chapter" data-level="" data-path="american-time-use-survey-atus.html"><a href="american-time-use-survey-atus.html#unweighted-counts-4"><i class="fa fa-check"></i>Unweighted Counts</a></li>
<li class="chapter" data-level="" data-path="american-time-use-survey-atus.html"><a href="american-time-use-survey-atus.html#weighted-counts-3"><i class="fa fa-check"></i>Weighted Counts</a></li>
<li class="chapter" data-level="" data-path="american-time-use-survey-atus.html"><a href="american-time-use-survey-atus.html#descriptive-statistics-4"><i class="fa fa-check"></i>Descriptive Statistics</a></li>
<li class="chapter" data-level="" data-path="american-time-use-survey-atus.html"><a href="american-time-use-survey-atus.html#subsetting-4"><i class="fa fa-check"></i>Subsetting</a></li>
<li class="chapter" data-level="" data-path="american-time-use-survey-atus.html"><a href="american-time-use-survey-atus.html#measures-of-uncertainty-4"><i class="fa fa-check"></i>Measures of Uncertainty</a></li>
<li class="chapter" data-level="" data-path="american-time-use-survey-atus.html"><a href="american-time-use-survey-atus.html#regression-models-and-tests-of-association-4"><i class="fa fa-check"></i>Regression Models and Tests of Association</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="american-time-use-survey-atus.html"><a href="american-time-use-survey-atus.html#replication-example-4"><i class="fa fa-check"></i>Replication Example</a></li>
<li class="chapter" data-level="" data-path="american-time-use-survey-atus.html"><a href="american-time-use-survey-atus.html#analysis-examples-with-srvyr-3"><i class="fa fa-check"></i>Analysis Examples with <code>srvyr</code>  </a></li>
</ul></li>
<li class="chapter" data-level="" data-path="behavioral-risk-factor-surveillance-system-brfss.html"><a href="behavioral-risk-factor-surveillance-system-brfss.html"><i class="fa fa-check"></i>Behavioral Risk Factor Surveillance System (BRFSS)</a>
<ul>
<li class="chapter" data-level="" data-path="behavioral-risk-factor-surveillance-system-brfss.html"><a href="behavioral-risk-factor-surveillance-system-brfss.html#download-import-preparation-6"><i class="fa fa-check"></i>Download, Import, Preparation</a>
<ul>
<li class="chapter" data-level="" data-path="behavioral-risk-factor-surveillance-system-brfss.html"><a href="behavioral-risk-factor-surveillance-system-brfss.html#save-locally-5"><i class="fa fa-check"></i>Save Locally  </a></li>
<li class="chapter" data-level="" data-path="behavioral-risk-factor-surveillance-system-brfss.html"><a href="behavioral-risk-factor-surveillance-system-brfss.html#survey-design-definition-4"><i class="fa fa-check"></i>Survey Design Definition</a></li>
<li class="chapter" data-level="" data-path="behavioral-risk-factor-surveillance-system-brfss.html"><a href="behavioral-risk-factor-surveillance-system-brfss.html#variable-recoding-5"><i class="fa fa-check"></i>Variable Recoding</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="behavioral-risk-factor-surveillance-system-brfss.html"><a href="behavioral-risk-factor-surveillance-system-brfss.html#analysis-examples-with-the-survey-library-4"><i class="fa fa-check"></i>Analysis Examples with the <code>survey</code> library  </a>
<ul>
<li class="chapter" data-level="" data-path="behavioral-risk-factor-surveillance-system-brfss.html"><a href="behavioral-risk-factor-surveillance-system-brfss.html#unweighted-counts-5"><i class="fa fa-check"></i>Unweighted Counts</a></li>
<li class="chapter" data-level="" data-path="behavioral-risk-factor-surveillance-system-brfss.html"><a href="behavioral-risk-factor-surveillance-system-brfss.html#weighted-counts-4"><i class="fa fa-check"></i>Weighted Counts</a></li>
<li class="chapter" data-level="" data-path="behavioral-risk-factor-surveillance-system-brfss.html"><a href="behavioral-risk-factor-surveillance-system-brfss.html#descriptive-statistics-5"><i class="fa fa-check"></i>Descriptive Statistics</a></li>
<li class="chapter" data-level="" data-path="behavioral-risk-factor-surveillance-system-brfss.html"><a href="behavioral-risk-factor-surveillance-system-brfss.html#subsetting-5"><i class="fa fa-check"></i>Subsetting</a></li>
<li class="chapter" data-level="" data-path="behavioral-risk-factor-surveillance-system-brfss.html"><a href="behavioral-risk-factor-surveillance-system-brfss.html#measures-of-uncertainty-5"><i class="fa fa-check"></i>Measures of Uncertainty</a></li>
<li class="chapter" data-level="" data-path="behavioral-risk-factor-surveillance-system-brfss.html"><a href="behavioral-risk-factor-surveillance-system-brfss.html#regression-models-and-tests-of-association-5"><i class="fa fa-check"></i>Regression Models and Tests of Association</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="behavioral-risk-factor-surveillance-system-brfss.html"><a href="behavioral-risk-factor-surveillance-system-brfss.html#replication-example-5"><i class="fa fa-check"></i>Replication Example</a></li>
<li class="chapter" data-level="" data-path="behavioral-risk-factor-surveillance-system-brfss.html"><a href="behavioral-risk-factor-surveillance-system-brfss.html#analysis-examples-with-srvyr-4"><i class="fa fa-check"></i>Analysis Examples with <code>srvyr</code>  </a></li>
</ul></li>
<li class="chapter" data-level="" data-path="consumer-expenditure-survey-ces.html"><a href="consumer-expenditure-survey-ces.html"><i class="fa fa-check"></i>Consumer Expenditure Survey (CES)</a>
<ul>
<li class="chapter" data-level="" data-path="consumer-expenditure-survey-ces.html"><a href="consumer-expenditure-survey-ces.html#download-import-preparation-7"><i class="fa fa-check"></i>Download, Import, Preparation</a>
<ul>
<li class="chapter" data-level="" data-path="consumer-expenditure-survey-ces.html"><a href="consumer-expenditure-survey-ces.html#save-locally-6"><i class="fa fa-check"></i>Save Locally  </a></li>
<li class="chapter" data-level="" data-path="consumer-expenditure-survey-ces.html"><a href="consumer-expenditure-survey-ces.html#survey-design-definition-5"><i class="fa fa-check"></i>Survey Design Definition</a></li>
<li class="chapter" data-level="" data-path="consumer-expenditure-survey-ces.html"><a href="consumer-expenditure-survey-ces.html#variable-recoding-6"><i class="fa fa-check"></i>Variable Recoding</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="consumer-expenditure-survey-ces.html"><a href="consumer-expenditure-survey-ces.html#analysis-examples-with-the-survey-library-5"><i class="fa fa-check"></i>Analysis Examples with the <code>survey</code> library  </a>
<ul>
<li class="chapter" data-level="" data-path="consumer-expenditure-survey-ces.html"><a href="consumer-expenditure-survey-ces.html#unweighted-counts-6"><i class="fa fa-check"></i>Unweighted Counts</a></li>
<li class="chapter" data-level="" data-path="consumer-expenditure-survey-ces.html"><a href="consumer-expenditure-survey-ces.html#weighted-counts-5"><i class="fa fa-check"></i>Weighted Counts</a></li>
<li class="chapter" data-level="" data-path="consumer-expenditure-survey-ces.html"><a href="consumer-expenditure-survey-ces.html#descriptive-statistics-6"><i class="fa fa-check"></i>Descriptive Statistics</a></li>
<li class="chapter" data-level="" data-path="consumer-expenditure-survey-ces.html"><a href="consumer-expenditure-survey-ces.html#subsetting-6"><i class="fa fa-check"></i>Subsetting</a></li>
<li class="chapter" data-level="" data-path="consumer-expenditure-survey-ces.html"><a href="consumer-expenditure-survey-ces.html#measures-of-uncertainty-6"><i class="fa fa-check"></i>Measures of Uncertainty</a></li>
<li class="chapter" data-level="" data-path="consumer-expenditure-survey-ces.html"><a href="consumer-expenditure-survey-ces.html#regression-models-and-tests-of-association-6"><i class="fa fa-check"></i>Regression Models and Tests of Association</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="consumer-expenditure-survey-ces.html"><a href="consumer-expenditure-survey-ces.html#replication-example-6"><i class="fa fa-check"></i>Replication Example</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="california-health-interview-survey-chis.html"><a href="california-health-interview-survey-chis.html"><i class="fa fa-check"></i>California Health Interview Survey (CHIS)</a>
<ul>
<li class="chapter" data-level="" data-path="california-health-interview-survey-chis.html"><a href="california-health-interview-survey-chis.html#function-definitions-2"><i class="fa fa-check"></i>Function Definitions</a></li>
<li class="chapter" data-level="" data-path="california-health-interview-survey-chis.html"><a href="california-health-interview-survey-chis.html#download-import-preparation-8"><i class="fa fa-check"></i>Download, Import, Preparation</a>
<ul>
<li class="chapter" data-level="" data-path="california-health-interview-survey-chis.html"><a href="california-health-interview-survey-chis.html#save-locally-7"><i class="fa fa-check"></i>Save Locally  </a></li>
<li class="chapter" data-level="" data-path="california-health-interview-survey-chis.html"><a href="california-health-interview-survey-chis.html#survey-design-definition-6"><i class="fa fa-check"></i>Survey Design Definition</a></li>
<li class="chapter" data-level="" data-path="california-health-interview-survey-chis.html"><a href="california-health-interview-survey-chis.html#variable-recoding-7"><i class="fa fa-check"></i>Variable Recoding</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="california-health-interview-survey-chis.html"><a href="california-health-interview-survey-chis.html#analysis-examples-with-the-survey-library-6"><i class="fa fa-check"></i>Analysis Examples with the <code>survey</code> library  </a>
<ul>
<li class="chapter" data-level="" data-path="california-health-interview-survey-chis.html"><a href="california-health-interview-survey-chis.html#unweighted-counts-7"><i class="fa fa-check"></i>Unweighted Counts</a></li>
<li class="chapter" data-level="" data-path="california-health-interview-survey-chis.html"><a href="california-health-interview-survey-chis.html#weighted-counts-6"><i class="fa fa-check"></i>Weighted Counts</a></li>
<li class="chapter" data-level="" data-path="california-health-interview-survey-chis.html"><a href="california-health-interview-survey-chis.html#descriptive-statistics-7"><i class="fa fa-check"></i>Descriptive Statistics</a></li>
<li class="chapter" data-level="" data-path="california-health-interview-survey-chis.html"><a href="california-health-interview-survey-chis.html#subsetting-7"><i class="fa fa-check"></i>Subsetting</a></li>
<li class="chapter" data-level="" data-path="california-health-interview-survey-chis.html"><a href="california-health-interview-survey-chis.html#measures-of-uncertainty-7"><i class="fa fa-check"></i>Measures of Uncertainty</a></li>
<li class="chapter" data-level="" data-path="california-health-interview-survey-chis.html"><a href="california-health-interview-survey-chis.html#regression-models-and-tests-of-association-7"><i class="fa fa-check"></i>Regression Models and Tests of Association</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="california-health-interview-survey-chis.html"><a href="california-health-interview-survey-chis.html#replication-example-7"><i class="fa fa-check"></i>Replication Example</a></li>
<li class="chapter" data-level="" data-path="california-health-interview-survey-chis.html"><a href="california-health-interview-survey-chis.html#analysis-examples-with-srvyr-5"><i class="fa fa-check"></i>Analysis Examples with <code>srvyr</code>  </a></li>
</ul></li>
<li class="chapter" data-level="" data-path="census-of-governments-cog.html"><a href="census-of-governments-cog.html"><i class="fa fa-check"></i>Census of Governments (COG)</a>
<ul>
<li class="chapter" data-level="" data-path="census-of-governments-cog.html"><a href="census-of-governments-cog.html#download-import-preparation-9"><i class="fa fa-check"></i>Download, Import, Preparation</a>
<ul>
<li class="chapter" data-level="" data-path="census-of-governments-cog.html"><a href="census-of-governments-cog.html#save-locally-8"><i class="fa fa-check"></i>Save Locally  </a></li>
<li class="chapter" data-level="" data-path="census-of-governments-cog.html"><a href="census-of-governments-cog.html#variable-recoding-8"><i class="fa fa-check"></i>Variable Recoding</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="census-of-governments-cog.html"><a href="census-of-governments-cog.html#analysis-examples-with-base-r-1"><i class="fa fa-check"></i>Analysis Examples with base R  </a>
<ul>
<li class="chapter" data-level="" data-path="census-of-governments-cog.html"><a href="census-of-governments-cog.html#unweighted-counts-8"><i class="fa fa-check"></i>Unweighted Counts</a></li>
<li class="chapter" data-level="" data-path="census-of-governments-cog.html"><a href="census-of-governments-cog.html#descriptive-statistics-8"><i class="fa fa-check"></i>Descriptive Statistics</a></li>
<li class="chapter" data-level="" data-path="census-of-governments-cog.html"><a href="census-of-governments-cog.html#subsetting-8"><i class="fa fa-check"></i>Subsetting</a></li>
<li class="chapter" data-level="" data-path="census-of-governments-cog.html"><a href="census-of-governments-cog.html#measures-of-uncertainty-8"><i class="fa fa-check"></i>Measures of Uncertainty</a></li>
<li class="chapter" data-level="" data-path="census-of-governments-cog.html"><a href="census-of-governments-cog.html#regression-models-and-tests-of-association-8"><i class="fa fa-check"></i>Regression Models and Tests of Association</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="census-of-governments-cog.html"><a href="census-of-governments-cog.html#replication-example-8"><i class="fa fa-check"></i>Replication Example</a></li>
<li class="chapter" data-level="" data-path="census-of-governments-cog.html"><a href="census-of-governments-cog.html#analysis-examples-with-dplyr-1"><i class="fa fa-check"></i>Analysis Examples with <code>dplyr</code>  </a></li>
<li class="chapter" data-level="" data-path="census-of-governments-cog.html"><a href="census-of-governments-cog.html#analysis-examples-with-data.table-1"><i class="fa fa-check"></i>Analysis Examples with <code>data.table</code>  </a></li>
<li class="chapter" data-level="" data-path="census-of-governments-cog.html"><a href="census-of-governments-cog.html#analysis-examples-with-duckdb-1"><i class="fa fa-check"></i>Analysis Examples with <code>duckdb</code>  </a></li>
</ul></li>
<li class="chapter" data-level="" data-path="current-population-survey-cps.html"><a href="current-population-survey-cps.html"><i class="fa fa-check"></i>Current Population Survey (CPS)</a>
<ul>
<li class="chapter" data-level="" data-path="current-population-survey-cps.html"><a href="current-population-survey-cps.html#download-import-preparation-10"><i class="fa fa-check"></i>Download, Import, Preparation</a>
<ul>
<li class="chapter" data-level="" data-path="current-population-survey-cps.html"><a href="current-population-survey-cps.html#save-locally-9"><i class="fa fa-check"></i>Save Locally  </a></li>
<li class="chapter" data-level="" data-path="current-population-survey-cps.html"><a href="current-population-survey-cps.html#survey-design-definition-7"><i class="fa fa-check"></i>Survey Design Definition</a></li>
<li class="chapter" data-level="" data-path="current-population-survey-cps.html"><a href="current-population-survey-cps.html#variable-recoding-9"><i class="fa fa-check"></i>Variable Recoding</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="current-population-survey-cps.html"><a href="current-population-survey-cps.html#analysis-examples-with-the-survey-library-7"><i class="fa fa-check"></i>Analysis Examples with the <code>survey</code> library  </a>
<ul>
<li class="chapter" data-level="" data-path="current-population-survey-cps.html"><a href="current-population-survey-cps.html#unweighted-counts-9"><i class="fa fa-check"></i>Unweighted Counts</a></li>
<li class="chapter" data-level="" data-path="current-population-survey-cps.html"><a href="current-population-survey-cps.html#weighted-counts-7"><i class="fa fa-check"></i>Weighted Counts</a></li>
<li class="chapter" data-level="" data-path="current-population-survey-cps.html"><a href="current-population-survey-cps.html#descriptive-statistics-9"><i class="fa fa-check"></i>Descriptive Statistics</a></li>
<li class="chapter" data-level="" data-path="current-population-survey-cps.html"><a href="current-population-survey-cps.html#subsetting-9"><i class="fa fa-check"></i>Subsetting</a></li>
<li class="chapter" data-level="" data-path="current-population-survey-cps.html"><a href="current-population-survey-cps.html#measures-of-uncertainty-9"><i class="fa fa-check"></i>Measures of Uncertainty</a></li>
<li class="chapter" data-level="" data-path="current-population-survey-cps.html"><a href="current-population-survey-cps.html#regression-models-and-tests-of-association-9"><i class="fa fa-check"></i>Regression Models and Tests of Association</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="current-population-survey-cps.html"><a href="current-population-survey-cps.html#replication-example-9"><i class="fa fa-check"></i>Replication Example</a></li>
<li class="chapter" data-level="" data-path="current-population-survey-cps.html"><a href="current-population-survey-cps.html#poverty-and-inequality-estimation-with-convey-1"><i class="fa fa-check"></i>Poverty and Inequality Estimation with <code>convey</code>  </a></li>
<li class="chapter" data-level="" data-path="current-population-survey-cps.html"><a href="current-population-survey-cps.html#analysis-examples-with-srvyr-6"><i class="fa fa-check"></i>Analysis Examples with <code>srvyr</code>  </a></li>
</ul></li>
<li class="chapter" data-level="" data-path="exame-nacional-de-desempenho-de-estudantes-enade.html"><a href="exame-nacional-de-desempenho-de-estudantes-enade.html"><i class="fa fa-check"></i>Exame Nacional de Desempenho de Estudantes (ENADE)</a>
<ul>
<li class="chapter" data-level="" data-path="exame-nacional-de-desempenho-de-estudantes-enade.html"><a href="exame-nacional-de-desempenho-de-estudantes-enade.html#download-import-preparation-11"><i class="fa fa-check"></i>Download, Import, Preparation</a>
<ul>
<li class="chapter" data-level="" data-path="exame-nacional-de-desempenho-de-estudantes-enade.html"><a href="exame-nacional-de-desempenho-de-estudantes-enade.html#save-locally-10"><i class="fa fa-check"></i>Save Locally  </a></li>
<li class="chapter" data-level="" data-path="exame-nacional-de-desempenho-de-estudantes-enade.html"><a href="exame-nacional-de-desempenho-de-estudantes-enade.html#variable-recoding-10"><i class="fa fa-check"></i>Variable Recoding</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="exame-nacional-de-desempenho-de-estudantes-enade.html"><a href="exame-nacional-de-desempenho-de-estudantes-enade.html#analysis-examples-with-base-r-2"><i class="fa fa-check"></i>Analysis Examples with base R  </a>
<ul>
<li class="chapter" data-level="" data-path="exame-nacional-de-desempenho-de-estudantes-enade.html"><a href="exame-nacional-de-desempenho-de-estudantes-enade.html#unweighted-counts-10"><i class="fa fa-check"></i>Unweighted Counts</a></li>
<li class="chapter" data-level="" data-path="exame-nacional-de-desempenho-de-estudantes-enade.html"><a href="exame-nacional-de-desempenho-de-estudantes-enade.html#descriptive-statistics-10"><i class="fa fa-check"></i>Descriptive Statistics</a></li>
<li class="chapter" data-level="" data-path="exame-nacional-de-desempenho-de-estudantes-enade.html"><a href="exame-nacional-de-desempenho-de-estudantes-enade.html#subsetting-10"><i class="fa fa-check"></i>Subsetting</a></li>
<li class="chapter" data-level="" data-path="exame-nacional-de-desempenho-de-estudantes-enade.html"><a href="exame-nacional-de-desempenho-de-estudantes-enade.html#measures-of-uncertainty-10"><i class="fa fa-check"></i>Measures of Uncertainty</a></li>
<li class="chapter" data-level="" data-path="exame-nacional-de-desempenho-de-estudantes-enade.html"><a href="exame-nacional-de-desempenho-de-estudantes-enade.html#regression-models-and-tests-of-association-10"><i class="fa fa-check"></i>Regression Models and Tests of Association</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="exame-nacional-de-desempenho-de-estudantes-enade.html"><a href="exame-nacional-de-desempenho-de-estudantes-enade.html#replication-example-10"><i class="fa fa-check"></i>Replication Example</a></li>
<li class="chapter" data-level="" data-path="exame-nacional-de-desempenho-de-estudantes-enade.html"><a href="exame-nacional-de-desempenho-de-estudantes-enade.html#analysis-examples-with-dplyr-2"><i class="fa fa-check"></i>Analysis Examples with <code>dplyr</code>  </a></li>
<li class="chapter" data-level="" data-path="exame-nacional-de-desempenho-de-estudantes-enade.html"><a href="exame-nacional-de-desempenho-de-estudantes-enade.html#analysis-examples-with-data.table-2"><i class="fa fa-check"></i>Analysis Examples with <code>data.table</code>  </a></li>
<li class="chapter" data-level="" data-path="exame-nacional-de-desempenho-de-estudantes-enade.html"><a href="exame-nacional-de-desempenho-de-estudantes-enade.html#analysis-examples-with-duckdb-2"><i class="fa fa-check"></i>Analysis Examples with <code>duckdb</code>  </a></li>
</ul></li>
<li class="chapter" data-level="" data-path="exame-nacional-do-ensino-medio-enem.html"><a href="exame-nacional-do-ensino-medio-enem.html"><i class="fa fa-check"></i>Exame Nacional do Ensino Medio (ENEM)</a>
<ul>
<li class="chapter" data-level="" data-path="exame-nacional-do-ensino-medio-enem.html"><a href="exame-nacional-do-ensino-medio-enem.html#download-import-preparation-12"><i class="fa fa-check"></i>Download, Import, Preparation</a>
<ul>
<li class="chapter" data-level="" data-path="exame-nacional-do-ensino-medio-enem.html"><a href="exame-nacional-do-ensino-medio-enem.html#save-locally-11"><i class="fa fa-check"></i>Save Locally  </a></li>
<li class="chapter" data-level="" data-path="exame-nacional-do-ensino-medio-enem.html"><a href="exame-nacional-do-ensino-medio-enem.html#variable-recoding-11"><i class="fa fa-check"></i>Variable Recoding</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="exame-nacional-do-ensino-medio-enem.html"><a href="exame-nacional-do-ensino-medio-enem.html#analysis-examples-with-base-r-3"><i class="fa fa-check"></i>Analysis Examples with base R  </a>
<ul>
<li class="chapter" data-level="" data-path="exame-nacional-do-ensino-medio-enem.html"><a href="exame-nacional-do-ensino-medio-enem.html#unweighted-counts-11"><i class="fa fa-check"></i>Unweighted Counts</a></li>
<li class="chapter" data-level="" data-path="exame-nacional-do-ensino-medio-enem.html"><a href="exame-nacional-do-ensino-medio-enem.html#descriptive-statistics-11"><i class="fa fa-check"></i>Descriptive Statistics</a></li>
<li class="chapter" data-level="" data-path="exame-nacional-do-ensino-medio-enem.html"><a href="exame-nacional-do-ensino-medio-enem.html#subsetting-11"><i class="fa fa-check"></i>Subsetting</a></li>
<li class="chapter" data-level="" data-path="exame-nacional-do-ensino-medio-enem.html"><a href="exame-nacional-do-ensino-medio-enem.html#measures-of-uncertainty-11"><i class="fa fa-check"></i>Measures of Uncertainty</a></li>
<li class="chapter" data-level="" data-path="exame-nacional-do-ensino-medio-enem.html"><a href="exame-nacional-do-ensino-medio-enem.html#regression-models-and-tests-of-association-11"><i class="fa fa-check"></i>Regression Models and Tests of Association</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="exame-nacional-do-ensino-medio-enem.html"><a href="exame-nacional-do-ensino-medio-enem.html#replication-example-11"><i class="fa fa-check"></i>Replication Example</a></li>
<li class="chapter" data-level="" data-path="exame-nacional-do-ensino-medio-enem.html"><a href="exame-nacional-do-ensino-medio-enem.html#analysis-examples-with-dplyr-3"><i class="fa fa-check"></i>Analysis Examples with <code>dplyr</code>  </a></li>
<li class="chapter" data-level="" data-path="exame-nacional-do-ensino-medio-enem.html"><a href="exame-nacional-do-ensino-medio-enem.html#analysis-examples-with-data.table-3"><i class="fa fa-check"></i>Analysis Examples with <code>data.table</code>  </a></li>
<li class="chapter" data-level="" data-path="exame-nacional-do-ensino-medio-enem.html"><a href="exame-nacional-do-ensino-medio-enem.html#analysis-examples-with-duckdb-3"><i class="fa fa-check"></i>Analysis Examples with <code>duckdb</code>  </a></li>
</ul></li>
<li class="chapter" data-level="" data-path="european-social-survey-ess.html"><a href="european-social-survey-ess.html"><i class="fa fa-check"></i>European Social Survey (ESS)</a>
<ul>
<li class="chapter" data-level="" data-path="european-social-survey-ess.html"><a href="european-social-survey-ess.html#download-import-preparation-13"><i class="fa fa-check"></i>Download, Import, Preparation</a>
<ul>
<li class="chapter" data-level="" data-path="european-social-survey-ess.html"><a href="european-social-survey-ess.html#save-locally-12"><i class="fa fa-check"></i>Save Locally  </a></li>
<li class="chapter" data-level="" data-path="european-social-survey-ess.html"><a href="european-social-survey-ess.html#survey-design-definition-8"><i class="fa fa-check"></i>Survey Design Definition</a></li>
<li class="chapter" data-level="" data-path="european-social-survey-ess.html"><a href="european-social-survey-ess.html#variable-recoding-12"><i class="fa fa-check"></i>Variable Recoding</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="european-social-survey-ess.html"><a href="european-social-survey-ess.html#analysis-examples-with-the-survey-library-8"><i class="fa fa-check"></i>Analysis Examples with the <code>survey</code> library  </a>
<ul>
<li class="chapter" data-level="" data-path="european-social-survey-ess.html"><a href="european-social-survey-ess.html#unweighted-counts-12"><i class="fa fa-check"></i>Unweighted Counts</a></li>
<li class="chapter" data-level="" data-path="european-social-survey-ess.html"><a href="european-social-survey-ess.html#weighted-counts-8"><i class="fa fa-check"></i>Weighted Counts</a></li>
<li class="chapter" data-level="" data-path="european-social-survey-ess.html"><a href="european-social-survey-ess.html#descriptive-statistics-12"><i class="fa fa-check"></i>Descriptive Statistics</a></li>
<li class="chapter" data-level="" data-path="european-social-survey-ess.html"><a href="european-social-survey-ess.html#subsetting-12"><i class="fa fa-check"></i>Subsetting</a></li>
<li class="chapter" data-level="" data-path="european-social-survey-ess.html"><a href="european-social-survey-ess.html#measures-of-uncertainty-12"><i class="fa fa-check"></i>Measures of Uncertainty</a></li>
<li class="chapter" data-level="" data-path="european-social-survey-ess.html"><a href="european-social-survey-ess.html#regression-models-and-tests-of-association-12"><i class="fa fa-check"></i>Regression Models and Tests of Association</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="european-social-survey-ess.html"><a href="european-social-survey-ess.html#replication-example-12"><i class="fa fa-check"></i>Replication Example</a></li>
<li class="chapter" data-level="" data-path="european-social-survey-ess.html"><a href="european-social-survey-ess.html#analysis-examples-with-srvyr-7"><i class="fa fa-check"></i>Analysis Examples with <code>srvyr</code>  </a></li>
</ul></li>
<li class="chapter" data-level="" data-path="fda-adverse-event-reporting-system-faers.html"><a href="fda-adverse-event-reporting-system-faers.html"><i class="fa fa-check"></i>FDA Adverse Event Reporting System (FAERS)</a>
<ul>
<li class="chapter" data-level="" data-path="fda-adverse-event-reporting-system-faers.html"><a href="fda-adverse-event-reporting-system-faers.html#function-definitions-3"><i class="fa fa-check"></i>Function Definitions</a></li>
<li class="chapter" data-level="" data-path="fda-adverse-event-reporting-system-faers.html"><a href="fda-adverse-event-reporting-system-faers.html#download-import-preparation-14"><i class="fa fa-check"></i>Download, Import, Preparation</a>
<ul>
<li class="chapter" data-level="" data-path="fda-adverse-event-reporting-system-faers.html"><a href="fda-adverse-event-reporting-system-faers.html#save-locally-13"><i class="fa fa-check"></i>Save Locally  </a></li>
<li class="chapter" data-level="" data-path="fda-adverse-event-reporting-system-faers.html"><a href="fda-adverse-event-reporting-system-faers.html#variable-recoding-13"><i class="fa fa-check"></i>Variable Recoding</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="fda-adverse-event-reporting-system-faers.html"><a href="fda-adverse-event-reporting-system-faers.html#analysis-examples-with-base-r-4"><i class="fa fa-check"></i>Analysis Examples with base R  </a>
<ul>
<li class="chapter" data-level="" data-path="fda-adverse-event-reporting-system-faers.html"><a href="fda-adverse-event-reporting-system-faers.html#unweighted-counts-13"><i class="fa fa-check"></i>Unweighted Counts</a></li>
<li class="chapter" data-level="" data-path="fda-adverse-event-reporting-system-faers.html"><a href="fda-adverse-event-reporting-system-faers.html#descriptive-statistics-13"><i class="fa fa-check"></i>Descriptive Statistics</a></li>
<li class="chapter" data-level="" data-path="fda-adverse-event-reporting-system-faers.html"><a href="fda-adverse-event-reporting-system-faers.html#subsetting-13"><i class="fa fa-check"></i>Subsetting</a></li>
<li class="chapter" data-level="" data-path="fda-adverse-event-reporting-system-faers.html"><a href="fda-adverse-event-reporting-system-faers.html#measures-of-uncertainty-13"><i class="fa fa-check"></i>Measures of Uncertainty</a></li>
<li class="chapter" data-level="" data-path="fda-adverse-event-reporting-system-faers.html"><a href="fda-adverse-event-reporting-system-faers.html#regression-models-and-tests-of-association-13"><i class="fa fa-check"></i>Regression Models and Tests of Association</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="fda-adverse-event-reporting-system-faers.html"><a href="fda-adverse-event-reporting-system-faers.html#replication-example-13"><i class="fa fa-check"></i>Replication Example</a></li>
<li class="chapter" data-level="" data-path="fda-adverse-event-reporting-system-faers.html"><a href="fda-adverse-event-reporting-system-faers.html#analysis-examples-with-dplyr-4"><i class="fa fa-check"></i>Analysis Examples with <code>dplyr</code>  </a></li>
<li class="chapter" data-level="" data-path="fda-adverse-event-reporting-system-faers.html"><a href="fda-adverse-event-reporting-system-faers.html#analysis-examples-with-data.table-4"><i class="fa fa-check"></i>Analysis Examples with <code>data.table</code>  </a></li>
<li class="chapter" data-level="" data-path="fda-adverse-event-reporting-system-faers.html"><a href="fda-adverse-event-reporting-system-faers.html#analysis-examples-with-duckdb-4"><i class="fa fa-check"></i>Analysis Examples with <code>duckdb</code>  </a></li>
</ul></li>
<li class="chapter" data-level="" data-path="general-social-survey-gss.html"><a href="general-social-survey-gss.html"><i class="fa fa-check"></i>General Social Survey (GSS)</a>
<ul>
<li class="chapter" data-level="" data-path="general-social-survey-gss.html"><a href="general-social-survey-gss.html#download-import-preparation-15"><i class="fa fa-check"></i>Download, Import, Preparation</a>
<ul>
<li class="chapter" data-level="" data-path="general-social-survey-gss.html"><a href="general-social-survey-gss.html#save-locally-14"><i class="fa fa-check"></i>Save Locally  </a></li>
<li class="chapter" data-level="" data-path="general-social-survey-gss.html"><a href="general-social-survey-gss.html#survey-design-definition-9"><i class="fa fa-check"></i>Survey Design Definition</a></li>
<li class="chapter" data-level="" data-path="general-social-survey-gss.html"><a href="general-social-survey-gss.html#variable-recoding-14"><i class="fa fa-check"></i>Variable Recoding</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="general-social-survey-gss.html"><a href="general-social-survey-gss.html#analysis-examples-with-the-survey-library-9"><i class="fa fa-check"></i>Analysis Examples with the <code>survey</code> library  </a>
<ul>
<li class="chapter" data-level="" data-path="general-social-survey-gss.html"><a href="general-social-survey-gss.html#unweighted-counts-14"><i class="fa fa-check"></i>Unweighted Counts</a></li>
<li class="chapter" data-level="" data-path="general-social-survey-gss.html"><a href="general-social-survey-gss.html#weighted-counts-9"><i class="fa fa-check"></i>Weighted Counts</a></li>
<li class="chapter" data-level="" data-path="general-social-survey-gss.html"><a href="general-social-survey-gss.html#descriptive-statistics-14"><i class="fa fa-check"></i>Descriptive Statistics</a></li>
<li class="chapter" data-level="" data-path="general-social-survey-gss.html"><a href="general-social-survey-gss.html#subsetting-14"><i class="fa fa-check"></i>Subsetting</a></li>
<li class="chapter" data-level="" data-path="general-social-survey-gss.html"><a href="general-social-survey-gss.html#measures-of-uncertainty-14"><i class="fa fa-check"></i>Measures of Uncertainty</a></li>
<li class="chapter" data-level="" data-path="general-social-survey-gss.html"><a href="general-social-survey-gss.html#regression-models-and-tests-of-association-14"><i class="fa fa-check"></i>Regression Models and Tests of Association</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="general-social-survey-gss.html"><a href="general-social-survey-gss.html#replication-example-14"><i class="fa fa-check"></i>Replication Example</a></li>
<li class="chapter" data-level="" data-path="general-social-survey-gss.html"><a href="general-social-survey-gss.html#analysis-examples-with-srvyr-8"><i class="fa fa-check"></i>Analysis Examples with <code>srvyr</code>  </a></li>
</ul></li>
<li class="chapter" data-level="" data-path="health-and-retirement-study-hrs.html"><a href="health-and-retirement-study-hrs.html"><i class="fa fa-check"></i>Health and Retirement Study (HRS)</a>
<ul>
<li class="chapter" data-level="" data-path="health-and-retirement-study-hrs.html"><a href="health-and-retirement-study-hrs.html#download-import-preparation-16"><i class="fa fa-check"></i>Download, Import, Preparation</a>
<ul>
<li class="chapter" data-level="" data-path="health-and-retirement-study-hrs.html"><a href="health-and-retirement-study-hrs.html#save-locally-15"><i class="fa fa-check"></i>Save Locally  </a></li>
<li class="chapter" data-level="" data-path="health-and-retirement-study-hrs.html"><a href="health-and-retirement-study-hrs.html#survey-design-definition-10"><i class="fa fa-check"></i>Survey Design Definition</a></li>
<li class="chapter" data-level="" data-path="health-and-retirement-study-hrs.html"><a href="health-and-retirement-study-hrs.html#variable-recoding-15"><i class="fa fa-check"></i>Variable Recoding</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="health-and-retirement-study-hrs.html"><a href="health-and-retirement-study-hrs.html#analysis-examples-with-the-survey-library-10"><i class="fa fa-check"></i>Analysis Examples with the <code>survey</code> library  </a>
<ul>
<li class="chapter" data-level="" data-path="health-and-retirement-study-hrs.html"><a href="health-and-retirement-study-hrs.html#unweighted-counts-15"><i class="fa fa-check"></i>Unweighted Counts</a></li>
<li class="chapter" data-level="" data-path="health-and-retirement-study-hrs.html"><a href="health-and-retirement-study-hrs.html#weighted-counts-10"><i class="fa fa-check"></i>Weighted Counts</a></li>
<li class="chapter" data-level="" data-path="health-and-retirement-study-hrs.html"><a href="health-and-retirement-study-hrs.html#descriptive-statistics-15"><i class="fa fa-check"></i>Descriptive Statistics</a></li>
<li class="chapter" data-level="" data-path="health-and-retirement-study-hrs.html"><a href="health-and-retirement-study-hrs.html#subsetting-15"><i class="fa fa-check"></i>Subsetting</a></li>
<li class="chapter" data-level="" data-path="health-and-retirement-study-hrs.html"><a href="health-and-retirement-study-hrs.html#measures-of-uncertainty-15"><i class="fa fa-check"></i>Measures of Uncertainty</a></li>
<li class="chapter" data-level="" data-path="health-and-retirement-study-hrs.html"><a href="health-and-retirement-study-hrs.html#regression-models-and-tests-of-association-15"><i class="fa fa-check"></i>Regression Models and Tests of Association</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="health-and-retirement-study-hrs.html"><a href="health-and-retirement-study-hrs.html#replication-example-15"><i class="fa fa-check"></i>Replication Example</a></li>
<li class="chapter" data-level="" data-path="health-and-retirement-study-hrs.html"><a href="health-and-retirement-study-hrs.html#analysis-examples-with-srvyr-9"><i class="fa fa-check"></i>Analysis Examples with <code>srvyr</code>  </a></li>
</ul></li>
<li class="chapter" data-level="" data-path="medicare-current-beneficiary-survey-mcbs.html"><a href="medicare-current-beneficiary-survey-mcbs.html"><i class="fa fa-check"></i>Medicare Current Beneficiary Survey (MCBS)</a>
<ul>
<li class="chapter" data-level="" data-path="medicare-current-beneficiary-survey-mcbs.html"><a href="medicare-current-beneficiary-survey-mcbs.html#download-import-preparation-17"><i class="fa fa-check"></i>Download, Import, Preparation</a>
<ul>
<li class="chapter" data-level="" data-path="medicare-current-beneficiary-survey-mcbs.html"><a href="medicare-current-beneficiary-survey-mcbs.html#save-locally-16"><i class="fa fa-check"></i>Save Locally  </a></li>
<li class="chapter" data-level="" data-path="medicare-current-beneficiary-survey-mcbs.html"><a href="medicare-current-beneficiary-survey-mcbs.html#survey-design-definition-11"><i class="fa fa-check"></i>Survey Design Definition</a></li>
<li class="chapter" data-level="" data-path="medicare-current-beneficiary-survey-mcbs.html"><a href="medicare-current-beneficiary-survey-mcbs.html#variable-recoding-16"><i class="fa fa-check"></i>Variable Recoding</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="medicare-current-beneficiary-survey-mcbs.html"><a href="medicare-current-beneficiary-survey-mcbs.html#analysis-examples-with-the-survey-library-11"><i class="fa fa-check"></i>Analysis Examples with the <code>survey</code> library  </a>
<ul>
<li class="chapter" data-level="" data-path="medicare-current-beneficiary-survey-mcbs.html"><a href="medicare-current-beneficiary-survey-mcbs.html#unweighted-counts-16"><i class="fa fa-check"></i>Unweighted Counts</a></li>
<li class="chapter" data-level="" data-path="medicare-current-beneficiary-survey-mcbs.html"><a href="medicare-current-beneficiary-survey-mcbs.html#weighted-counts-11"><i class="fa fa-check"></i>Weighted Counts</a></li>
<li class="chapter" data-level="" data-path="medicare-current-beneficiary-survey-mcbs.html"><a href="medicare-current-beneficiary-survey-mcbs.html#descriptive-statistics-16"><i class="fa fa-check"></i>Descriptive Statistics</a></li>
<li class="chapter" data-level="" data-path="medicare-current-beneficiary-survey-mcbs.html"><a href="medicare-current-beneficiary-survey-mcbs.html#subsetting-16"><i class="fa fa-check"></i>Subsetting</a></li>
<li class="chapter" data-level="" data-path="medicare-current-beneficiary-survey-mcbs.html"><a href="medicare-current-beneficiary-survey-mcbs.html#measures-of-uncertainty-16"><i class="fa fa-check"></i>Measures of Uncertainty</a></li>
<li class="chapter" data-level="" data-path="medicare-current-beneficiary-survey-mcbs.html"><a href="medicare-current-beneficiary-survey-mcbs.html#regression-models-and-tests-of-association-16"><i class="fa fa-check"></i>Regression Models and Tests of Association</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="medicare-current-beneficiary-survey-mcbs.html"><a href="medicare-current-beneficiary-survey-mcbs.html#replication-example-16"><i class="fa fa-check"></i>Replication Example</a></li>
<li class="chapter" data-level="" data-path="medicare-current-beneficiary-survey-mcbs.html"><a href="medicare-current-beneficiary-survey-mcbs.html#analysis-examples-with-srvyr-10"><i class="fa fa-check"></i>Analysis Examples with <code>srvyr</code>  </a></li>
</ul></li>
<li class="chapter" data-level="" data-path="medical-expenditure-panel-survey-meps.html"><a href="medical-expenditure-panel-survey-meps.html"><i class="fa fa-check"></i>Medical Expenditure Panel Survey (MEPS)</a>
<ul>
<li class="chapter" data-level="" data-path="medical-expenditure-panel-survey-meps.html"><a href="medical-expenditure-panel-survey-meps.html#function-definitions-4"><i class="fa fa-check"></i>Function Definitions</a></li>
<li class="chapter" data-level="" data-path="medical-expenditure-panel-survey-meps.html"><a href="medical-expenditure-panel-survey-meps.html#download-import-preparation-18"><i class="fa fa-check"></i>Download, Import, Preparation</a>
<ul>
<li class="chapter" data-level="" data-path="medical-expenditure-panel-survey-meps.html"><a href="medical-expenditure-panel-survey-meps.html#save-locally-17"><i class="fa fa-check"></i>Save Locally  </a></li>
<li class="chapter" data-level="" data-path="medical-expenditure-panel-survey-meps.html"><a href="medical-expenditure-panel-survey-meps.html#survey-design-definition-12"><i class="fa fa-check"></i>Survey Design Definition</a></li>
<li class="chapter" data-level="" data-path="medical-expenditure-panel-survey-meps.html"><a href="medical-expenditure-panel-survey-meps.html#variable-recoding-17"><i class="fa fa-check"></i>Variable Recoding</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="medical-expenditure-panel-survey-meps.html"><a href="medical-expenditure-panel-survey-meps.html#analysis-examples-with-the-survey-library-12"><i class="fa fa-check"></i>Analysis Examples with the <code>survey</code> library  </a>
<ul>
<li class="chapter" data-level="" data-path="medical-expenditure-panel-survey-meps.html"><a href="medical-expenditure-panel-survey-meps.html#unweighted-counts-17"><i class="fa fa-check"></i>Unweighted Counts</a></li>
<li class="chapter" data-level="" data-path="medical-expenditure-panel-survey-meps.html"><a href="medical-expenditure-panel-survey-meps.html#weighted-counts-12"><i class="fa fa-check"></i>Weighted Counts</a></li>
<li class="chapter" data-level="" data-path="medical-expenditure-panel-survey-meps.html"><a href="medical-expenditure-panel-survey-meps.html#descriptive-statistics-17"><i class="fa fa-check"></i>Descriptive Statistics</a></li>
<li class="chapter" data-level="" data-path="medical-expenditure-panel-survey-meps.html"><a href="medical-expenditure-panel-survey-meps.html#subsetting-17"><i class="fa fa-check"></i>Subsetting</a></li>
<li class="chapter" data-level="" data-path="medical-expenditure-panel-survey-meps.html"><a href="medical-expenditure-panel-survey-meps.html#measures-of-uncertainty-17"><i class="fa fa-check"></i>Measures of Uncertainty</a></li>
<li class="chapter" data-level="" data-path="medical-expenditure-panel-survey-meps.html"><a href="medical-expenditure-panel-survey-meps.html#regression-models-and-tests-of-association-17"><i class="fa fa-check"></i>Regression Models and Tests of Association</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="medical-expenditure-panel-survey-meps.html"><a href="medical-expenditure-panel-survey-meps.html#replication-example-17"><i class="fa fa-check"></i>Replication Example</a></li>
<li class="chapter" data-level="" data-path="medical-expenditure-panel-survey-meps.html"><a href="medical-expenditure-panel-survey-meps.html#analysis-examples-with-srvyr-11"><i class="fa fa-check"></i>Analysis Examples with <code>srvyr</code>  </a></li>
</ul></li>
<li class="chapter" data-level="" data-path="medical-large-claims-experience-study-mlces.html"><a href="medical-large-claims-experience-study-mlces.html"><i class="fa fa-check"></i>Medical Large Claims Experience Study (MLCES)</a>
<ul>
<li class="chapter" data-level="" data-path="medical-large-claims-experience-study-mlces.html"><a href="medical-large-claims-experience-study-mlces.html#download-import-preparation-19"><i class="fa fa-check"></i>Download, Import, Preparation</a>
<ul>
<li class="chapter" data-level="" data-path="medical-large-claims-experience-study-mlces.html"><a href="medical-large-claims-experience-study-mlces.html#save-locally-18"><i class="fa fa-check"></i>Save Locally  </a></li>
<li class="chapter" data-level="" data-path="medical-large-claims-experience-study-mlces.html"><a href="medical-large-claims-experience-study-mlces.html#variable-recoding-18"><i class="fa fa-check"></i>Variable Recoding</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="medical-large-claims-experience-study-mlces.html"><a href="medical-large-claims-experience-study-mlces.html#analysis-examples-with-base-r-5"><i class="fa fa-check"></i>Analysis Examples with base R  </a>
<ul>
<li class="chapter" data-level="" data-path="medical-large-claims-experience-study-mlces.html"><a href="medical-large-claims-experience-study-mlces.html#unweighted-counts-18"><i class="fa fa-check"></i>Unweighted Counts</a></li>
<li class="chapter" data-level="" data-path="medical-large-claims-experience-study-mlces.html"><a href="medical-large-claims-experience-study-mlces.html#descriptive-statistics-18"><i class="fa fa-check"></i>Descriptive Statistics</a></li>
<li class="chapter" data-level="" data-path="medical-large-claims-experience-study-mlces.html"><a href="medical-large-claims-experience-study-mlces.html#subsetting-18"><i class="fa fa-check"></i>Subsetting</a></li>
<li class="chapter" data-level="" data-path="medical-large-claims-experience-study-mlces.html"><a href="medical-large-claims-experience-study-mlces.html#measures-of-uncertainty-18"><i class="fa fa-check"></i>Measures of Uncertainty</a></li>
<li class="chapter" data-level="" data-path="medical-large-claims-experience-study-mlces.html"><a href="medical-large-claims-experience-study-mlces.html#regression-models-and-tests-of-association-18"><i class="fa fa-check"></i>Regression Models and Tests of Association</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="medical-large-claims-experience-study-mlces.html"><a href="medical-large-claims-experience-study-mlces.html#replication-example-18"><i class="fa fa-check"></i>Replication Example</a></li>
<li class="chapter" data-level="" data-path="medical-large-claims-experience-study-mlces.html"><a href="medical-large-claims-experience-study-mlces.html#analysis-examples-with-dplyr-5"><i class="fa fa-check"></i>Analysis Examples with <code>dplyr</code>  </a></li>
<li class="chapter" data-level="" data-path="medical-large-claims-experience-study-mlces.html"><a href="medical-large-claims-experience-study-mlces.html#analysis-examples-with-data.table-5"><i class="fa fa-check"></i>Analysis Examples with <code>data.table</code>  </a></li>
<li class="chapter" data-level="" data-path="medical-large-claims-experience-study-mlces.html"><a href="medical-large-claims-experience-study-mlces.html#analysis-examples-with-duckdb-5"><i class="fa fa-check"></i>Analysis Examples with <code>duckdb</code>  </a></li>
</ul></li>
<li class="chapter" data-level="" data-path="national-agricultural-workers-survey-naws.html"><a href="national-agricultural-workers-survey-naws.html"><i class="fa fa-check"></i>National Agricultural Workers Survey (NAWS)</a>
<ul>
<li class="chapter" data-level="" data-path="national-agricultural-workers-survey-naws.html"><a href="national-agricultural-workers-survey-naws.html#download-import-preparation-20"><i class="fa fa-check"></i>Download, Import, Preparation</a>
<ul>
<li class="chapter" data-level="" data-path="national-agricultural-workers-survey-naws.html"><a href="national-agricultural-workers-survey-naws.html#save-locally-19"><i class="fa fa-check"></i>Save Locally  </a></li>
<li class="chapter" data-level="" data-path="national-agricultural-workers-survey-naws.html"><a href="national-agricultural-workers-survey-naws.html#survey-design-definition-13"><i class="fa fa-check"></i>Survey Design Definition</a></li>
<li class="chapter" data-level="" data-path="national-agricultural-workers-survey-naws.html"><a href="national-agricultural-workers-survey-naws.html#variable-recoding-19"><i class="fa fa-check"></i>Variable Recoding</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="national-agricultural-workers-survey-naws.html"><a href="national-agricultural-workers-survey-naws.html#analysis-examples-with-the-survey-library-13"><i class="fa fa-check"></i>Analysis Examples with the <code>survey</code> library  </a>
<ul>
<li class="chapter" data-level="" data-path="national-agricultural-workers-survey-naws.html"><a href="national-agricultural-workers-survey-naws.html#unweighted-counts-19"><i class="fa fa-check"></i>Unweighted Counts</a></li>
<li class="chapter" data-level="" data-path="national-agricultural-workers-survey-naws.html"><a href="national-agricultural-workers-survey-naws.html#weighted-counts-13"><i class="fa fa-check"></i>Weighted Counts</a></li>
<li class="chapter" data-level="" data-path="national-agricultural-workers-survey-naws.html"><a href="national-agricultural-workers-survey-naws.html#descriptive-statistics-19"><i class="fa fa-check"></i>Descriptive Statistics</a></li>
<li class="chapter" data-level="" data-path="national-agricultural-workers-survey-naws.html"><a href="national-agricultural-workers-survey-naws.html#subsetting-19"><i class="fa fa-check"></i>Subsetting</a></li>
<li class="chapter" data-level="" data-path="national-agricultural-workers-survey-naws.html"><a href="national-agricultural-workers-survey-naws.html#measures-of-uncertainty-19"><i class="fa fa-check"></i>Measures of Uncertainty</a></li>
<li class="chapter" data-level="" data-path="national-agricultural-workers-survey-naws.html"><a href="national-agricultural-workers-survey-naws.html#regression-models-and-tests-of-association-19"><i class="fa fa-check"></i>Regression Models and Tests of Association</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="national-agricultural-workers-survey-naws.html"><a href="national-agricultural-workers-survey-naws.html#replication-example-19"><i class="fa fa-check"></i>Replication Example</a></li>
<li class="chapter" data-level="" data-path="national-agricultural-workers-survey-naws.html"><a href="national-agricultural-workers-survey-naws.html#analysis-examples-with-srvyr-12"><i class="fa fa-check"></i>Analysis Examples with <code>srvyr</code>  </a></li>
</ul></li>
<li class="chapter" data-level="" data-path="national-beneficiary-survey-nbs.html"><a href="national-beneficiary-survey-nbs.html"><i class="fa fa-check"></i>National Beneficiary Survey (NBS)</a>
<ul>
<li class="chapter" data-level="" data-path="national-beneficiary-survey-nbs.html"><a href="national-beneficiary-survey-nbs.html#download-import-preparation-21"><i class="fa fa-check"></i>Download, Import, Preparation</a>
<ul>
<li class="chapter" data-level="" data-path="national-beneficiary-survey-nbs.html"><a href="national-beneficiary-survey-nbs.html#save-locally-20"><i class="fa fa-check"></i>Save Locally  </a></li>
<li class="chapter" data-level="" data-path="national-beneficiary-survey-nbs.html"><a href="national-beneficiary-survey-nbs.html#survey-design-definition-14"><i class="fa fa-check"></i>Survey Design Definition</a></li>
<li class="chapter" data-level="" data-path="national-beneficiary-survey-nbs.html"><a href="national-beneficiary-survey-nbs.html#variable-recoding-20"><i class="fa fa-check"></i>Variable Recoding</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="national-beneficiary-survey-nbs.html"><a href="national-beneficiary-survey-nbs.html#analysis-examples-with-the-survey-library-14"><i class="fa fa-check"></i>Analysis Examples with the <code>survey</code> library  </a>
<ul>
<li class="chapter" data-level="" data-path="national-beneficiary-survey-nbs.html"><a href="national-beneficiary-survey-nbs.html#unweighted-counts-20"><i class="fa fa-check"></i>Unweighted Counts</a></li>
<li class="chapter" data-level="" data-path="national-beneficiary-survey-nbs.html"><a href="national-beneficiary-survey-nbs.html#weighted-counts-14"><i class="fa fa-check"></i>Weighted Counts</a></li>
<li class="chapter" data-level="" data-path="national-beneficiary-survey-nbs.html"><a href="national-beneficiary-survey-nbs.html#descriptive-statistics-20"><i class="fa fa-check"></i>Descriptive Statistics</a></li>
<li class="chapter" data-level="" data-path="national-beneficiary-survey-nbs.html"><a href="national-beneficiary-survey-nbs.html#subsetting-20"><i class="fa fa-check"></i>Subsetting</a></li>
<li class="chapter" data-level="" data-path="national-beneficiary-survey-nbs.html"><a href="national-beneficiary-survey-nbs.html#measures-of-uncertainty-20"><i class="fa fa-check"></i>Measures of Uncertainty</a></li>
<li class="chapter" data-level="" data-path="national-beneficiary-survey-nbs.html"><a href="national-beneficiary-survey-nbs.html#regression-models-and-tests-of-association-20"><i class="fa fa-check"></i>Regression Models and Tests of Association</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="national-beneficiary-survey-nbs.html"><a href="national-beneficiary-survey-nbs.html#replication-example-20"><i class="fa fa-check"></i>Replication Example</a></li>
<li class="chapter" data-level="" data-path="national-beneficiary-survey-nbs.html"><a href="national-beneficiary-survey-nbs.html#analysis-examples-with-srvyr-13"><i class="fa fa-check"></i>Analysis Examples with <code>srvyr</code>  </a></li>
</ul></li>
<li class="chapter" data-level="" data-path="national-crime-victimization-survey-ncvs.html"><a href="national-crime-victimization-survey-ncvs.html"><i class="fa fa-check"></i>National Crime Victimization Survey (NCVS)</a>
<ul>
<li class="chapter" data-level="" data-path="national-crime-victimization-survey-ncvs.html"><a href="national-crime-victimization-survey-ncvs.html#function-definitions-5"><i class="fa fa-check"></i>Function Definitions</a></li>
<li class="chapter" data-level="" data-path="national-crime-victimization-survey-ncvs.html"><a href="national-crime-victimization-survey-ncvs.html#download-import-preparation-22"><i class="fa fa-check"></i>Download, Import, Preparation</a>
<ul>
<li class="chapter" data-level="" data-path="national-crime-victimization-survey-ncvs.html"><a href="national-crime-victimization-survey-ncvs.html#save-locally-21"><i class="fa fa-check"></i>Save Locally  </a></li>
<li class="chapter" data-level="" data-path="national-crime-victimization-survey-ncvs.html"><a href="national-crime-victimization-survey-ncvs.html#survey-design-definition-15"><i class="fa fa-check"></i>Survey Design Definition</a></li>
<li class="chapter" data-level="" data-path="national-crime-victimization-survey-ncvs.html"><a href="national-crime-victimization-survey-ncvs.html#variable-recoding-21"><i class="fa fa-check"></i>Variable Recoding</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="national-crime-victimization-survey-ncvs.html"><a href="national-crime-victimization-survey-ncvs.html#analysis-examples-with-the-survey-library-15"><i class="fa fa-check"></i>Analysis Examples with the <code>survey</code> library  </a>
<ul>
<li class="chapter" data-level="" data-path="national-crime-victimization-survey-ncvs.html"><a href="national-crime-victimization-survey-ncvs.html#unweighted-counts-21"><i class="fa fa-check"></i>Unweighted Counts</a></li>
<li class="chapter" data-level="" data-path="national-crime-victimization-survey-ncvs.html"><a href="national-crime-victimization-survey-ncvs.html#weighted-counts-15"><i class="fa fa-check"></i>Weighted Counts</a></li>
<li class="chapter" data-level="" data-path="national-crime-victimization-survey-ncvs.html"><a href="national-crime-victimization-survey-ncvs.html#descriptive-statistics-21"><i class="fa fa-check"></i>Descriptive Statistics</a></li>
<li class="chapter" data-level="" data-path="national-crime-victimization-survey-ncvs.html"><a href="national-crime-victimization-survey-ncvs.html#subsetting-21"><i class="fa fa-check"></i>Subsetting</a></li>
<li class="chapter" data-level="" data-path="national-crime-victimization-survey-ncvs.html"><a href="national-crime-victimization-survey-ncvs.html#measures-of-uncertainty-21"><i class="fa fa-check"></i>Measures of Uncertainty</a></li>
<li class="chapter" data-level="" data-path="national-crime-victimization-survey-ncvs.html"><a href="national-crime-victimization-survey-ncvs.html#regression-models-and-tests-of-association-21"><i class="fa fa-check"></i>Regression Models and Tests of Association</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="national-crime-victimization-survey-ncvs.html"><a href="national-crime-victimization-survey-ncvs.html#replication-example-21"><i class="fa fa-check"></i>Replication Example</a></li>
<li class="chapter" data-level="" data-path="national-crime-victimization-survey-ncvs.html"><a href="national-crime-victimization-survey-ncvs.html#analysis-examples-with-srvyr-14"><i class="fa fa-check"></i>Analysis Examples with <code>srvyr</code>  </a></li>
</ul></li>
<li class="chapter" data-level="" data-path="national-financial-capability-study-nfcs.html"><a href="national-financial-capability-study-nfcs.html"><i class="fa fa-check"></i>National Financial Capability Study (NFCS)</a>
<ul>
<li class="chapter" data-level="" data-path="national-financial-capability-study-nfcs.html"><a href="national-financial-capability-study-nfcs.html#download-import-preparation-23"><i class="fa fa-check"></i>Download, Import, Preparation</a>
<ul>
<li class="chapter" data-level="" data-path="national-financial-capability-study-nfcs.html"><a href="national-financial-capability-study-nfcs.html#save-locally-22"><i class="fa fa-check"></i>Save Locally  </a></li>
<li class="chapter" data-level="" data-path="national-financial-capability-study-nfcs.html"><a href="national-financial-capability-study-nfcs.html#survey-design-definition-16"><i class="fa fa-check"></i>Survey Design Definition</a></li>
<li class="chapter" data-level="" data-path="national-financial-capability-study-nfcs.html"><a href="national-financial-capability-study-nfcs.html#variable-recoding-22"><i class="fa fa-check"></i>Variable Recoding</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="national-financial-capability-study-nfcs.html"><a href="national-financial-capability-study-nfcs.html#analysis-examples-with-the-survey-library-16"><i class="fa fa-check"></i>Analysis Examples with the <code>survey</code> library  </a>
<ul>
<li class="chapter" data-level="" data-path="national-financial-capability-study-nfcs.html"><a href="national-financial-capability-study-nfcs.html#unweighted-counts-22"><i class="fa fa-check"></i>Unweighted Counts</a></li>
<li class="chapter" data-level="" data-path="national-financial-capability-study-nfcs.html"><a href="national-financial-capability-study-nfcs.html#weighted-counts-16"><i class="fa fa-check"></i>Weighted Counts</a></li>
<li class="chapter" data-level="" data-path="national-financial-capability-study-nfcs.html"><a href="national-financial-capability-study-nfcs.html#descriptive-statistics-22"><i class="fa fa-check"></i>Descriptive Statistics</a></li>
<li class="chapter" data-level="" data-path="national-financial-capability-study-nfcs.html"><a href="national-financial-capability-study-nfcs.html#subsetting-22"><i class="fa fa-check"></i>Subsetting</a></li>
<li class="chapter" data-level="" data-path="national-financial-capability-study-nfcs.html"><a href="national-financial-capability-study-nfcs.html#measures-of-uncertainty-22"><i class="fa fa-check"></i>Measures of Uncertainty</a></li>
<li class="chapter" data-level="" data-path="national-financial-capability-study-nfcs.html"><a href="national-financial-capability-study-nfcs.html#regression-models-and-tests-of-association-22"><i class="fa fa-check"></i>Regression Models and Tests of Association</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="national-financial-capability-study-nfcs.html"><a href="national-financial-capability-study-nfcs.html#replication-example-22"><i class="fa fa-check"></i>Replication Example</a></li>
<li class="chapter" data-level="" data-path="national-financial-capability-study-nfcs.html"><a href="national-financial-capability-study-nfcs.html#analysis-examples-with-srvyr-15"><i class="fa fa-check"></i>Analysis Examples with <code>srvyr</code>  </a></li>
</ul></li>
<li class="chapter" data-level="" data-path="national-health-and-nutrition-examination-survey-nhanes.html"><a href="national-health-and-nutrition-examination-survey-nhanes.html"><i class="fa fa-check"></i>National Health and Nutrition Examination Survey (NHANES)</a>
<ul>
<li class="chapter" data-level="" data-path="national-health-and-nutrition-examination-survey-nhanes.html"><a href="national-health-and-nutrition-examination-survey-nhanes.html#download-import-preparation-24"><i class="fa fa-check"></i>Download, Import, Preparation</a>
<ul>
<li class="chapter" data-level="" data-path="national-health-and-nutrition-examination-survey-nhanes.html"><a href="national-health-and-nutrition-examination-survey-nhanes.html#save-locally-23"><i class="fa fa-check"></i>Save Locally  </a></li>
<li class="chapter" data-level="" data-path="national-health-and-nutrition-examination-survey-nhanes.html"><a href="national-health-and-nutrition-examination-survey-nhanes.html#survey-design-definition-17"><i class="fa fa-check"></i>Survey Design Definition</a></li>
<li class="chapter" data-level="" data-path="national-health-and-nutrition-examination-survey-nhanes.html"><a href="national-health-and-nutrition-examination-survey-nhanes.html#variable-recoding-23"><i class="fa fa-check"></i>Variable Recoding</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="national-health-and-nutrition-examination-survey-nhanes.html"><a href="national-health-and-nutrition-examination-survey-nhanes.html#analysis-examples-with-the-survey-library-17"><i class="fa fa-check"></i>Analysis Examples with the <code>survey</code> library  </a>
<ul>
<li class="chapter" data-level="" data-path="national-health-and-nutrition-examination-survey-nhanes.html"><a href="national-health-and-nutrition-examination-survey-nhanes.html#unweighted-counts-23"><i class="fa fa-check"></i>Unweighted Counts</a></li>
<li class="chapter" data-level="" data-path="national-health-and-nutrition-examination-survey-nhanes.html"><a href="national-health-and-nutrition-examination-survey-nhanes.html#weighted-counts-17"><i class="fa fa-check"></i>Weighted Counts</a></li>
<li class="chapter" data-level="" data-path="national-health-and-nutrition-examination-survey-nhanes.html"><a href="national-health-and-nutrition-examination-survey-nhanes.html#descriptive-statistics-23"><i class="fa fa-check"></i>Descriptive Statistics</a></li>
<li class="chapter" data-level="" data-path="national-health-and-nutrition-examination-survey-nhanes.html"><a href="national-health-and-nutrition-examination-survey-nhanes.html#subsetting-23"><i class="fa fa-check"></i>Subsetting</a></li>
<li class="chapter" data-level="" data-path="national-health-and-nutrition-examination-survey-nhanes.html"><a href="national-health-and-nutrition-examination-survey-nhanes.html#measures-of-uncertainty-23"><i class="fa fa-check"></i>Measures of Uncertainty</a></li>
<li class="chapter" data-level="" data-path="national-health-and-nutrition-examination-survey-nhanes.html"><a href="national-health-and-nutrition-examination-survey-nhanes.html#regression-models-and-tests-of-association-23"><i class="fa fa-check"></i>Regression Models and Tests of Association</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="national-health-and-nutrition-examination-survey-nhanes.html"><a href="national-health-and-nutrition-examination-survey-nhanes.html#direct-method-of-age-adjustment-replication-example"><i class="fa fa-check"></i>Direct Method of Age-Adjustment Replication Example</a></li>
<li class="chapter" data-level="" data-path="national-health-and-nutrition-examination-survey-nhanes.html"><a href="national-health-and-nutrition-examination-survey-nhanes.html#analysis-examples-with-srvyr-16"><i class="fa fa-check"></i>Analysis Examples with <code>srvyr</code>  </a></li>
</ul></li>
<li class="chapter" data-level="" data-path="national-health-interview-survey-nhis.html"><a href="national-health-interview-survey-nhis.html"><i class="fa fa-check"></i>National Health Interview Survey (NHIS)</a>
<ul>
<li class="chapter" data-level="" data-path="national-health-interview-survey-nhis.html"><a href="national-health-interview-survey-nhis.html#function-definitions-6"><i class="fa fa-check"></i>Function Definitions</a></li>
<li class="chapter" data-level="" data-path="national-health-interview-survey-nhis.html"><a href="national-health-interview-survey-nhis.html#download-import-preparation-25"><i class="fa fa-check"></i>Download, Import, Preparation</a>
<ul>
<li class="chapter" data-level="" data-path="national-health-interview-survey-nhis.html"><a href="national-health-interview-survey-nhis.html#save-locally-24"><i class="fa fa-check"></i>Save Locally  </a></li>
<li class="chapter" data-level="" data-path="national-health-interview-survey-nhis.html"><a href="national-health-interview-survey-nhis.html#survey-design-definition-18"><i class="fa fa-check"></i>Survey Design Definition</a></li>
<li class="chapter" data-level="" data-path="national-health-interview-survey-nhis.html"><a href="national-health-interview-survey-nhis.html#variable-recoding-24"><i class="fa fa-check"></i>Variable Recoding</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="national-health-interview-survey-nhis.html"><a href="national-health-interview-survey-nhis.html#analysis-examples-with-the-survey-library-18"><i class="fa fa-check"></i>Analysis Examples with the <code>survey</code> library  </a>
<ul>
<li class="chapter" data-level="" data-path="national-health-interview-survey-nhis.html"><a href="national-health-interview-survey-nhis.html#unweighted-counts-24"><i class="fa fa-check"></i>Unweighted Counts</a></li>
<li class="chapter" data-level="" data-path="national-health-interview-survey-nhis.html"><a href="national-health-interview-survey-nhis.html#weighted-counts-18"><i class="fa fa-check"></i>Weighted Counts</a></li>
<li class="chapter" data-level="" data-path="national-health-interview-survey-nhis.html"><a href="national-health-interview-survey-nhis.html#descriptive-statistics-24"><i class="fa fa-check"></i>Descriptive Statistics</a></li>
<li class="chapter" data-level="" data-path="national-health-interview-survey-nhis.html"><a href="national-health-interview-survey-nhis.html#subsetting-24"><i class="fa fa-check"></i>Subsetting</a></li>
<li class="chapter" data-level="" data-path="national-health-interview-survey-nhis.html"><a href="national-health-interview-survey-nhis.html#measures-of-uncertainty-24"><i class="fa fa-check"></i>Measures of Uncertainty</a></li>
<li class="chapter" data-level="" data-path="national-health-interview-survey-nhis.html"><a href="national-health-interview-survey-nhis.html#regression-models-and-tests-of-association-24"><i class="fa fa-check"></i>Regression Models and Tests of Association</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="national-health-interview-survey-nhis.html"><a href="national-health-interview-survey-nhis.html#replication-example-23"><i class="fa fa-check"></i>Replication Example</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="national-household-travel-survey-nhts.html"><a href="national-household-travel-survey-nhts.html"><i class="fa fa-check"></i>National Household Travel Survey (NHTS)</a>
<ul>
<li class="chapter" data-level="" data-path="national-household-travel-survey-nhts.html"><a href="national-household-travel-survey-nhts.html#download-import-preparation-26"><i class="fa fa-check"></i>Download, Import, Preparation</a>
<ul>
<li class="chapter" data-level="" data-path="national-household-travel-survey-nhts.html"><a href="national-household-travel-survey-nhts.html#save-locally-25"><i class="fa fa-check"></i>Save Locally  </a></li>
<li class="chapter" data-level="" data-path="national-household-travel-survey-nhts.html"><a href="national-household-travel-survey-nhts.html#survey-design-definition-19"><i class="fa fa-check"></i>Survey Design Definition</a></li>
<li class="chapter" data-level="" data-path="national-household-travel-survey-nhts.html"><a href="national-household-travel-survey-nhts.html#variable-recoding-25"><i class="fa fa-check"></i>Variable Recoding</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="national-household-travel-survey-nhts.html"><a href="national-household-travel-survey-nhts.html#analysis-examples-with-the-survey-library-19"><i class="fa fa-check"></i>Analysis Examples with the <code>survey</code> library  </a>
<ul>
<li class="chapter" data-level="" data-path="national-household-travel-survey-nhts.html"><a href="national-household-travel-survey-nhts.html#unweighted-counts-25"><i class="fa fa-check"></i>Unweighted Counts</a></li>
<li class="chapter" data-level="" data-path="national-household-travel-survey-nhts.html"><a href="national-household-travel-survey-nhts.html#weighted-counts-19"><i class="fa fa-check"></i>Weighted Counts</a></li>
<li class="chapter" data-level="" data-path="national-household-travel-survey-nhts.html"><a href="national-household-travel-survey-nhts.html#descriptive-statistics-25"><i class="fa fa-check"></i>Descriptive Statistics</a></li>
<li class="chapter" data-level="" data-path="national-household-travel-survey-nhts.html"><a href="national-household-travel-survey-nhts.html#subsetting-25"><i class="fa fa-check"></i>Subsetting</a></li>
<li class="chapter" data-level="" data-path="national-household-travel-survey-nhts.html"><a href="national-household-travel-survey-nhts.html#measures-of-uncertainty-25"><i class="fa fa-check"></i>Measures of Uncertainty</a></li>
<li class="chapter" data-level="" data-path="national-household-travel-survey-nhts.html"><a href="national-household-travel-survey-nhts.html#regression-models-and-tests-of-association-25"><i class="fa fa-check"></i>Regression Models and Tests of Association</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="national-household-travel-survey-nhts.html"><a href="national-household-travel-survey-nhts.html#replication-example-24"><i class="fa fa-check"></i>Replication Example</a></li>
<li class="chapter" data-level="" data-path="national-household-travel-survey-nhts.html"><a href="national-household-travel-survey-nhts.html#analysis-examples-with-srvyr-17"><i class="fa fa-check"></i>Analysis Examples with <code>srvyr</code>  </a></li>
</ul></li>
<li class="chapter" data-level="" data-path="national-immunization-survey-nis.html"><a href="national-immunization-survey-nis.html"><i class="fa fa-check"></i>National Immunization Survey (NIS)</a>
<ul>
<li class="chapter" data-level="" data-path="national-immunization-survey-nis.html"><a href="national-immunization-survey-nis.html#download-import-preparation-27"><i class="fa fa-check"></i>Download, Import, Preparation</a>
<ul>
<li class="chapter" data-level="" data-path="national-immunization-survey-nis.html"><a href="national-immunization-survey-nis.html#save-locally-26"><i class="fa fa-check"></i>Save Locally  </a></li>
<li class="chapter" data-level="" data-path="national-immunization-survey-nis.html"><a href="national-immunization-survey-nis.html#survey-design-definition-20"><i class="fa fa-check"></i>Survey Design Definition</a></li>
<li class="chapter" data-level="" data-path="national-immunization-survey-nis.html"><a href="national-immunization-survey-nis.html#variable-recoding-26"><i class="fa fa-check"></i>Variable Recoding</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="national-immunization-survey-nis.html"><a href="national-immunization-survey-nis.html#analysis-examples-with-the-survey-library-20"><i class="fa fa-check"></i>Analysis Examples with the <code>survey</code> library  </a>
<ul>
<li class="chapter" data-level="" data-path="national-immunization-survey-nis.html"><a href="national-immunization-survey-nis.html#unweighted-counts-26"><i class="fa fa-check"></i>Unweighted Counts</a></li>
<li class="chapter" data-level="" data-path="national-immunization-survey-nis.html"><a href="national-immunization-survey-nis.html#weighted-counts-20"><i class="fa fa-check"></i>Weighted Counts</a></li>
<li class="chapter" data-level="" data-path="national-immunization-survey-nis.html"><a href="national-immunization-survey-nis.html#descriptive-statistics-26"><i class="fa fa-check"></i>Descriptive Statistics</a></li>
<li class="chapter" data-level="" data-path="national-immunization-survey-nis.html"><a href="national-immunization-survey-nis.html#subsetting-26"><i class="fa fa-check"></i>Subsetting</a></li>
<li class="chapter" data-level="" data-path="national-immunization-survey-nis.html"><a href="national-immunization-survey-nis.html#measures-of-uncertainty-26"><i class="fa fa-check"></i>Measures of Uncertainty</a></li>
<li class="chapter" data-level="" data-path="national-immunization-survey-nis.html"><a href="national-immunization-survey-nis.html#regression-models-and-tests-of-association-26"><i class="fa fa-check"></i>Regression Models and Tests of Association</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="national-immunization-survey-nis.html"><a href="national-immunization-survey-nis.html#replication-example-25"><i class="fa fa-check"></i>Replication Example</a></li>
<li class="chapter" data-level="" data-path="national-immunization-survey-nis.html"><a href="national-immunization-survey-nis.html#analysis-examples-with-srvyr-18"><i class="fa fa-check"></i>Analysis Examples with <code>srvyr</code>  </a></li>
</ul></li>
<li class="chapter" data-level="" data-path="national-plan-and-provider-enumeration-system-nppes.html"><a href="national-plan-and-provider-enumeration-system-nppes.html"><i class="fa fa-check"></i>National Plan and Provider Enumeration System (NPPES)</a>
<ul>
<li class="chapter" data-level="" data-path="national-plan-and-provider-enumeration-system-nppes.html"><a href="national-plan-and-provider-enumeration-system-nppes.html#download-import-preparation-28"><i class="fa fa-check"></i>Download, Import, Preparation</a>
<ul>
<li class="chapter" data-level="" data-path="national-plan-and-provider-enumeration-system-nppes.html"><a href="national-plan-and-provider-enumeration-system-nppes.html#save-locally-27"><i class="fa fa-check"></i>Save Locally  </a></li>
<li class="chapter" data-level="" data-path="national-plan-and-provider-enumeration-system-nppes.html"><a href="national-plan-and-provider-enumeration-system-nppes.html#variable-recoding-27"><i class="fa fa-check"></i>Variable Recoding</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="national-plan-and-provider-enumeration-system-nppes.html"><a href="national-plan-and-provider-enumeration-system-nppes.html#analysis-examples-with-base-r-6"><i class="fa fa-check"></i>Analysis Examples with base R  </a>
<ul>
<li class="chapter" data-level="" data-path="national-plan-and-provider-enumeration-system-nppes.html"><a href="national-plan-and-provider-enumeration-system-nppes.html#unweighted-counts-27"><i class="fa fa-check"></i>Unweighted Counts</a></li>
<li class="chapter" data-level="" data-path="national-plan-and-provider-enumeration-system-nppes.html"><a href="national-plan-and-provider-enumeration-system-nppes.html#descriptive-statistics-27"><i class="fa fa-check"></i>Descriptive Statistics</a></li>
<li class="chapter" data-level="" data-path="national-plan-and-provider-enumeration-system-nppes.html"><a href="national-plan-and-provider-enumeration-system-nppes.html#subsetting-27"><i class="fa fa-check"></i>Subsetting</a></li>
<li class="chapter" data-level="" data-path="national-plan-and-provider-enumeration-system-nppes.html"><a href="national-plan-and-provider-enumeration-system-nppes.html#measures-of-uncertainty-27"><i class="fa fa-check"></i>Measures of Uncertainty</a></li>
<li class="chapter" data-level="" data-path="national-plan-and-provider-enumeration-system-nppes.html"><a href="national-plan-and-provider-enumeration-system-nppes.html#regression-models-and-tests-of-association-27"><i class="fa fa-check"></i>Regression Models and Tests of Association</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="national-plan-and-provider-enumeration-system-nppes.html"><a href="national-plan-and-provider-enumeration-system-nppes.html#analysis-examples-with-dplyr-6"><i class="fa fa-check"></i>Analysis Examples with <code>dplyr</code>  </a></li>
<li class="chapter" data-level="" data-path="national-plan-and-provider-enumeration-system-nppes.html"><a href="national-plan-and-provider-enumeration-system-nppes.html#analysis-examples-with-data.table-6"><i class="fa fa-check"></i>Analysis Examples with <code>data.table</code>  </a></li>
<li class="chapter" data-level="" data-path="national-plan-and-provider-enumeration-system-nppes.html"><a href="national-plan-and-provider-enumeration-system-nppes.html#analysis-examples-with-duckdb-6"><i class="fa fa-check"></i>Analysis Examples with <code>duckdb</code>  </a></li>
</ul></li>
<li class="chapter" data-level="" data-path="national-survey-of-childrens-health-nsch.html"><a href="national-survey-of-childrens-health-nsch.html"><i class="fa fa-check"></i>National Survey of Children’s Health (NSCH)</a>
<ul>
<li class="chapter" data-level="" data-path="national-survey-of-childrens-health-nsch.html"><a href="national-survey-of-childrens-health-nsch.html#function-definitions-7"><i class="fa fa-check"></i>Function Definitions</a></li>
<li class="chapter" data-level="" data-path="national-survey-of-childrens-health-nsch.html"><a href="national-survey-of-childrens-health-nsch.html#download-import-preparation-29"><i class="fa fa-check"></i>Download, Import, Preparation</a>
<ul>
<li class="chapter" data-level="" data-path="national-survey-of-childrens-health-nsch.html"><a href="national-survey-of-childrens-health-nsch.html#save-locally-28"><i class="fa fa-check"></i>Save Locally  </a></li>
<li class="chapter" data-level="" data-path="national-survey-of-childrens-health-nsch.html"><a href="national-survey-of-childrens-health-nsch.html#survey-design-definition-21"><i class="fa fa-check"></i>Survey Design Definition</a></li>
<li class="chapter" data-level="" data-path="national-survey-of-childrens-health-nsch.html"><a href="national-survey-of-childrens-health-nsch.html#variable-recoding-28"><i class="fa fa-check"></i>Variable Recoding</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="national-survey-of-childrens-health-nsch.html"><a href="national-survey-of-childrens-health-nsch.html#analysis-examples-with-the-survey-library-21"><i class="fa fa-check"></i>Analysis Examples with the <code>survey</code> library  </a>
<ul>
<li class="chapter" data-level="" data-path="national-survey-of-childrens-health-nsch.html"><a href="national-survey-of-childrens-health-nsch.html#unweighted-counts-28"><i class="fa fa-check"></i>Unweighted Counts</a></li>
<li class="chapter" data-level="" data-path="national-survey-of-childrens-health-nsch.html"><a href="national-survey-of-childrens-health-nsch.html#weighted-counts-21"><i class="fa fa-check"></i>Weighted Counts</a></li>
<li class="chapter" data-level="" data-path="national-survey-of-childrens-health-nsch.html"><a href="national-survey-of-childrens-health-nsch.html#descriptive-statistics-28"><i class="fa fa-check"></i>Descriptive Statistics</a></li>
<li class="chapter" data-level="" data-path="national-survey-of-childrens-health-nsch.html"><a href="national-survey-of-childrens-health-nsch.html#subsetting-28"><i class="fa fa-check"></i>Subsetting</a></li>
<li class="chapter" data-level="" data-path="national-survey-of-childrens-health-nsch.html"><a href="national-survey-of-childrens-health-nsch.html#measures-of-uncertainty-28"><i class="fa fa-check"></i>Measures of Uncertainty</a></li>
<li class="chapter" data-level="" data-path="national-survey-of-childrens-health-nsch.html"><a href="national-survey-of-childrens-health-nsch.html#regression-models-and-tests-of-association-28"><i class="fa fa-check"></i>Regression Models and Tests of Association</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="national-survey-of-childrens-health-nsch.html"><a href="national-survey-of-childrens-health-nsch.html#replication-example-26"><i class="fa fa-check"></i>Replication Example</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="national-survey-on-drug-use-and-health-nsduh.html"><a href="national-survey-on-drug-use-and-health-nsduh.html"><i class="fa fa-check"></i>National Survey on Drug Use and Health (NSDUH)</a>
<ul>
<li class="chapter" data-level="" data-path="national-survey-on-drug-use-and-health-nsduh.html"><a href="national-survey-on-drug-use-and-health-nsduh.html#download-import-preparation-30"><i class="fa fa-check"></i>Download, Import, Preparation</a>
<ul>
<li class="chapter" data-level="" data-path="national-survey-on-drug-use-and-health-nsduh.html"><a href="national-survey-on-drug-use-and-health-nsduh.html#save-locally-29"><i class="fa fa-check"></i>Save Locally  </a></li>
<li class="chapter" data-level="" data-path="national-survey-on-drug-use-and-health-nsduh.html"><a href="national-survey-on-drug-use-and-health-nsduh.html#survey-design-definition-22"><i class="fa fa-check"></i>Survey Design Definition</a></li>
<li class="chapter" data-level="" data-path="national-survey-on-drug-use-and-health-nsduh.html"><a href="national-survey-on-drug-use-and-health-nsduh.html#variable-recoding-29"><i class="fa fa-check"></i>Variable Recoding</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="national-survey-on-drug-use-and-health-nsduh.html"><a href="national-survey-on-drug-use-and-health-nsduh.html#analysis-examples-with-the-survey-library-22"><i class="fa fa-check"></i>Analysis Examples with the <code>survey</code> library  </a>
<ul>
<li class="chapter" data-level="" data-path="national-survey-on-drug-use-and-health-nsduh.html"><a href="national-survey-on-drug-use-and-health-nsduh.html#unweighted-counts-29"><i class="fa fa-check"></i>Unweighted Counts</a></li>
<li class="chapter" data-level="" data-path="national-survey-on-drug-use-and-health-nsduh.html"><a href="national-survey-on-drug-use-and-health-nsduh.html#weighted-counts-22"><i class="fa fa-check"></i>Weighted Counts</a></li>
<li class="chapter" data-level="" data-path="national-survey-on-drug-use-and-health-nsduh.html"><a href="national-survey-on-drug-use-and-health-nsduh.html#descriptive-statistics-29"><i class="fa fa-check"></i>Descriptive Statistics</a></li>
<li class="chapter" data-level="" data-path="national-survey-on-drug-use-and-health-nsduh.html"><a href="national-survey-on-drug-use-and-health-nsduh.html#subsetting-29"><i class="fa fa-check"></i>Subsetting</a></li>
<li class="chapter" data-level="" data-path="national-survey-on-drug-use-and-health-nsduh.html"><a href="national-survey-on-drug-use-and-health-nsduh.html#measures-of-uncertainty-29"><i class="fa fa-check"></i>Measures of Uncertainty</a></li>
<li class="chapter" data-level="" data-path="national-survey-on-drug-use-and-health-nsduh.html"><a href="national-survey-on-drug-use-and-health-nsduh.html#regression-models-and-tests-of-association-29"><i class="fa fa-check"></i>Regression Models and Tests of Association</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="national-survey-on-drug-use-and-health-nsduh.html"><a href="national-survey-on-drug-use-and-health-nsduh.html#replication-example-27"><i class="fa fa-check"></i>Replication Example</a></li>
<li class="chapter" data-level="" data-path="national-survey-on-drug-use-and-health-nsduh.html"><a href="national-survey-on-drug-use-and-health-nsduh.html#analysis-examples-with-srvyr-19"><i class="fa fa-check"></i>Analysis Examples with <code>srvyr</code>  </a></li>
</ul></li>
<li class="chapter" data-level="" data-path="national-survey-of-family-growth-nsfg.html"><a href="national-survey-of-family-growth-nsfg.html"><i class="fa fa-check"></i>National Survey of Family Growth (NSFG)</a>
<ul>
<li class="chapter" data-level="" data-path="national-survey-of-family-growth-nsfg.html"><a href="national-survey-of-family-growth-nsfg.html#download-import-preparation-31"><i class="fa fa-check"></i>Download, Import, Preparation</a>
<ul>
<li class="chapter" data-level="" data-path="national-survey-of-family-growth-nsfg.html"><a href="national-survey-of-family-growth-nsfg.html#save-locally-30"><i class="fa fa-check"></i>Save Locally  </a></li>
<li class="chapter" data-level="" data-path="national-survey-of-family-growth-nsfg.html"><a href="national-survey-of-family-growth-nsfg.html#survey-design-definition-23"><i class="fa fa-check"></i>Survey Design Definition</a></li>
<li class="chapter" data-level="" data-path="national-survey-of-family-growth-nsfg.html"><a href="national-survey-of-family-growth-nsfg.html#variable-recoding-30"><i class="fa fa-check"></i>Variable Recoding</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="national-survey-of-family-growth-nsfg.html"><a href="national-survey-of-family-growth-nsfg.html#analysis-examples-with-the-survey-library-23"><i class="fa fa-check"></i>Analysis Examples with the <code>survey</code> library  </a>
<ul>
<li class="chapter" data-level="" data-path="national-survey-of-family-growth-nsfg.html"><a href="national-survey-of-family-growth-nsfg.html#unweighted-counts-30"><i class="fa fa-check"></i>Unweighted Counts</a></li>
<li class="chapter" data-level="" data-path="national-survey-of-family-growth-nsfg.html"><a href="national-survey-of-family-growth-nsfg.html#weighted-counts-23"><i class="fa fa-check"></i>Weighted Counts</a></li>
<li class="chapter" data-level="" data-path="national-survey-of-family-growth-nsfg.html"><a href="national-survey-of-family-growth-nsfg.html#descriptive-statistics-30"><i class="fa fa-check"></i>Descriptive Statistics</a></li>
<li class="chapter" data-level="" data-path="national-survey-of-family-growth-nsfg.html"><a href="national-survey-of-family-growth-nsfg.html#subsetting-30"><i class="fa fa-check"></i>Subsetting</a></li>
<li class="chapter" data-level="" data-path="national-survey-of-family-growth-nsfg.html"><a href="national-survey-of-family-growth-nsfg.html#measures-of-uncertainty-30"><i class="fa fa-check"></i>Measures of Uncertainty</a></li>
<li class="chapter" data-level="" data-path="national-survey-of-family-growth-nsfg.html"><a href="national-survey-of-family-growth-nsfg.html#regression-models-and-tests-of-association-30"><i class="fa fa-check"></i>Regression Models and Tests of Association</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="national-survey-of-family-growth-nsfg.html"><a href="national-survey-of-family-growth-nsfg.html#replication-example-28"><i class="fa fa-check"></i>Replication Example</a></li>
<li class="chapter" data-level="" data-path="national-survey-of-family-growth-nsfg.html"><a href="national-survey-of-family-growth-nsfg.html#analysis-examples-with-srvyr-20"><i class="fa fa-check"></i>Analysis Examples with <code>srvyr</code>  </a></li>
</ul></li>
<li class="chapter" data-level="" data-path="national-sample-survey-of-registered-nurses-nssrn.html"><a href="national-sample-survey-of-registered-nurses-nssrn.html"><i class="fa fa-check"></i>National Sample Survey of Registered Nurses (NSSRN)</a>
<ul>
<li class="chapter" data-level="" data-path="national-sample-survey-of-registered-nurses-nssrn.html"><a href="national-sample-survey-of-registered-nurses-nssrn.html#download-import-preparation-32"><i class="fa fa-check"></i>Download, Import, Preparation</a>
<ul>
<li class="chapter" data-level="" data-path="national-sample-survey-of-registered-nurses-nssrn.html"><a href="national-sample-survey-of-registered-nurses-nssrn.html#save-locally-31"><i class="fa fa-check"></i>Save Locally  </a></li>
<li class="chapter" data-level="" data-path="national-sample-survey-of-registered-nurses-nssrn.html"><a href="national-sample-survey-of-registered-nurses-nssrn.html#survey-design-definition-24"><i class="fa fa-check"></i>Survey Design Definition</a></li>
<li class="chapter" data-level="" data-path="national-sample-survey-of-registered-nurses-nssrn.html"><a href="national-sample-survey-of-registered-nurses-nssrn.html#variable-recoding-31"><i class="fa fa-check"></i>Variable Recoding</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="national-sample-survey-of-registered-nurses-nssrn.html"><a href="national-sample-survey-of-registered-nurses-nssrn.html#analysis-examples-with-the-survey-library-24"><i class="fa fa-check"></i>Analysis Examples with the <code>survey</code> library  </a>
<ul>
<li class="chapter" data-level="" data-path="national-sample-survey-of-registered-nurses-nssrn.html"><a href="national-sample-survey-of-registered-nurses-nssrn.html#unweighted-counts-31"><i class="fa fa-check"></i>Unweighted Counts</a></li>
<li class="chapter" data-level="" data-path="national-sample-survey-of-registered-nurses-nssrn.html"><a href="national-sample-survey-of-registered-nurses-nssrn.html#weighted-counts-24"><i class="fa fa-check"></i>Weighted Counts</a></li>
<li class="chapter" data-level="" data-path="national-sample-survey-of-registered-nurses-nssrn.html"><a href="national-sample-survey-of-registered-nurses-nssrn.html#descriptive-statistics-31"><i class="fa fa-check"></i>Descriptive Statistics</a></li>
<li class="chapter" data-level="" data-path="national-sample-survey-of-registered-nurses-nssrn.html"><a href="national-sample-survey-of-registered-nurses-nssrn.html#subsetting-31"><i class="fa fa-check"></i>Subsetting</a></li>
<li class="chapter" data-level="" data-path="national-sample-survey-of-registered-nurses-nssrn.html"><a href="national-sample-survey-of-registered-nurses-nssrn.html#measures-of-uncertainty-31"><i class="fa fa-check"></i>Measures of Uncertainty</a></li>
<li class="chapter" data-level="" data-path="national-sample-survey-of-registered-nurses-nssrn.html"><a href="national-sample-survey-of-registered-nurses-nssrn.html#regression-models-and-tests-of-association-31"><i class="fa fa-check"></i>Regression Models and Tests of Association</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="national-sample-survey-of-registered-nurses-nssrn.html"><a href="national-sample-survey-of-registered-nurses-nssrn.html#replication-example-29"><i class="fa fa-check"></i>Replication Example</a></li>
<li class="chapter" data-level="" data-path="national-sample-survey-of-registered-nurses-nssrn.html"><a href="national-sample-survey-of-registered-nurses-nssrn.html#analysis-examples-with-srvyr-21"><i class="fa fa-check"></i>Analysis Examples with <code>srvyr</code>  </a></li>
</ul></li>
<li class="chapter" data-level="" data-path="new-york-city-housing-and-vacancy-survey-nychvs.html"><a href="new-york-city-housing-and-vacancy-survey-nychvs.html"><i class="fa fa-check"></i>New York City Housing and Vacancy Survey (NYCHVS)</a>
<ul>
<li class="chapter" data-level="" data-path="new-york-city-housing-and-vacancy-survey-nychvs.html"><a href="new-york-city-housing-and-vacancy-survey-nychvs.html#function-definitions-8"><i class="fa fa-check"></i>Function Definitions</a></li>
<li class="chapter" data-level="" data-path="new-york-city-housing-and-vacancy-survey-nychvs.html"><a href="new-york-city-housing-and-vacancy-survey-nychvs.html#download-import-preparation-33"><i class="fa fa-check"></i>Download, Import, Preparation</a>
<ul>
<li class="chapter" data-level="" data-path="new-york-city-housing-and-vacancy-survey-nychvs.html"><a href="new-york-city-housing-and-vacancy-survey-nychvs.html#save-locally-32"><i class="fa fa-check"></i>Save Locally  </a></li>
<li class="chapter" data-level="" data-path="new-york-city-housing-and-vacancy-survey-nychvs.html"><a href="new-york-city-housing-and-vacancy-survey-nychvs.html#survey-design-definition-25"><i class="fa fa-check"></i>Survey Design Definition</a></li>
<li class="chapter" data-level="" data-path="new-york-city-housing-and-vacancy-survey-nychvs.html"><a href="new-york-city-housing-and-vacancy-survey-nychvs.html#variable-recoding-32"><i class="fa fa-check"></i>Variable Recoding</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="new-york-city-housing-and-vacancy-survey-nychvs.html"><a href="new-york-city-housing-and-vacancy-survey-nychvs.html#analysis-examples-with-the-survey-library-25"><i class="fa fa-check"></i>Analysis Examples with the <code>survey</code> library  </a>
<ul>
<li class="chapter" data-level="" data-path="new-york-city-housing-and-vacancy-survey-nychvs.html"><a href="new-york-city-housing-and-vacancy-survey-nychvs.html#unweighted-counts-32"><i class="fa fa-check"></i>Unweighted Counts</a></li>
<li class="chapter" data-level="" data-path="new-york-city-housing-and-vacancy-survey-nychvs.html"><a href="new-york-city-housing-and-vacancy-survey-nychvs.html#weighted-counts-25"><i class="fa fa-check"></i>Weighted Counts</a></li>
<li class="chapter" data-level="" data-path="new-york-city-housing-and-vacancy-survey-nychvs.html"><a href="new-york-city-housing-and-vacancy-survey-nychvs.html#descriptive-statistics-32"><i class="fa fa-check"></i>Descriptive Statistics</a></li>
<li class="chapter" data-level="" data-path="new-york-city-housing-and-vacancy-survey-nychvs.html"><a href="new-york-city-housing-and-vacancy-survey-nychvs.html#subsetting-32"><i class="fa fa-check"></i>Subsetting</a></li>
<li class="chapter" data-level="" data-path="new-york-city-housing-and-vacancy-survey-nychvs.html"><a href="new-york-city-housing-and-vacancy-survey-nychvs.html#measures-of-uncertainty-32"><i class="fa fa-check"></i>Measures of Uncertainty</a></li>
<li class="chapter" data-level="" data-path="new-york-city-housing-and-vacancy-survey-nychvs.html"><a href="new-york-city-housing-and-vacancy-survey-nychvs.html#regression-models-and-tests-of-association-32"><i class="fa fa-check"></i>Regression Models and Tests of Association</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="new-york-city-housing-and-vacancy-survey-nychvs.html"><a href="new-york-city-housing-and-vacancy-survey-nychvs.html#replication-example-30"><i class="fa fa-check"></i>Replication Example</a></li>
<li class="chapter" data-level="" data-path="new-york-city-housing-and-vacancy-survey-nychvs.html"><a href="new-york-city-housing-and-vacancy-survey-nychvs.html#analysis-examples-with-srvyr-22"><i class="fa fa-check"></i>Analysis Examples with <code>srvyr</code>  </a></li>
</ul></li>
<li class="chapter" data-level="" data-path="pew-research-center-pew.html"><a href="pew-research-center-pew.html"><i class="fa fa-check"></i>Pew Research Center (PEW)</a>
<ul>
<li class="chapter" data-level="" data-path="pew-research-center-pew.html"><a href="pew-research-center-pew.html#download-import-preparation-34"><i class="fa fa-check"></i>Download, Import, Preparation</a>
<ul>
<li class="chapter" data-level="" data-path="pew-research-center-pew.html"><a href="pew-research-center-pew.html#save-locally-33"><i class="fa fa-check"></i>Save Locally  </a></li>
<li class="chapter" data-level="" data-path="pew-research-center-pew.html"><a href="pew-research-center-pew.html#survey-design-definition-26"><i class="fa fa-check"></i>Survey Design Definition</a></li>
<li class="chapter" data-level="" data-path="pew-research-center-pew.html"><a href="pew-research-center-pew.html#variable-recoding-33"><i class="fa fa-check"></i>Variable Recoding</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="pew-research-center-pew.html"><a href="pew-research-center-pew.html#analysis-examples-with-the-survey-library-26"><i class="fa fa-check"></i>Analysis Examples with the <code>survey</code> library  </a>
<ul>
<li class="chapter" data-level="" data-path="pew-research-center-pew.html"><a href="pew-research-center-pew.html#unweighted-counts-33"><i class="fa fa-check"></i>Unweighted Counts</a></li>
<li class="chapter" data-level="" data-path="pew-research-center-pew.html"><a href="pew-research-center-pew.html#weighted-counts-26"><i class="fa fa-check"></i>Weighted Counts</a></li>
<li class="chapter" data-level="" data-path="pew-research-center-pew.html"><a href="pew-research-center-pew.html#descriptive-statistics-33"><i class="fa fa-check"></i>Descriptive Statistics</a></li>
<li class="chapter" data-level="" data-path="pew-research-center-pew.html"><a href="pew-research-center-pew.html#subsetting-33"><i class="fa fa-check"></i>Subsetting</a></li>
<li class="chapter" data-level="" data-path="pew-research-center-pew.html"><a href="pew-research-center-pew.html#measures-of-uncertainty-33"><i class="fa fa-check"></i>Measures of Uncertainty</a></li>
<li class="chapter" data-level="" data-path="pew-research-center-pew.html"><a href="pew-research-center-pew.html#regression-models-and-tests-of-association-33"><i class="fa fa-check"></i>Regression Models and Tests of Association</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="pew-research-center-pew.html"><a href="pew-research-center-pew.html#replication-example-31"><i class="fa fa-check"></i>Replication Example</a></li>
<li class="chapter" data-level="" data-path="pew-research-center-pew.html"><a href="pew-research-center-pew.html#analysis-examples-with-srvyr-23"><i class="fa fa-check"></i>Analysis Examples with <code>srvyr</code>  </a></li>
</ul></li>
<li class="chapter" data-level="" data-path="programme-for-the-international-assessment-of-adult-competencies-piaac.html"><a href="programme-for-the-international-assessment-of-adult-competencies-piaac.html"><i class="fa fa-check"></i>Programme for the International Assessment of Adult Competencies (PIAAC)</a>
<ul>
<li class="chapter" data-level="" data-path="programme-for-the-international-assessment-of-adult-competencies-piaac.html"><a href="programme-for-the-international-assessment-of-adult-competencies-piaac.html#download-import-preparation-35"><i class="fa fa-check"></i>Download, Import, Preparation</a>
<ul>
<li class="chapter" data-level="" data-path="programme-for-the-international-assessment-of-adult-competencies-piaac.html"><a href="programme-for-the-international-assessment-of-adult-competencies-piaac.html#save-locally-34"><i class="fa fa-check"></i>Save Locally  </a></li>
<li class="chapter" data-level="" data-path="programme-for-the-international-assessment-of-adult-competencies-piaac.html"><a href="programme-for-the-international-assessment-of-adult-competencies-piaac.html#survey-design-definition-27"><i class="fa fa-check"></i>Survey Design Definition</a></li>
<li class="chapter" data-level="" data-path="programme-for-the-international-assessment-of-adult-competencies-piaac.html"><a href="programme-for-the-international-assessment-of-adult-competencies-piaac.html#variable-recoding-34"><i class="fa fa-check"></i>Variable Recoding</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="programme-for-the-international-assessment-of-adult-competencies-piaac.html"><a href="programme-for-the-international-assessment-of-adult-competencies-piaac.html#analysis-examples-with-the-survey-library-27"><i class="fa fa-check"></i>Analysis Examples with the <code>survey</code> library  </a>
<ul>
<li class="chapter" data-level="" data-path="programme-for-the-international-assessment-of-adult-competencies-piaac.html"><a href="programme-for-the-international-assessment-of-adult-competencies-piaac.html#unweighted-counts-34"><i class="fa fa-check"></i>Unweighted Counts</a></li>
<li class="chapter" data-level="" data-path="programme-for-the-international-assessment-of-adult-competencies-piaac.html"><a href="programme-for-the-international-assessment-of-adult-competencies-piaac.html#weighted-counts-27"><i class="fa fa-check"></i>Weighted Counts</a></li>
<li class="chapter" data-level="" data-path="programme-for-the-international-assessment-of-adult-competencies-piaac.html"><a href="programme-for-the-international-assessment-of-adult-competencies-piaac.html#descriptive-statistics-34"><i class="fa fa-check"></i>Descriptive Statistics</a></li>
<li class="chapter" data-level="" data-path="programme-for-the-international-assessment-of-adult-competencies-piaac.html"><a href="programme-for-the-international-assessment-of-adult-competencies-piaac.html#subsetting-34"><i class="fa fa-check"></i>Subsetting</a></li>
<li class="chapter" data-level="" data-path="programme-for-the-international-assessment-of-adult-competencies-piaac.html"><a href="programme-for-the-international-assessment-of-adult-competencies-piaac.html#measures-of-uncertainty-34"><i class="fa fa-check"></i>Measures of Uncertainty</a></li>
<li class="chapter" data-level="" data-path="programme-for-the-international-assessment-of-adult-competencies-piaac.html"><a href="programme-for-the-international-assessment-of-adult-competencies-piaac.html#regression-models-and-tests-of-association-34"><i class="fa fa-check"></i>Regression Models and Tests of Association</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="programme-for-the-international-assessment-of-adult-competencies-piaac.html"><a href="programme-for-the-international-assessment-of-adult-competencies-piaac.html#replication-example-32"><i class="fa fa-check"></i>Replication Example</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="progress-in-international-reading-literacy-study-pirls.html"><a href="progress-in-international-reading-literacy-study-pirls.html"><i class="fa fa-check"></i>Progress in International Reading Literacy Study (PIRLS)</a>
<ul>
<li class="chapter" data-level="" data-path="progress-in-international-reading-literacy-study-pirls.html"><a href="progress-in-international-reading-literacy-study-pirls.html#function-definitions-9"><i class="fa fa-check"></i>Function Definitions</a></li>
<li class="chapter" data-level="" data-path="progress-in-international-reading-literacy-study-pirls.html"><a href="progress-in-international-reading-literacy-study-pirls.html#download-import-preparation-36"><i class="fa fa-check"></i>Download, Import, Preparation</a>
<ul>
<li class="chapter" data-level="" data-path="progress-in-international-reading-literacy-study-pirls.html"><a href="progress-in-international-reading-literacy-study-pirls.html#save-locally-35"><i class="fa fa-check"></i>Save Locally  </a></li>
<li class="chapter" data-level="" data-path="progress-in-international-reading-literacy-study-pirls.html"><a href="progress-in-international-reading-literacy-study-pirls.html#survey-design-definition-28"><i class="fa fa-check"></i>Survey Design Definition</a></li>
<li class="chapter" data-level="" data-path="progress-in-international-reading-literacy-study-pirls.html"><a href="progress-in-international-reading-literacy-study-pirls.html#variable-recoding-35"><i class="fa fa-check"></i>Variable Recoding</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="progress-in-international-reading-literacy-study-pirls.html"><a href="progress-in-international-reading-literacy-study-pirls.html#analysis-examples-with-the-survey-library-28"><i class="fa fa-check"></i>Analysis Examples with the <code>survey</code> library  </a>
<ul>
<li class="chapter" data-level="" data-path="progress-in-international-reading-literacy-study-pirls.html"><a href="progress-in-international-reading-literacy-study-pirls.html#unweighted-counts-35"><i class="fa fa-check"></i>Unweighted Counts</a></li>
<li class="chapter" data-level="" data-path="progress-in-international-reading-literacy-study-pirls.html"><a href="progress-in-international-reading-literacy-study-pirls.html#weighted-counts-28"><i class="fa fa-check"></i>Weighted Counts</a></li>
<li class="chapter" data-level="" data-path="progress-in-international-reading-literacy-study-pirls.html"><a href="progress-in-international-reading-literacy-study-pirls.html#descriptive-statistics-35"><i class="fa fa-check"></i>Descriptive Statistics</a></li>
<li class="chapter" data-level="" data-path="progress-in-international-reading-literacy-study-pirls.html"><a href="progress-in-international-reading-literacy-study-pirls.html#subsetting-35"><i class="fa fa-check"></i>Subsetting</a></li>
<li class="chapter" data-level="" data-path="progress-in-international-reading-literacy-study-pirls.html"><a href="progress-in-international-reading-literacy-study-pirls.html#measures-of-uncertainty-35"><i class="fa fa-check"></i>Measures of Uncertainty</a></li>
<li class="chapter" data-level="" data-path="progress-in-international-reading-literacy-study-pirls.html"><a href="progress-in-international-reading-literacy-study-pirls.html#regression-models-and-tests-of-association-35"><i class="fa fa-check"></i>Regression Models and Tests of Association</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="progress-in-international-reading-literacy-study-pirls.html"><a href="progress-in-international-reading-literacy-study-pirls.html#replication-example-33"><i class="fa fa-check"></i>Replication Example</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="public-libraries-survey-pls.html"><a href="public-libraries-survey-pls.html"><i class="fa fa-check"></i>Public Libraries Survey (PLS)</a>
<ul>
<li class="chapter" data-level="" data-path="public-libraries-survey-pls.html"><a href="public-libraries-survey-pls.html#download-import-preparation-37"><i class="fa fa-check"></i>Download, Import, Preparation</a>
<ul>
<li class="chapter" data-level="" data-path="public-libraries-survey-pls.html"><a href="public-libraries-survey-pls.html#save-locally-36"><i class="fa fa-check"></i>Save Locally  </a></li>
<li class="chapter" data-level="" data-path="public-libraries-survey-pls.html"><a href="public-libraries-survey-pls.html#variable-recoding-36"><i class="fa fa-check"></i>Variable Recoding</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="public-libraries-survey-pls.html"><a href="public-libraries-survey-pls.html#analysis-examples-with-base-r-7"><i class="fa fa-check"></i>Analysis Examples with base R  </a>
<ul>
<li class="chapter" data-level="" data-path="public-libraries-survey-pls.html"><a href="public-libraries-survey-pls.html#unweighted-counts-36"><i class="fa fa-check"></i>Unweighted Counts</a></li>
<li class="chapter" data-level="" data-path="public-libraries-survey-pls.html"><a href="public-libraries-survey-pls.html#descriptive-statistics-36"><i class="fa fa-check"></i>Descriptive Statistics</a></li>
<li class="chapter" data-level="" data-path="public-libraries-survey-pls.html"><a href="public-libraries-survey-pls.html#subsetting-36"><i class="fa fa-check"></i>Subsetting</a></li>
<li class="chapter" data-level="" data-path="public-libraries-survey-pls.html"><a href="public-libraries-survey-pls.html#measures-of-uncertainty-36"><i class="fa fa-check"></i>Measures of Uncertainty</a></li>
<li class="chapter" data-level="" data-path="public-libraries-survey-pls.html"><a href="public-libraries-survey-pls.html#regression-models-and-tests-of-association-36"><i class="fa fa-check"></i>Regression Models and Tests of Association</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="public-libraries-survey-pls.html"><a href="public-libraries-survey-pls.html#replication-example-34"><i class="fa fa-check"></i>Replication Example</a></li>
<li class="chapter" data-level="" data-path="public-libraries-survey-pls.html"><a href="public-libraries-survey-pls.html#analysis-examples-with-dplyr-7"><i class="fa fa-check"></i>Analysis Examples with <code>dplyr</code>  </a></li>
<li class="chapter" data-level="" data-path="public-libraries-survey-pls.html"><a href="public-libraries-survey-pls.html#analysis-examples-with-data.table-7"><i class="fa fa-check"></i>Analysis Examples with <code>data.table</code>  </a></li>
<li class="chapter" data-level="" data-path="public-libraries-survey-pls.html"><a href="public-libraries-survey-pls.html#analysis-examples-with-duckdb-7"><i class="fa fa-check"></i>Analysis Examples with <code>duckdb</code>  </a></li>
</ul></li>
<li class="chapter" data-level="" data-path="pesquisa-nacional-por-amostra-de-domicilios-pnad.html"><a href="pesquisa-nacional-por-amostra-de-domicilios-pnad.html"><i class="fa fa-check"></i>Pesquisa Nacional por Amostra de Domicilios (PNAD)</a>
<ul>
<li class="chapter" data-level="" data-path="pesquisa-nacional-por-amostra-de-domicilios-pnad.html"><a href="pesquisa-nacional-por-amostra-de-domicilios-pnad.html#download-import-preparation-38"><i class="fa fa-check"></i>Download, Import, Preparation</a>
<ul>
<li class="chapter" data-level="" data-path="pesquisa-nacional-por-amostra-de-domicilios-pnad.html"><a href="pesquisa-nacional-por-amostra-de-domicilios-pnad.html#save-locally-37"><i class="fa fa-check"></i>Save Locally  </a></li>
<li class="chapter" data-level="" data-path="pesquisa-nacional-por-amostra-de-domicilios-pnad.html"><a href="pesquisa-nacional-por-amostra-de-domicilios-pnad.html#survey-design-definition-29"><i class="fa fa-check"></i>Survey Design Definition</a></li>
<li class="chapter" data-level="" data-path="pesquisa-nacional-por-amostra-de-domicilios-pnad.html"><a href="pesquisa-nacional-por-amostra-de-domicilios-pnad.html#variable-recoding-37"><i class="fa fa-check"></i>Variable Recoding</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="pesquisa-nacional-por-amostra-de-domicilios-pnad.html"><a href="pesquisa-nacional-por-amostra-de-domicilios-pnad.html#analysis-examples-with-the-survey-library-29"><i class="fa fa-check"></i>Analysis Examples with the <code>survey</code> library  </a>
<ul>
<li class="chapter" data-level="" data-path="pesquisa-nacional-por-amostra-de-domicilios-pnad.html"><a href="pesquisa-nacional-por-amostra-de-domicilios-pnad.html#unweighted-counts-37"><i class="fa fa-check"></i>Unweighted Counts</a></li>
<li class="chapter" data-level="" data-path="pesquisa-nacional-por-amostra-de-domicilios-pnad.html"><a href="pesquisa-nacional-por-amostra-de-domicilios-pnad.html#weighted-counts-29"><i class="fa fa-check"></i>Weighted Counts</a></li>
<li class="chapter" data-level="" data-path="pesquisa-nacional-por-amostra-de-domicilios-pnad.html"><a href="pesquisa-nacional-por-amostra-de-domicilios-pnad.html#descriptive-statistics-37"><i class="fa fa-check"></i>Descriptive Statistics</a></li>
<li class="chapter" data-level="" data-path="pesquisa-nacional-por-amostra-de-domicilios-pnad.html"><a href="pesquisa-nacional-por-amostra-de-domicilios-pnad.html#subsetting-37"><i class="fa fa-check"></i>Subsetting</a></li>
<li class="chapter" data-level="" data-path="pesquisa-nacional-por-amostra-de-domicilios-pnad.html"><a href="pesquisa-nacional-por-amostra-de-domicilios-pnad.html#measures-of-uncertainty-37"><i class="fa fa-check"></i>Measures of Uncertainty</a></li>
<li class="chapter" data-level="" data-path="pesquisa-nacional-por-amostra-de-domicilios-pnad.html"><a href="pesquisa-nacional-por-amostra-de-domicilios-pnad.html#regression-models-and-tests-of-association-37"><i class="fa fa-check"></i>Regression Models and Tests of Association</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="pesquisa-nacional-por-amostra-de-domicilios-pnad.html"><a href="pesquisa-nacional-por-amostra-de-domicilios-pnad.html#replication-example-35"><i class="fa fa-check"></i>Replication Example</a></li>
<li class="chapter" data-level="" data-path="pesquisa-nacional-por-amostra-de-domicilios-pnad.html"><a href="pesquisa-nacional-por-amostra-de-domicilios-pnad.html#poverty-and-inequality-estimation-with-convey-2"><i class="fa fa-check"></i>Poverty and Inequality Estimation with <code>convey</code>  </a></li>
<li class="chapter" data-level="" data-path="pesquisa-nacional-por-amostra-de-domicilios-pnad.html"><a href="pesquisa-nacional-por-amostra-de-domicilios-pnad.html#analysis-examples-with-srvyr-24"><i class="fa fa-check"></i>Analysis Examples with <code>srvyr</code>  </a></li>
</ul></li>
<li class="chapter" data-level="" data-path="pesquisa-nacional-de-saude-pns.html"><a href="pesquisa-nacional-de-saude-pns.html"><i class="fa fa-check"></i>Pesquisa Nacional de Saude (PNS)</a>
<ul>
<li class="chapter" data-level="" data-path="pesquisa-nacional-de-saude-pns.html"><a href="pesquisa-nacional-de-saude-pns.html#download-import-preparation-39"><i class="fa fa-check"></i>Download, Import, Preparation</a>
<ul>
<li class="chapter" data-level="" data-path="pesquisa-nacional-de-saude-pns.html"><a href="pesquisa-nacional-de-saude-pns.html#save-locally-38"><i class="fa fa-check"></i>Save Locally  </a></li>
<li class="chapter" data-level="" data-path="pesquisa-nacional-de-saude-pns.html"><a href="pesquisa-nacional-de-saude-pns.html#survey-design-definition-30"><i class="fa fa-check"></i>Survey Design Definition</a></li>
<li class="chapter" data-level="" data-path="pesquisa-nacional-de-saude-pns.html"><a href="pesquisa-nacional-de-saude-pns.html#variable-recoding-38"><i class="fa fa-check"></i>Variable Recoding</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="pesquisa-nacional-de-saude-pns.html"><a href="pesquisa-nacional-de-saude-pns.html#analysis-examples-with-the-survey-library-30"><i class="fa fa-check"></i>Analysis Examples with the <code>survey</code> library  </a>
<ul>
<li class="chapter" data-level="" data-path="pesquisa-nacional-de-saude-pns.html"><a href="pesquisa-nacional-de-saude-pns.html#unweighted-counts-38"><i class="fa fa-check"></i>Unweighted Counts</a></li>
<li class="chapter" data-level="" data-path="pesquisa-nacional-de-saude-pns.html"><a href="pesquisa-nacional-de-saude-pns.html#weighted-counts-30"><i class="fa fa-check"></i>Weighted Counts</a></li>
<li class="chapter" data-level="" data-path="pesquisa-nacional-de-saude-pns.html"><a href="pesquisa-nacional-de-saude-pns.html#descriptive-statistics-38"><i class="fa fa-check"></i>Descriptive Statistics</a></li>
<li class="chapter" data-level="" data-path="pesquisa-nacional-de-saude-pns.html"><a href="pesquisa-nacional-de-saude-pns.html#subsetting-38"><i class="fa fa-check"></i>Subsetting</a></li>
<li class="chapter" data-level="" data-path="pesquisa-nacional-de-saude-pns.html"><a href="pesquisa-nacional-de-saude-pns.html#measures-of-uncertainty-38"><i class="fa fa-check"></i>Measures of Uncertainty</a></li>
<li class="chapter" data-level="" data-path="pesquisa-nacional-de-saude-pns.html"><a href="pesquisa-nacional-de-saude-pns.html#regression-models-and-tests-of-association-38"><i class="fa fa-check"></i>Regression Models and Tests of Association</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="pesquisa-nacional-de-saude-pns.html"><a href="pesquisa-nacional-de-saude-pns.html#replication-example-36"><i class="fa fa-check"></i>Replication Example</a></li>
<li class="chapter" data-level="" data-path="pesquisa-nacional-de-saude-pns.html"><a href="pesquisa-nacional-de-saude-pns.html#analysis-examples-with-srvyr-25"><i class="fa fa-check"></i>Analysis Examples with <code>srvyr</code>  </a></li>
</ul></li>
<li class="chapter" data-level="" data-path="pesquisa-de-orcamentos-familiares-pof.html"><a href="pesquisa-de-orcamentos-familiares-pof.html"><i class="fa fa-check"></i>Pesquisa de Orcamentos Familiares (POF)</a>
<ul>
<li class="chapter" data-level="" data-path="pesquisa-de-orcamentos-familiares-pof.html"><a href="pesquisa-de-orcamentos-familiares-pof.html#download-import-preparation-40"><i class="fa fa-check"></i>Download, Import, Preparation</a>
<ul>
<li class="chapter" data-level="" data-path="pesquisa-de-orcamentos-familiares-pof.html"><a href="pesquisa-de-orcamentos-familiares-pof.html#save-locally-39"><i class="fa fa-check"></i>Save Locally  </a></li>
<li class="chapter" data-level="" data-path="pesquisa-de-orcamentos-familiares-pof.html"><a href="pesquisa-de-orcamentos-familiares-pof.html#survey-design-definition-31"><i class="fa fa-check"></i>Survey Design Definition</a></li>
<li class="chapter" data-level="" data-path="pesquisa-de-orcamentos-familiares-pof.html"><a href="pesquisa-de-orcamentos-familiares-pof.html#variable-recoding-39"><i class="fa fa-check"></i>Variable Recoding</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="pesquisa-de-orcamentos-familiares-pof.html"><a href="pesquisa-de-orcamentos-familiares-pof.html#analysis-examples-with-the-survey-library-31"><i class="fa fa-check"></i>Analysis Examples with the <code>survey</code> library  </a>
<ul>
<li class="chapter" data-level="" data-path="pesquisa-de-orcamentos-familiares-pof.html"><a href="pesquisa-de-orcamentos-familiares-pof.html#unweighted-counts-39"><i class="fa fa-check"></i>Unweighted Counts</a></li>
<li class="chapter" data-level="" data-path="pesquisa-de-orcamentos-familiares-pof.html"><a href="pesquisa-de-orcamentos-familiares-pof.html#weighted-counts-31"><i class="fa fa-check"></i>Weighted Counts</a></li>
<li class="chapter" data-level="" data-path="pesquisa-de-orcamentos-familiares-pof.html"><a href="pesquisa-de-orcamentos-familiares-pof.html#descriptive-statistics-39"><i class="fa fa-check"></i>Descriptive Statistics</a></li>
<li class="chapter" data-level="" data-path="pesquisa-de-orcamentos-familiares-pof.html"><a href="pesquisa-de-orcamentos-familiares-pof.html#subsetting-39"><i class="fa fa-check"></i>Subsetting</a></li>
<li class="chapter" data-level="" data-path="pesquisa-de-orcamentos-familiares-pof.html"><a href="pesquisa-de-orcamentos-familiares-pof.html#measures-of-uncertainty-39"><i class="fa fa-check"></i>Measures of Uncertainty</a></li>
<li class="chapter" data-level="" data-path="pesquisa-de-orcamentos-familiares-pof.html"><a href="pesquisa-de-orcamentos-familiares-pof.html#regression-models-and-tests-of-association-39"><i class="fa fa-check"></i>Regression Models and Tests of Association</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="pesquisa-de-orcamentos-familiares-pof.html"><a href="pesquisa-de-orcamentos-familiares-pof.html#replication-example-37"><i class="fa fa-check"></i>Replication Example</a></li>
<li class="chapter" data-level="" data-path="pesquisa-de-orcamentos-familiares-pof.html"><a href="pesquisa-de-orcamentos-familiares-pof.html#poverty-and-inequality-estimation-with-convey-3"><i class="fa fa-check"></i>Poverty and Inequality Estimation with <code>convey</code>  </a></li>
<li class="chapter" data-level="" data-path="pesquisa-de-orcamentos-familiares-pof.html"><a href="pesquisa-de-orcamentos-familiares-pof.html#analysis-examples-with-srvyr-26"><i class="fa fa-check"></i>Analysis Examples with <code>srvyr</code>  </a></li>
</ul></li>
<li class="chapter" data-level="" data-path="residential-energy-consumption-survey-recs.html"><a href="residential-energy-consumption-survey-recs.html"><i class="fa fa-check"></i>Residential Energy Consumption Survey (RECS)</a>
<ul>
<li class="chapter" data-level="" data-path="residential-energy-consumption-survey-recs.html"><a href="residential-energy-consumption-survey-recs.html#download-import-preparation-41"><i class="fa fa-check"></i>Download, Import, Preparation</a>
<ul>
<li class="chapter" data-level="" data-path="residential-energy-consumption-survey-recs.html"><a href="residential-energy-consumption-survey-recs.html#save-locally-40"><i class="fa fa-check"></i>Save Locally  </a></li>
<li class="chapter" data-level="" data-path="residential-energy-consumption-survey-recs.html"><a href="residential-energy-consumption-survey-recs.html#survey-design-definition-32"><i class="fa fa-check"></i>Survey Design Definition</a></li>
<li class="chapter" data-level="" data-path="residential-energy-consumption-survey-recs.html"><a href="residential-energy-consumption-survey-recs.html#variable-recoding-40"><i class="fa fa-check"></i>Variable Recoding</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="residential-energy-consumption-survey-recs.html"><a href="residential-energy-consumption-survey-recs.html#analysis-examples-with-the-survey-library-32"><i class="fa fa-check"></i>Analysis Examples with the <code>survey</code> library  </a>
<ul>
<li class="chapter" data-level="" data-path="residential-energy-consumption-survey-recs.html"><a href="residential-energy-consumption-survey-recs.html#unweighted-counts-40"><i class="fa fa-check"></i>Unweighted Counts</a></li>
<li class="chapter" data-level="" data-path="residential-energy-consumption-survey-recs.html"><a href="residential-energy-consumption-survey-recs.html#weighted-counts-32"><i class="fa fa-check"></i>Weighted Counts</a></li>
<li class="chapter" data-level="" data-path="residential-energy-consumption-survey-recs.html"><a href="residential-energy-consumption-survey-recs.html#descriptive-statistics-40"><i class="fa fa-check"></i>Descriptive Statistics</a></li>
<li class="chapter" data-level="" data-path="residential-energy-consumption-survey-recs.html"><a href="residential-energy-consumption-survey-recs.html#subsetting-40"><i class="fa fa-check"></i>Subsetting</a></li>
<li class="chapter" data-level="" data-path="residential-energy-consumption-survey-recs.html"><a href="residential-energy-consumption-survey-recs.html#measures-of-uncertainty-40"><i class="fa fa-check"></i>Measures of Uncertainty</a></li>
<li class="chapter" data-level="" data-path="residential-energy-consumption-survey-recs.html"><a href="residential-energy-consumption-survey-recs.html#regression-models-and-tests-of-association-40"><i class="fa fa-check"></i>Regression Models and Tests of Association</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="residential-energy-consumption-survey-recs.html"><a href="residential-energy-consumption-survey-recs.html#replication-example-38"><i class="fa fa-check"></i>Replication Example</a></li>
<li class="chapter" data-level="" data-path="residential-energy-consumption-survey-recs.html"><a href="residential-energy-consumption-survey-recs.html#analysis-examples-with-srvyr-27"><i class="fa fa-check"></i>Analysis Examples with <code>srvyr</code>  </a></li>
</ul></li>
<li class="chapter" data-level="" data-path="rapid-surveys-system-rss.html"><a href="rapid-surveys-system-rss.html"><i class="fa fa-check"></i>Rapid Surveys System (RSS)</a>
<ul>
<li class="chapter" data-level="" data-path="rapid-surveys-system-rss.html"><a href="rapid-surveys-system-rss.html#download-import-preparation-42"><i class="fa fa-check"></i>Download, Import, Preparation</a>
<ul>
<li class="chapter" data-level="" data-path="rapid-surveys-system-rss.html"><a href="rapid-surveys-system-rss.html#save-locally-41"><i class="fa fa-check"></i>Save Locally  </a></li>
<li class="chapter" data-level="" data-path="rapid-surveys-system-rss.html"><a href="rapid-surveys-system-rss.html#survey-design-definition-33"><i class="fa fa-check"></i>Survey Design Definition</a></li>
<li class="chapter" data-level="" data-path="rapid-surveys-system-rss.html"><a href="rapid-surveys-system-rss.html#variable-recoding-41"><i class="fa fa-check"></i>Variable Recoding</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="rapid-surveys-system-rss.html"><a href="rapid-surveys-system-rss.html#analysis-examples-with-the-survey-library-33"><i class="fa fa-check"></i>Analysis Examples with the <code>survey</code> library  </a>
<ul>
<li class="chapter" data-level="" data-path="rapid-surveys-system-rss.html"><a href="rapid-surveys-system-rss.html#unweighted-counts-41"><i class="fa fa-check"></i>Unweighted Counts</a></li>
<li class="chapter" data-level="" data-path="rapid-surveys-system-rss.html"><a href="rapid-surveys-system-rss.html#weighted-counts-33"><i class="fa fa-check"></i>Weighted Counts</a></li>
<li class="chapter" data-level="" data-path="rapid-surveys-system-rss.html"><a href="rapid-surveys-system-rss.html#descriptive-statistics-41"><i class="fa fa-check"></i>Descriptive Statistics</a></li>
<li class="chapter" data-level="" data-path="rapid-surveys-system-rss.html"><a href="rapid-surveys-system-rss.html#subsetting-41"><i class="fa fa-check"></i>Subsetting</a></li>
<li class="chapter" data-level="" data-path="rapid-surveys-system-rss.html"><a href="rapid-surveys-system-rss.html#measures-of-uncertainty-41"><i class="fa fa-check"></i>Measures of Uncertainty</a></li>
<li class="chapter" data-level="" data-path="rapid-surveys-system-rss.html"><a href="rapid-surveys-system-rss.html#regression-models-and-tests-of-association-41"><i class="fa fa-check"></i>Regression Models and Tests of Association</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="rapid-surveys-system-rss.html"><a href="rapid-surveys-system-rss.html#replication-example-39"><i class="fa fa-check"></i>Replication Example</a></li>
<li class="chapter" data-level="" data-path="rapid-surveys-system-rss.html"><a href="rapid-surveys-system-rss.html#analysis-examples-with-srvyr-28"><i class="fa fa-check"></i>Analysis Examples with <code>srvyr</code>  </a></li>
</ul></li>
<li class="chapter" data-level="" data-path="survey-of-business-owners-sbo.html"><a href="survey-of-business-owners-sbo.html"><i class="fa fa-check"></i>Survey of Business Owners (SBO)</a>
<ul>
<li class="chapter" data-level="" data-path="survey-of-business-owners-sbo.html"><a href="survey-of-business-owners-sbo.html#function-definitions-10"><i class="fa fa-check"></i>Function Definitions</a></li>
<li class="chapter" data-level="" data-path="survey-of-business-owners-sbo.html"><a href="survey-of-business-owners-sbo.html#download-import-preparation-43"><i class="fa fa-check"></i>Download, Import, Preparation</a>
<ul>
<li class="chapter" data-level="" data-path="survey-of-business-owners-sbo.html"><a href="survey-of-business-owners-sbo.html#save-locally-42"><i class="fa fa-check"></i>Save Locally  </a></li>
<li class="chapter" data-level="" data-path="survey-of-business-owners-sbo.html"><a href="survey-of-business-owners-sbo.html#survey-design-definition-34"><i class="fa fa-check"></i>Survey Design Definition</a></li>
<li class="chapter" data-level="" data-path="survey-of-business-owners-sbo.html"><a href="survey-of-business-owners-sbo.html#variable-recoding-42"><i class="fa fa-check"></i>Variable Recoding</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="survey-of-business-owners-sbo.html"><a href="survey-of-business-owners-sbo.html#analysis-examples-with-the-survey-library-34"><i class="fa fa-check"></i>Analysis Examples with the <code>survey</code> library  </a>
<ul>
<li class="chapter" data-level="" data-path="survey-of-business-owners-sbo.html"><a href="survey-of-business-owners-sbo.html#unweighted-counts-42"><i class="fa fa-check"></i>Unweighted Counts</a></li>
<li class="chapter" data-level="" data-path="survey-of-business-owners-sbo.html"><a href="survey-of-business-owners-sbo.html#weighted-counts-34"><i class="fa fa-check"></i>Weighted Counts</a></li>
<li class="chapter" data-level="" data-path="survey-of-business-owners-sbo.html"><a href="survey-of-business-owners-sbo.html#descriptive-statistics-42"><i class="fa fa-check"></i>Descriptive Statistics</a></li>
<li class="chapter" data-level="" data-path="survey-of-business-owners-sbo.html"><a href="survey-of-business-owners-sbo.html#subsetting-42"><i class="fa fa-check"></i>Subsetting</a></li>
<li class="chapter" data-level="" data-path="survey-of-business-owners-sbo.html"><a href="survey-of-business-owners-sbo.html#measures-of-uncertainty-42"><i class="fa fa-check"></i>Measures of Uncertainty</a></li>
<li class="chapter" data-level="" data-path="survey-of-business-owners-sbo.html"><a href="survey-of-business-owners-sbo.html#regression-models-and-tests-of-association-42"><i class="fa fa-check"></i>Regression Models and Tests of Association</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="survey-of-business-owners-sbo.html"><a href="survey-of-business-owners-sbo.html#replication-example-40"><i class="fa fa-check"></i>Replication Example</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="survey-of-consumer-finances-scf.html"><a href="survey-of-consumer-finances-scf.html"><i class="fa fa-check"></i>Survey of Consumer Finances (SCF)</a>
<ul>
<li class="chapter" data-level="" data-path="survey-of-consumer-finances-scf.html"><a href="survey-of-consumer-finances-scf.html#function-definitions-11"><i class="fa fa-check"></i>Function Definitions</a></li>
<li class="chapter" data-level="" data-path="survey-of-consumer-finances-scf.html"><a href="survey-of-consumer-finances-scf.html#download-import-preparation-44"><i class="fa fa-check"></i>Download, Import, Preparation</a>
<ul>
<li class="chapter" data-level="" data-path="survey-of-consumer-finances-scf.html"><a href="survey-of-consumer-finances-scf.html#save-locally-43"><i class="fa fa-check"></i>Save Locally  </a></li>
<li class="chapter" data-level="" data-path="survey-of-consumer-finances-scf.html"><a href="survey-of-consumer-finances-scf.html#survey-design-definition-35"><i class="fa fa-check"></i>Survey Design Definition</a></li>
<li class="chapter" data-level="" data-path="survey-of-consumer-finances-scf.html"><a href="survey-of-consumer-finances-scf.html#variable-recoding-43"><i class="fa fa-check"></i>Variable Recoding</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="survey-of-consumer-finances-scf.html"><a href="survey-of-consumer-finances-scf.html#analysis-examples-with-the-survey-library-35"><i class="fa fa-check"></i>Analysis Examples with the <code>survey</code> library  </a>
<ul>
<li class="chapter" data-level="" data-path="survey-of-consumer-finances-scf.html"><a href="survey-of-consumer-finances-scf.html#unweighted-counts-43"><i class="fa fa-check"></i>Unweighted Counts</a></li>
<li class="chapter" data-level="" data-path="survey-of-consumer-finances-scf.html"><a href="survey-of-consumer-finances-scf.html#weighted-counts-35"><i class="fa fa-check"></i>Weighted Counts</a></li>
<li class="chapter" data-level="" data-path="survey-of-consumer-finances-scf.html"><a href="survey-of-consumer-finances-scf.html#descriptive-statistics-43"><i class="fa fa-check"></i>Descriptive Statistics</a></li>
<li class="chapter" data-level="" data-path="survey-of-consumer-finances-scf.html"><a href="survey-of-consumer-finances-scf.html#subsetting-43"><i class="fa fa-check"></i>Subsetting</a></li>
<li class="chapter" data-level="" data-path="survey-of-consumer-finances-scf.html"><a href="survey-of-consumer-finances-scf.html#measures-of-uncertainty-43"><i class="fa fa-check"></i>Measures of Uncertainty</a></li>
<li class="chapter" data-level="" data-path="survey-of-consumer-finances-scf.html"><a href="survey-of-consumer-finances-scf.html#regression-models-and-tests-of-association-43"><i class="fa fa-check"></i>Regression Models and Tests of Association</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="survey-of-consumer-finances-scf.html"><a href="survey-of-consumer-finances-scf.html#replication-example-41"><i class="fa fa-check"></i>Replication Example</a></li>
<li class="chapter" data-level="" data-path="survey-of-consumer-finances-scf.html"><a href="survey-of-consumer-finances-scf.html#poverty-and-inequality-estimation-with-convey-4"><i class="fa fa-check"></i>Poverty and Inequality Estimation with <code>convey</code>  </a></li>
</ul></li>
<li class="chapter" data-level="" data-path="survey-of-income-and-program-participation-sipp.html"><a href="survey-of-income-and-program-participation-sipp.html"><i class="fa fa-check"></i>Survey of Income and Program Participation (SIPP)</a>
<ul>
<li class="chapter" data-level="" data-path="survey-of-income-and-program-participation-sipp.html"><a href="survey-of-income-and-program-participation-sipp.html#download-import-preparation-45"><i class="fa fa-check"></i>Download, Import, Preparation</a>
<ul>
<li class="chapter" data-level="" data-path="survey-of-income-and-program-participation-sipp.html"><a href="survey-of-income-and-program-participation-sipp.html#save-locally-44"><i class="fa fa-check"></i>Save Locally  </a></li>
<li class="chapter" data-level="" data-path="survey-of-income-and-program-participation-sipp.html"><a href="survey-of-income-and-program-participation-sipp.html#survey-design-definition-36"><i class="fa fa-check"></i>Survey Design Definition</a></li>
<li class="chapter" data-level="" data-path="survey-of-income-and-program-participation-sipp.html"><a href="survey-of-income-and-program-participation-sipp.html#variable-recoding-44"><i class="fa fa-check"></i>Variable Recoding</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="survey-of-income-and-program-participation-sipp.html"><a href="survey-of-income-and-program-participation-sipp.html#analysis-examples-with-the-survey-library-36"><i class="fa fa-check"></i>Analysis Examples with the <code>survey</code> library  </a>
<ul>
<li class="chapter" data-level="" data-path="survey-of-income-and-program-participation-sipp.html"><a href="survey-of-income-and-program-participation-sipp.html#unweighted-counts-44"><i class="fa fa-check"></i>Unweighted Counts</a></li>
<li class="chapter" data-level="" data-path="survey-of-income-and-program-participation-sipp.html"><a href="survey-of-income-and-program-participation-sipp.html#weighted-counts-36"><i class="fa fa-check"></i>Weighted Counts</a></li>
<li class="chapter" data-level="" data-path="survey-of-income-and-program-participation-sipp.html"><a href="survey-of-income-and-program-participation-sipp.html#descriptive-statistics-44"><i class="fa fa-check"></i>Descriptive Statistics</a></li>
<li class="chapter" data-level="" data-path="survey-of-income-and-program-participation-sipp.html"><a href="survey-of-income-and-program-participation-sipp.html#subsetting-44"><i class="fa fa-check"></i>Subsetting</a></li>
<li class="chapter" data-level="" data-path="survey-of-income-and-program-participation-sipp.html"><a href="survey-of-income-and-program-participation-sipp.html#measures-of-uncertainty-44"><i class="fa fa-check"></i>Measures of Uncertainty</a></li>
<li class="chapter" data-level="" data-path="survey-of-income-and-program-participation-sipp.html"><a href="survey-of-income-and-program-participation-sipp.html#regression-models-and-tests-of-association-44"><i class="fa fa-check"></i>Regression Models and Tests of Association</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="survey-of-income-and-program-participation-sipp.html"><a href="survey-of-income-and-program-participation-sipp.html#replication-example-42"><i class="fa fa-check"></i>Replication Example</a></li>
<li class="chapter" data-level="" data-path="survey-of-income-and-program-participation-sipp.html"><a href="survey-of-income-and-program-participation-sipp.html#poverty-and-inequality-estimation-with-convey-5"><i class="fa fa-check"></i>Poverty and Inequality Estimation with <code>convey</code>  </a></li>
<li class="chapter" data-level="" data-path="survey-of-income-and-program-participation-sipp.html"><a href="survey-of-income-and-program-participation-sipp.html#analysis-examples-with-srvyr-29"><i class="fa fa-check"></i>Analysis Examples with <code>srvyr</code>  </a></li>
</ul></li>
<li class="chapter" data-level="" data-path="social-security-public-use-data-files-ssa.html"><a href="social-security-public-use-data-files-ssa.html"><i class="fa fa-check"></i>Social Security Public-Use Data Files (SSA)</a>
<ul>
<li class="chapter" data-level="" data-path="social-security-public-use-data-files-ssa.html"><a href="social-security-public-use-data-files-ssa.html#download-import-preparation-46"><i class="fa fa-check"></i>Download, Import, Preparation</a>
<ul>
<li class="chapter" data-level="" data-path="social-security-public-use-data-files-ssa.html"><a href="social-security-public-use-data-files-ssa.html#save-locally-45"><i class="fa fa-check"></i>Save Locally  </a></li>
<li class="chapter" data-level="" data-path="social-security-public-use-data-files-ssa.html"><a href="social-security-public-use-data-files-ssa.html#variable-recoding-45"><i class="fa fa-check"></i>Variable Recoding</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="social-security-public-use-data-files-ssa.html"><a href="social-security-public-use-data-files-ssa.html#analysis-examples-with-base-r-8"><i class="fa fa-check"></i>Analysis Examples with base R  </a>
<ul>
<li class="chapter" data-level="" data-path="social-security-public-use-data-files-ssa.html"><a href="social-security-public-use-data-files-ssa.html#unweighted-counts-45"><i class="fa fa-check"></i>Unweighted Counts</a></li>
<li class="chapter" data-level="" data-path="social-security-public-use-data-files-ssa.html"><a href="social-security-public-use-data-files-ssa.html#descriptive-statistics-45"><i class="fa fa-check"></i>Descriptive Statistics</a></li>
<li class="chapter" data-level="" data-path="social-security-public-use-data-files-ssa.html"><a href="social-security-public-use-data-files-ssa.html#subsetting-45"><i class="fa fa-check"></i>Subsetting</a></li>
<li class="chapter" data-level="" data-path="social-security-public-use-data-files-ssa.html"><a href="social-security-public-use-data-files-ssa.html#measures-of-uncertainty-45"><i class="fa fa-check"></i>Measures of Uncertainty</a></li>
<li class="chapter" data-level="" data-path="social-security-public-use-data-files-ssa.html"><a href="social-security-public-use-data-files-ssa.html#regression-models-and-tests-of-association-45"><i class="fa fa-check"></i>Regression Models and Tests of Association</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="social-security-public-use-data-files-ssa.html"><a href="social-security-public-use-data-files-ssa.html#replication-example-43"><i class="fa fa-check"></i>Replication Example</a></li>
<li class="chapter" data-level="" data-path="social-security-public-use-data-files-ssa.html"><a href="social-security-public-use-data-files-ssa.html#analysis-examples-with-dplyr-8"><i class="fa fa-check"></i>Analysis Examples with <code>dplyr</code>  </a></li>
<li class="chapter" data-level="" data-path="social-security-public-use-data-files-ssa.html"><a href="social-security-public-use-data-files-ssa.html#analysis-examples-with-data.table-8"><i class="fa fa-check"></i>Analysis Examples with <code>data.table</code>  </a></li>
<li class="chapter" data-level="" data-path="social-security-public-use-data-files-ssa.html"><a href="social-security-public-use-data-files-ssa.html#analysis-examples-with-duckdb-8"><i class="fa fa-check"></i>Analysis Examples with <code>duckdb</code>  </a></li>
</ul></li>
<li class="chapter" data-level="" data-path="trends-in-international-mathematics-and-science-study-timss.html"><a href="trends-in-international-mathematics-and-science-study-timss.html"><i class="fa fa-check"></i>Trends in International Mathematics and Science Study (TIMSS)</a>
<ul>
<li class="chapter" data-level="" data-path="trends-in-international-mathematics-and-science-study-timss.html"><a href="trends-in-international-mathematics-and-science-study-timss.html#function-definitions-12"><i class="fa fa-check"></i>Function Definitions</a></li>
<li class="chapter" data-level="" data-path="trends-in-international-mathematics-and-science-study-timss.html"><a href="trends-in-international-mathematics-and-science-study-timss.html#download-import-preparation-47"><i class="fa fa-check"></i>Download, Import, Preparation</a>
<ul>
<li class="chapter" data-level="" data-path="trends-in-international-mathematics-and-science-study-timss.html"><a href="trends-in-international-mathematics-and-science-study-timss.html#save-locally-46"><i class="fa fa-check"></i>Save Locally  </a></li>
<li class="chapter" data-level="" data-path="trends-in-international-mathematics-and-science-study-timss.html"><a href="trends-in-international-mathematics-and-science-study-timss.html#survey-design-definition-37"><i class="fa fa-check"></i>Survey Design Definition</a></li>
<li class="chapter" data-level="" data-path="trends-in-international-mathematics-and-science-study-timss.html"><a href="trends-in-international-mathematics-and-science-study-timss.html#variable-recoding-46"><i class="fa fa-check"></i>Variable Recoding</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="trends-in-international-mathematics-and-science-study-timss.html"><a href="trends-in-international-mathematics-and-science-study-timss.html#analysis-examples-with-the-survey-library-37"><i class="fa fa-check"></i>Analysis Examples with the <code>survey</code> library  </a>
<ul>
<li class="chapter" data-level="" data-path="trends-in-international-mathematics-and-science-study-timss.html"><a href="trends-in-international-mathematics-and-science-study-timss.html#unweighted-counts-46"><i class="fa fa-check"></i>Unweighted Counts</a></li>
<li class="chapter" data-level="" data-path="trends-in-international-mathematics-and-science-study-timss.html"><a href="trends-in-international-mathematics-and-science-study-timss.html#weighted-counts-37"><i class="fa fa-check"></i>Weighted Counts</a></li>
<li class="chapter" data-level="" data-path="trends-in-international-mathematics-and-science-study-timss.html"><a href="trends-in-international-mathematics-and-science-study-timss.html#descriptive-statistics-46"><i class="fa fa-check"></i>Descriptive Statistics</a></li>
<li class="chapter" data-level="" data-path="trends-in-international-mathematics-and-science-study-timss.html"><a href="trends-in-international-mathematics-and-science-study-timss.html#subsetting-46"><i class="fa fa-check"></i>Subsetting</a></li>
<li class="chapter" data-level="" data-path="trends-in-international-mathematics-and-science-study-timss.html"><a href="trends-in-international-mathematics-and-science-study-timss.html#measures-of-uncertainty-46"><i class="fa fa-check"></i>Measures of Uncertainty</a></li>
<li class="chapter" data-level="" data-path="trends-in-international-mathematics-and-science-study-timss.html"><a href="trends-in-international-mathematics-and-science-study-timss.html#regression-models-and-tests-of-association-46"><i class="fa fa-check"></i>Regression Models and Tests of Association</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="trends-in-international-mathematics-and-science-study-timss.html"><a href="trends-in-international-mathematics-and-science-study-timss.html#replication-example-44"><i class="fa fa-check"></i>Replication Example</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="violence-against-children-and-youth-surveys-vacs.html"><a href="violence-against-children-and-youth-surveys-vacs.html"><i class="fa fa-check"></i>Violence Against Children And Youth Surveys (VACS)</a>
<ul>
<li class="chapter" data-level="" data-path="violence-against-children-and-youth-surveys-vacs.html"><a href="violence-against-children-and-youth-surveys-vacs.html#download-import-preparation-48"><i class="fa fa-check"></i>Download, Import, Preparation</a>
<ul>
<li class="chapter" data-level="" data-path="violence-against-children-and-youth-surveys-vacs.html"><a href="violence-against-children-and-youth-surveys-vacs.html#save-locally-47"><i class="fa fa-check"></i>Save Locally  </a></li>
<li class="chapter" data-level="" data-path="violence-against-children-and-youth-surveys-vacs.html"><a href="violence-against-children-and-youth-surveys-vacs.html#survey-design-definition-38"><i class="fa fa-check"></i>Survey Design Definition</a></li>
<li class="chapter" data-level="" data-path="violence-against-children-and-youth-surveys-vacs.html"><a href="violence-against-children-and-youth-surveys-vacs.html#variable-recoding-47"><i class="fa fa-check"></i>Variable Recoding</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="violence-against-children-and-youth-surveys-vacs.html"><a href="violence-against-children-and-youth-surveys-vacs.html#analysis-examples-with-the-survey-library-38"><i class="fa fa-check"></i>Analysis Examples with the <code>survey</code> library  </a>
<ul>
<li class="chapter" data-level="" data-path="violence-against-children-and-youth-surveys-vacs.html"><a href="violence-against-children-and-youth-surveys-vacs.html#unweighted-counts-47"><i class="fa fa-check"></i>Unweighted Counts</a></li>
<li class="chapter" data-level="" data-path="violence-against-children-and-youth-surveys-vacs.html"><a href="violence-against-children-and-youth-surveys-vacs.html#weighted-counts-38"><i class="fa fa-check"></i>Weighted Counts</a></li>
<li class="chapter" data-level="" data-path="violence-against-children-and-youth-surveys-vacs.html"><a href="violence-against-children-and-youth-surveys-vacs.html#descriptive-statistics-47"><i class="fa fa-check"></i>Descriptive Statistics</a></li>
<li class="chapter" data-level="" data-path="violence-against-children-and-youth-surveys-vacs.html"><a href="violence-against-children-and-youth-surveys-vacs.html#subsetting-47"><i class="fa fa-check"></i>Subsetting</a></li>
<li class="chapter" data-level="" data-path="violence-against-children-and-youth-surveys-vacs.html"><a href="violence-against-children-and-youth-surveys-vacs.html#measures-of-uncertainty-47"><i class="fa fa-check"></i>Measures of Uncertainty</a></li>
<li class="chapter" data-level="" data-path="violence-against-children-and-youth-surveys-vacs.html"><a href="violence-against-children-and-youth-surveys-vacs.html#regression-models-and-tests-of-association-47"><i class="fa fa-check"></i>Regression Models and Tests of Association</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="violence-against-children-and-youth-surveys-vacs.html"><a href="violence-against-children-and-youth-surveys-vacs.html#replication-example-45"><i class="fa fa-check"></i>Replication Example</a></li>
<li class="chapter" data-level="" data-path="violence-against-children-and-youth-surveys-vacs.html"><a href="violence-against-children-and-youth-surveys-vacs.html#analysis-examples-with-srvyr-30"><i class="fa fa-check"></i>Analysis Examples with <code>srvyr</code>  </a></li>
</ul></li>
<li class="chapter" data-level="" data-path="youth-risk-behavior-surveillance-system-yrbss.html"><a href="youth-risk-behavior-surveillance-system-yrbss.html"><i class="fa fa-check"></i>Youth Risk Behavior Surveillance System (YRBSS)</a>
<ul>
<li class="chapter" data-level="" data-path="youth-risk-behavior-surveillance-system-yrbss.html"><a href="youth-risk-behavior-surveillance-system-yrbss.html#download-import-preparation-49"><i class="fa fa-check"></i>Download, Import, Preparation</a>
<ul>
<li class="chapter" data-level="" data-path="youth-risk-behavior-surveillance-system-yrbss.html"><a href="youth-risk-behavior-surveillance-system-yrbss.html#save-locally-48"><i class="fa fa-check"></i>Save Locally  </a></li>
<li class="chapter" data-level="" data-path="youth-risk-behavior-surveillance-system-yrbss.html"><a href="youth-risk-behavior-surveillance-system-yrbss.html#survey-design-definition-39"><i class="fa fa-check"></i>Survey Design Definition</a></li>
<li class="chapter" data-level="" data-path="youth-risk-behavior-surveillance-system-yrbss.html"><a href="youth-risk-behavior-surveillance-system-yrbss.html#variable-recoding-48"><i class="fa fa-check"></i>Variable Recoding</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="youth-risk-behavior-surveillance-system-yrbss.html"><a href="youth-risk-behavior-surveillance-system-yrbss.html#analysis-examples-with-the-survey-library-39"><i class="fa fa-check"></i>Analysis Examples with the <code>survey</code> library  </a>
<ul>
<li class="chapter" data-level="" data-path="youth-risk-behavior-surveillance-system-yrbss.html"><a href="youth-risk-behavior-surveillance-system-yrbss.html#unweighted-counts-48"><i class="fa fa-check"></i>Unweighted Counts</a></li>
<li class="chapter" data-level="" data-path="youth-risk-behavior-surveillance-system-yrbss.html"><a href="youth-risk-behavior-surveillance-system-yrbss.html#weighted-counts-39"><i class="fa fa-check"></i>Weighted Counts</a></li>
<li class="chapter" data-level="" data-path="youth-risk-behavior-surveillance-system-yrbss.html"><a href="youth-risk-behavior-surveillance-system-yrbss.html#descriptive-statistics-48"><i class="fa fa-check"></i>Descriptive Statistics</a></li>
<li class="chapter" data-level="" data-path="youth-risk-behavior-surveillance-system-yrbss.html"><a href="youth-risk-behavior-surveillance-system-yrbss.html#subsetting-48"><i class="fa fa-check"></i>Subsetting</a></li>
<li class="chapter" data-level="" data-path="youth-risk-behavior-surveillance-system-yrbss.html"><a href="youth-risk-behavior-surveillance-system-yrbss.html#measures-of-uncertainty-48"><i class="fa fa-check"></i>Measures of Uncertainty</a></li>
<li class="chapter" data-level="" data-path="youth-risk-behavior-surveillance-system-yrbss.html"><a href="youth-risk-behavior-surveillance-system-yrbss.html#regression-models-and-tests-of-association-48"><i class="fa fa-check"></i>Regression Models and Tests of Association</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="youth-risk-behavior-surveillance-system-yrbss.html"><a href="youth-risk-behavior-surveillance-system-yrbss.html#replication-example-46"><i class="fa fa-check"></i>Replication Example</a></li>
<li class="chapter" data-level="" data-path="youth-risk-behavior-surveillance-system-yrbss.html"><a href="youth-risk-behavior-surveillance-system-yrbss.html#analysis-examples-with-srvyr-31"><i class="fa fa-check"></i>Analysis Examples with <code>srvyr</code>  </a></li>
</ul></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="./">Analyze Survey Data for Free</a>
          </h1>
        </div>

        <div class="page-wrapper" tabindex="-1" role="main">
          <div class="page-inner">

            <section class="normal" id="section-">
<div id="national-crime-victimization-survey-ncvs" class="section level1 unnumbered hasAnchor">
<h1>National Crime Victimization Survey (NCVS)<a href="national-crime-victimization-survey-ncvs.html#national-crime-victimization-survey-ncvs" class="anchor-section" aria-label="Anchor link to header"></a></h1>
<p><a href="https://www.gnu.org/licenses/gpl-3.0"><img src="https://img.shields.io/badge/License-GPLv3-blue.svg" alt="License: GPL v3" /></a> <img src='https://img.shields.io/badge/Tested%20Locally-Windows%20Laptop-brightgreen' alt='Local Testing Badge'></p>
<p>The primary information source on victims of nonfatal personal crimes and household property crimes (especially those not reported to the police), and also victim experience within the justice system.</p>
<ul>
<li><p>Three tables, the first one row per household per interview, the second one per person-interview, the third one per incident reported across each sampled household’s seven-interview, three-year period.</p></li>
<li><p>A complex survey designed to generalize to civilian, non-institutional americans aged 12 and older.</p></li>
<li><p>Released annually since its 1992 rename and redesign, related surveys dating to the early 1970s.</p></li>
<li><p>Sponsored by the <a href="http://www.bjs.gov/">Bureau of Justics Statistics</a> and administered by the <a href="http://www.census.gov/">US Census Bureau</a>.</p></li>
</ul>
<hr />
<p>Please skim before you begin:</p>
<ol style="list-style-type: decimal">
<li><p><a href="https://bjs.ojp.gov/sites/g/files/xyckuh236/files/media/document/ncvstd16.pdf">National Crime Victimization Survey, 2016: Technical Documentation</a></p></li>
<li><p><a href="https://bjs.ojp.gov/document/nmpncvs.pdf">A New Measure of Prevalence for the National Crime Victimization Survey</a></p></li>
<li><p>A haiku regarding this microdata:</p></li>
</ol>
<div class="sourceCode" id="cb610"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb610-1"><a href="national-crime-victimization-survey-ncvs.html#cb610-1" tabindex="-1"></a><span class="co"># saint peter&#39;s sports bar</span></span>
<span id="cb610-2"><a href="national-crime-victimization-survey-ncvs.html#cb610-2" tabindex="-1"></a><span class="co"># evil deed instant replay</span></span>
<span id="cb610-3"><a href="national-crime-victimization-survey-ncvs.html#cb610-3" tabindex="-1"></a><span class="co"># sinful thought jukebox</span></span></code></pre></div>
<hr />
<div id="function-definitions-5" class="section level2 unnumbered hasAnchor">
<h2>Function Definitions<a href="national-crime-victimization-survey-ncvs.html#function-definitions-5" class="anchor-section" aria-label="Anchor link to header"></a></h2>
<p>Define a function to extract values stored in parentheses:</p>
<div class="sourceCode" id="cb611"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb611-1"><a href="national-crime-victimization-survey-ncvs.html#cb611-1" tabindex="-1"></a>ncvs_numeric_to_factor <span class="ot">&lt;-</span> </span>
<span id="cb611-2"><a href="national-crime-victimization-survey-ncvs.html#cb611-2" tabindex="-1"></a>    <span class="cf">function</span>( this_column ) <span class="fu">as.numeric</span>( <span class="fu">gsub</span>( <span class="st">&quot;^</span><span class="sc">\\</span><span class="st">(([0-9]+)</span><span class="sc">\\</span><span class="st">) (.*)&quot;</span> , <span class="st">&quot;</span><span class="sc">\\</span><span class="st">1&quot;</span> , this_column ) )</span></code></pre></div>
<hr />
<p>Define a function to merge aggregated information onto main data.frame objects:</p>
<div class="sourceCode" id="cb612"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb612-1"><a href="national-crime-victimization-survey-ncvs.html#cb612-1" tabindex="-1"></a>left_join_zero_missings <span class="ot">&lt;-</span></span>
<span id="cb612-2"><a href="national-crime-victimization-survey-ncvs.html#cb612-2" tabindex="-1"></a>    <span class="cf">function</span>( left_df , right_df ){</span>
<span id="cb612-3"><a href="national-crime-victimization-survey-ncvs.html#cb612-3" tabindex="-1"></a></span>
<span id="cb612-4"><a href="national-crime-victimization-survey-ncvs.html#cb612-4" tabindex="-1"></a>        final_df <span class="ot">&lt;-</span></span>
<span id="cb612-5"><a href="national-crime-victimization-survey-ncvs.html#cb612-5" tabindex="-1"></a>            <span class="fu">merge</span>(</span>
<span id="cb612-6"><a href="national-crime-victimization-survey-ncvs.html#cb612-6" tabindex="-1"></a>                left_df ,</span>
<span id="cb612-7"><a href="national-crime-victimization-survey-ncvs.html#cb612-7" tabindex="-1"></a>                right_df ,</span>
<span id="cb612-8"><a href="national-crime-victimization-survey-ncvs.html#cb612-8" tabindex="-1"></a>                <span class="at">all.x =</span> <span class="cn">TRUE</span></span>
<span id="cb612-9"><a href="national-crime-victimization-survey-ncvs.html#cb612-9" tabindex="-1"></a>            )</span>
<span id="cb612-10"><a href="national-crime-victimization-survey-ncvs.html#cb612-10" tabindex="-1"></a>            </span>
<span id="cb612-11"><a href="national-crime-victimization-survey-ncvs.html#cb612-11" tabindex="-1"></a>        <span class="fu">stopifnot</span>( <span class="fu">nrow</span>( final_df ) <span class="sc">==</span> <span class="fu">nrow</span>( left_df ) )</span>
<span id="cb612-12"><a href="national-crime-victimization-survey-ncvs.html#cb612-12" tabindex="-1"></a></span>
<span id="cb612-13"><a href="national-crime-victimization-survey-ncvs.html#cb612-13" tabindex="-1"></a>        <span class="cf">for</span>( this_column <span class="cf">in</span> <span class="fu">setdiff</span>( <span class="fu">names</span>( right_df ) , <span class="fu">names</span>( left_df ) ) ){</span>
<span id="cb612-14"><a href="national-crime-victimization-survey-ncvs.html#cb612-14" tabindex="-1"></a>            final_df[ <span class="fu">is.na</span>( final_df[ , this_column ] ) , this_column ] <span class="ot">&lt;-</span> <span class="dv">0</span></span>
<span id="cb612-15"><a href="national-crime-victimization-survey-ncvs.html#cb612-15" tabindex="-1"></a>        }</span>
<span id="cb612-16"><a href="national-crime-victimization-survey-ncvs.html#cb612-16" tabindex="-1"></a>        </span>
<span id="cb612-17"><a href="national-crime-victimization-survey-ncvs.html#cb612-17" tabindex="-1"></a>        <span class="fu">gc</span>()</span>
<span id="cb612-18"><a href="national-crime-victimization-survey-ncvs.html#cb612-18" tabindex="-1"></a></span>
<span id="cb612-19"><a href="national-crime-victimization-survey-ncvs.html#cb612-19" tabindex="-1"></a>        final_df</span>
<span id="cb612-20"><a href="national-crime-victimization-survey-ncvs.html#cb612-20" tabindex="-1"></a>    }</span></code></pre></div>
<hr />
</div>
<div id="download-import-preparation-22" class="section level2 unnumbered hasAnchor">
<h2>Download, Import, Preparation<a href="national-crime-victimization-survey-ncvs.html#download-import-preparation-22" class="anchor-section" aria-label="Anchor link to header"></a></h2>
<ol style="list-style-type: decimal">
<li><p>Register for the National Archive of Criminal Justice Data at <a href="https://www.icpsr.umich.edu/web/NACJD/series/95" class="uri">https://www.icpsr.umich.edu/web/NACJD/series/95</a></p></li>
<li><p>Choose <code>National Crime Victimization Survey, Concatenated File, [United States], 1992-2022 (ICPSR 38604)</code></p></li>
<li><p>Download the <code>R</code> version of the September 18, 2023 file.</p></li>
</ol>
<p>Import the three main files:</p>
<div class="sourceCode" id="cb613"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb613-1"><a href="national-crime-victimization-survey-ncvs.html#cb613-1" tabindex="-1"></a>ncvs_household_df_name <span class="ot">&lt;-</span></span>
<span id="cb613-2"><a href="national-crime-victimization-survey-ncvs.html#cb613-2" tabindex="-1"></a>    <span class="fu">load</span>( <span class="fu">file.path</span>( <span class="fu">path.expand</span>( <span class="st">&quot;~&quot;</span> ) , <span class="st">&quot;ICPSR_38604/DS0001/38604-0001-Data.rda&quot;</span> ) )</span>
<span id="cb613-3"><a href="national-crime-victimization-survey-ncvs.html#cb613-3" tabindex="-1"></a>    </span>
<span id="cb613-4"><a href="national-crime-victimization-survey-ncvs.html#cb613-4" tabindex="-1"></a>ncvs_person_df_name <span class="ot">&lt;-</span></span>
<span id="cb613-5"><a href="national-crime-victimization-survey-ncvs.html#cb613-5" tabindex="-1"></a>    <span class="fu">load</span>( <span class="fu">file.path</span>( <span class="fu">path.expand</span>( <span class="st">&quot;~&quot;</span> ) , <span class="st">&quot;ICPSR_38604/DS0002/38604-0002-Data.rda&quot;</span> ) )</span>
<span id="cb613-6"><a href="national-crime-victimization-survey-ncvs.html#cb613-6" tabindex="-1"></a></span>
<span id="cb613-7"><a href="national-crime-victimization-survey-ncvs.html#cb613-7" tabindex="-1"></a>ncvs_incident_df_name <span class="ot">&lt;-</span></span>
<span id="cb613-8"><a href="national-crime-victimization-survey-ncvs.html#cb613-8" tabindex="-1"></a>    <span class="fu">load</span>( <span class="fu">file.path</span>( <span class="fu">path.expand</span>( <span class="st">&quot;~&quot;</span> ) , <span class="st">&quot;ICPSR_38604/DS0003/38604-0003-Data.rda&quot;</span> ) )</span>
<span id="cb613-9"><a href="national-crime-victimization-survey-ncvs.html#cb613-9" tabindex="-1"></a></span>
<span id="cb613-10"><a href="national-crime-victimization-survey-ncvs.html#cb613-10" tabindex="-1"></a>ncvs_household_df <span class="ot">&lt;-</span> <span class="fu">get</span>( ncvs_household_df_name )</span>
<span id="cb613-11"><a href="national-crime-victimization-survey-ncvs.html#cb613-11" tabindex="-1"></a>ncvs_person_df <span class="ot">&lt;-</span> <span class="fu">get</span>( ncvs_person_df_name )</span>
<span id="cb613-12"><a href="national-crime-victimization-survey-ncvs.html#cb613-12" tabindex="-1"></a>ncvs_incident_df <span class="ot">&lt;-</span> <span class="fu">get</span>( ncvs_incident_df_name )</span>
<span id="cb613-13"><a href="national-crime-victimization-survey-ncvs.html#cb613-13" tabindex="-1"></a></span>
<span id="cb613-14"><a href="national-crime-victimization-survey-ncvs.html#cb613-14" tabindex="-1"></a><span class="fu">rm</span>( <span class="at">list =</span> ncvs_household_df_name ) ; <span class="fu">gc</span>()</span>
<span id="cb613-15"><a href="national-crime-victimization-survey-ncvs.html#cb613-15" tabindex="-1"></a><span class="fu">rm</span>( <span class="at">list =</span> ncvs_person_df_name ) ; <span class="fu">gc</span>()</span>
<span id="cb613-16"><a href="national-crime-victimization-survey-ncvs.html#cb613-16" tabindex="-1"></a><span class="fu">rm</span>( <span class="at">list =</span> ncvs_incident_df_name ) ; <span class="fu">gc</span>()</span>
<span id="cb613-17"><a href="national-crime-victimization-survey-ncvs.html#cb613-17" tabindex="-1"></a></span>
<span id="cb613-18"><a href="national-crime-victimization-survey-ncvs.html#cb613-18" tabindex="-1"></a><span class="fu">names</span>( ncvs_household_df ) <span class="ot">&lt;-</span> <span class="fu">tolower</span>( <span class="fu">names</span>( ncvs_household_df ) )</span>
<span id="cb613-19"><a href="national-crime-victimization-survey-ncvs.html#cb613-19" tabindex="-1"></a><span class="fu">names</span>( ncvs_person_df ) <span class="ot">&lt;-</span> <span class="fu">tolower</span>( <span class="fu">names</span>( ncvs_person_df ) )</span>
<span id="cb613-20"><a href="national-crime-victimization-survey-ncvs.html#cb613-20" tabindex="-1"></a><span class="fu">names</span>( ncvs_incident_df ) <span class="ot">&lt;-</span> <span class="fu">tolower</span>( <span class="fu">names</span>( ncvs_incident_df ) )</span></code></pre></div>
<p>Determine which variables from each table to retain:</p>
<div class="sourceCode" id="cb614"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb614-1"><a href="national-crime-victimization-survey-ncvs.html#cb614-1" tabindex="-1"></a>household_variables_to_keep <span class="ot">&lt;-</span></span>
<span id="cb614-2"><a href="national-crime-victimization-survey-ncvs.html#cb614-2" tabindex="-1"></a>    <span class="fu">c</span>( <span class="st">&#39;year&#39;</span> , <span class="st">&#39;yearq&#39;</span> , <span class="st">&#39;idhh&#39;</span> , <span class="st">&#39;wgthhcy&#39;</span> , <span class="st">&#39;v2002&#39;</span> , <span class="st">&#39;sc214a&#39;</span> , </span>
<span id="cb614-3"><a href="national-crime-victimization-survey-ncvs.html#cb614-3" tabindex="-1"></a>    <span class="st">&#39;v2026&#39;</span> , <span class="st">&#39;v2126a&#39;</span> , <span class="st">&#39;v2126b&#39;</span> , <span class="st">&#39;v2015&#39;</span> , <span class="st">&#39;v2017&#39;</span> , <span class="st">&#39;v2117&#39;</span> , </span>
<span id="cb614-4"><a href="national-crime-victimization-survey-ncvs.html#cb614-4" tabindex="-1"></a>    <span class="st">&#39;v2118&#39;</span> , <span class="st">&#39;v2125&#39;</span> , <span class="st">&#39;v2071&#39;</span> , <span class="st">&#39;v2072&#39;</span> , <span class="st">&#39;v2127b&#39;</span> , <span class="st">&#39;v2129&#39;</span> )</span>
<span id="cb614-5"><a href="national-crime-victimization-survey-ncvs.html#cb614-5" tabindex="-1"></a></span>
<span id="cb614-6"><a href="national-crime-victimization-survey-ncvs.html#cb614-6" tabindex="-1"></a>person_variables_to_keep <span class="ot">&lt;-</span></span>
<span id="cb614-7"><a href="national-crime-victimization-survey-ncvs.html#cb614-7" tabindex="-1"></a>    <span class="fu">c</span>( <span class="st">&#39;year&#39;</span> , <span class="st">&#39;yearq&#39;</span> , <span class="st">&#39;v3018&#39;</span> , <span class="st">&#39;v3014&#39;</span> , <span class="st">&#39;sc214a&#39;</span> , <span class="st">&#39;v3023&#39;</span> , </span>
<span id="cb614-8"><a href="national-crime-victimization-survey-ncvs.html#cb614-8" tabindex="-1"></a>    <span class="st">&#39;v3023a&#39;</span> , <span class="st">&#39;v3024&#39;</span> , <span class="st">&#39;v3024a&#39;</span> , <span class="st">&#39;v2117&#39;</span> , <span class="st">&#39;v2118&#39;</span> , <span class="st">&#39;v3002&#39;</span> , </span>
<span id="cb614-9"><a href="national-crime-victimization-survey-ncvs.html#cb614-9" tabindex="-1"></a>    <span class="st">&#39;idhh&#39;</span> , <span class="st">&#39;idper&#39;</span> , <span class="st">&#39;wgtpercy&#39;</span> , <span class="st">&#39;v3015&#39;</span> , <span class="st">&#39;v3033&#39;</span> , <span class="st">&#39;v2026&#39;</span> )</span>
<span id="cb614-10"><a href="national-crime-victimization-survey-ncvs.html#cb614-10" tabindex="-1"></a></span>
<span id="cb614-11"><a href="national-crime-victimization-survey-ncvs.html#cb614-11" tabindex="-1"></a>incident_variables_to_keep <span class="ot">&lt;-</span></span>
<span id="cb614-12"><a href="national-crime-victimization-survey-ncvs.html#cb614-12" tabindex="-1"></a>    <span class="fu">c</span>( <span class="st">&#39;year&#39;</span> , <span class="st">&#39;yearq&#39;</span> , <span class="st">&#39;v2117&#39;</span> , <span class="st">&#39;v2118&#39;</span> , <span class="st">&#39;v4022&#39;</span> , </span>
<span id="cb614-13"><a href="national-crime-victimization-survey-ncvs.html#cb614-13" tabindex="-1"></a>    <span class="fu">paste0</span>( <span class="st">&#39;v401&#39;</span> , <span class="dv">6</span><span class="sc">:</span><span class="dv">9</span> ) , <span class="st">&#39;v4399&#39;</span> , <span class="st">&#39;v4529&#39;</span> , <span class="st">&#39;v4049&#39;</span> , <span class="fu">paste0</span>( <span class="st">&#39;v405&#39;</span> , <span class="dv">0</span><span class="sc">:</span><span class="dv">8</span> ) , </span>
<span id="cb614-14"><a href="national-crime-victimization-survey-ncvs.html#cb614-14" tabindex="-1"></a>    <span class="st">&#39;v4060&#39;</span> , <span class="st">&#39;v4062&#39;</span> , <span class="fu">paste0</span>( <span class="st">&#39;v41&#39;</span> , <span class="dv">11</span><span class="sc">:</span><span class="dv">22</span> ) , <span class="st">&#39;v4064&#39;</span> , <span class="fu">paste0</span>( <span class="st">&#39;v41&#39;</span> , <span class="dv">27</span><span class="sc">:</span><span class="dv">37</span> ) , </span>
<span id="cb614-15"><a href="national-crime-victimization-survey-ncvs.html#cb614-15" tabindex="-1"></a>    <span class="st">&#39;v4467&#39;</span> , <span class="st">&#39;v4234&#39;</span> , <span class="st">&#39;v4245&#39;</span> , <span class="st">&#39;v4243&#39;</span> , <span class="st">&#39;v4241&#39;</span> , <span class="st">&#39;v4256&#39;</span> , <span class="st">&#39;v4258&#39;</span> , <span class="st">&#39;v4278&#39;</span> , </span>
<span id="cb614-16"><a href="national-crime-victimization-survey-ncvs.html#cb614-16" tabindex="-1"></a>    <span class="st">&#39;v4262&#39;</span> , <span class="fu">paste0</span>( <span class="st">&#39;v42&#39;</span> , <span class="dv">59</span><span class="sc">:</span><span class="dv">61</span> ) , <span class="st">&#39;v4269&#39;</span> , <span class="st">&#39;v4270&#39;</span> , <span class="st">&#39;v4268&#39;</span> , <span class="st">&#39;v4267&#39;</span> , </span>
<span id="cb614-17"><a href="national-crime-victimization-survey-ncvs.html#cb614-17" tabindex="-1"></a>    <span class="st">&#39;v4271&#39;</span> , <span class="st">&#39;v4266&#39;</span> , <span class="st">&#39;v4265&#39;</span> , <span class="st">&#39;wgtviccy&#39;</span> , <span class="st">&#39;idhh&#39;</span> , <span class="st">&#39;idper&#39;</span> , <span class="st">&#39;v4002&#39;</span> , <span class="st">&#39;v4288&#39;</span> , </span>
<span id="cb614-18"><a href="national-crime-victimization-survey-ncvs.html#cb614-18" tabindex="-1"></a>    <span class="st">&#39;v4290&#39;</span> , <span class="st">&#39;v4400&#39;</span> , <span class="st">&#39;v4437&#39;</span> , <span class="st">&#39;v4422&#39;</span> , <span class="st">&#39;v4024&#39;</span> )</span></code></pre></div>
<p>Limit columns in each data.frame to those specified above:</p>
<div class="sourceCode" id="cb615"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb615-1"><a href="national-crime-victimization-survey-ncvs.html#cb615-1" tabindex="-1"></a>ncvs_household_df <span class="ot">&lt;-</span> ncvs_household_df[ , household_variables_to_keep ]</span>
<span id="cb615-2"><a href="national-crime-victimization-survey-ncvs.html#cb615-2" tabindex="-1"></a></span>
<span id="cb615-3"><a href="national-crime-victimization-survey-ncvs.html#cb615-3" tabindex="-1"></a>ncvs_person_df <span class="ot">&lt;-</span> ncvs_person_df[ , person_variables_to_keep ]</span>
<span id="cb615-4"><a href="national-crime-victimization-survey-ncvs.html#cb615-4" tabindex="-1"></a></span>
<span id="cb615-5"><a href="national-crime-victimization-survey-ncvs.html#cb615-5" tabindex="-1"></a>ncvs_incident_df <span class="ot">&lt;-</span> ncvs_incident_df[ , incident_variables_to_keep ]</span>
<span id="cb615-6"><a href="national-crime-victimization-survey-ncvs.html#cb615-6" tabindex="-1"></a></span>
<span id="cb615-7"><a href="national-crime-victimization-survey-ncvs.html#cb615-7" tabindex="-1"></a><span class="fu">gc</span>()</span></code></pre></div>
<p><strong>In this example, limit the 1993-2022 <code>data.frame</code> to only the first &amp; last years for quicker processing:</strong></p>
<div class="sourceCode" id="cb616"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb616-1"><a href="national-crime-victimization-survey-ncvs.html#cb616-1" tabindex="-1"></a>ncvs_household_df <span class="ot">&lt;-</span> ncvs_household_df[ ncvs_household_df[ , <span class="st">&#39;year&#39;</span> ] <span class="sc">%in%</span> <span class="fu">c</span>( <span class="dv">1994</span> , <span class="dv">2022</span> ) , ]</span>
<span id="cb616-2"><a href="national-crime-victimization-survey-ncvs.html#cb616-2" tabindex="-1"></a></span>
<span id="cb616-3"><a href="national-crime-victimization-survey-ncvs.html#cb616-3" tabindex="-1"></a>ncvs_person_df <span class="ot">&lt;-</span> ncvs_person_df[ ncvs_person_df[ , <span class="st">&#39;year&#39;</span> ] <span class="sc">%in%</span> <span class="fu">c</span>( <span class="dv">1994</span> , <span class="dv">2022</span> ) , ]</span>
<span id="cb616-4"><a href="national-crime-victimization-survey-ncvs.html#cb616-4" tabindex="-1"></a></span>
<span id="cb616-5"><a href="national-crime-victimization-survey-ncvs.html#cb616-5" tabindex="-1"></a>ncvs_incident_df <span class="ot">&lt;-</span> ncvs_incident_df[ ncvs_incident_df[ , <span class="st">&#39;year&#39;</span> ] <span class="sc">%in%</span> <span class="fu">c</span>( <span class="dv">1994</span> , <span class="dv">2022</span> ) , ]</span>
<span id="cb616-6"><a href="national-crime-victimization-survey-ncvs.html#cb616-6" tabindex="-1"></a></span>
<span id="cb616-7"><a href="national-crime-victimization-survey-ncvs.html#cb616-7" tabindex="-1"></a><span class="fu">gc</span>()</span></code></pre></div>
<p>Recode identifiers to character class:</p>
<div class="sourceCode" id="cb617"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb617-1"><a href="national-crime-victimization-survey-ncvs.html#cb617-1" tabindex="-1"></a>ncvs_household_df[ , <span class="st">&#39;idhh&#39;</span> ] <span class="ot">&lt;-</span> <span class="fu">as.character</span>( ncvs_household_df[ , <span class="st">&#39;idhh&#39;</span> ] )</span>
<span id="cb617-2"><a href="national-crime-victimization-survey-ncvs.html#cb617-2" tabindex="-1"></a></span>
<span id="cb617-3"><a href="national-crime-victimization-survey-ncvs.html#cb617-3" tabindex="-1"></a>ncvs_person_df[ <span class="fu">c</span>( <span class="st">&#39;idhh&#39;</span> , <span class="st">&#39;idper&#39;</span> ) ] <span class="ot">&lt;-</span></span>
<span id="cb617-4"><a href="national-crime-victimization-survey-ncvs.html#cb617-4" tabindex="-1"></a>    <span class="fu">sapply</span>( ncvs_person_df[ <span class="fu">c</span>( <span class="st">&#39;idhh&#39;</span> , <span class="st">&#39;idper&#39;</span> ) ] , as.character )</span>
<span id="cb617-5"><a href="national-crime-victimization-survey-ncvs.html#cb617-5" tabindex="-1"></a></span>
<span id="cb617-6"><a href="national-crime-victimization-survey-ncvs.html#cb617-6" tabindex="-1"></a>ncvs_incident_df[ <span class="fu">c</span>( <span class="st">&#39;idhh&#39;</span> , <span class="st">&#39;idper&#39;</span> ) ] <span class="ot">&lt;-</span></span>
<span id="cb617-7"><a href="national-crime-victimization-survey-ncvs.html#cb617-7" tabindex="-1"></a>    <span class="fu">sapply</span>( ncvs_incident_df[ <span class="fu">c</span>( <span class="st">&#39;idhh&#39;</span> , <span class="st">&#39;idper&#39;</span> ) ] , as.character )</span></code></pre></div>
<p>Recode factor variables to numeric values:</p>
<div class="sourceCode" id="cb618"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb618-1"><a href="national-crime-victimization-survey-ncvs.html#cb618-1" tabindex="-1"></a>ncvs_household_df[ <span class="fu">sapply</span>( ncvs_household_df , class ) <span class="sc">==</span> <span class="st">&#39;factor&#39;</span> ] <span class="ot">&lt;-</span></span>
<span id="cb618-2"><a href="national-crime-victimization-survey-ncvs.html#cb618-2" tabindex="-1"></a>    <span class="fu">sapply</span>( </span>
<span id="cb618-3"><a href="national-crime-victimization-survey-ncvs.html#cb618-3" tabindex="-1"></a>        ncvs_household_df[ <span class="fu">sapply</span>( ncvs_household_df , class ) <span class="sc">==</span> <span class="st">&#39;factor&#39;</span> ] , </span>
<span id="cb618-4"><a href="national-crime-victimization-survey-ncvs.html#cb618-4" tabindex="-1"></a>        ncvs_numeric_to_factor , </span>
<span id="cb618-5"><a href="national-crime-victimization-survey-ncvs.html#cb618-5" tabindex="-1"></a>        <span class="at">simplify =</span> <span class="cn">FALSE</span> </span>
<span id="cb618-6"><a href="national-crime-victimization-survey-ncvs.html#cb618-6" tabindex="-1"></a>    )</span>
<span id="cb618-7"><a href="national-crime-victimization-survey-ncvs.html#cb618-7" tabindex="-1"></a></span>
<span id="cb618-8"><a href="national-crime-victimization-survey-ncvs.html#cb618-8" tabindex="-1"></a>ncvs_person_df[ <span class="fu">sapply</span>( ncvs_person_df , class ) <span class="sc">==</span> <span class="st">&#39;factor&#39;</span> ] <span class="ot">&lt;-</span></span>
<span id="cb618-9"><a href="national-crime-victimization-survey-ncvs.html#cb618-9" tabindex="-1"></a>    <span class="fu">sapply</span>( </span>
<span id="cb618-10"><a href="national-crime-victimization-survey-ncvs.html#cb618-10" tabindex="-1"></a>        ncvs_person_df[ <span class="fu">sapply</span>( ncvs_person_df , class ) <span class="sc">==</span> <span class="st">&#39;factor&#39;</span> ] , </span>
<span id="cb618-11"><a href="national-crime-victimization-survey-ncvs.html#cb618-11" tabindex="-1"></a>        ncvs_numeric_to_factor ,</span>
<span id="cb618-12"><a href="national-crime-victimization-survey-ncvs.html#cb618-12" tabindex="-1"></a>        <span class="at">simplify =</span> <span class="cn">FALSE</span></span>
<span id="cb618-13"><a href="national-crime-victimization-survey-ncvs.html#cb618-13" tabindex="-1"></a>    )</span>
<span id="cb618-14"><a href="national-crime-victimization-survey-ncvs.html#cb618-14" tabindex="-1"></a></span>
<span id="cb618-15"><a href="national-crime-victimization-survey-ncvs.html#cb618-15" tabindex="-1"></a>ncvs_incident_df[ <span class="fu">sapply</span>( ncvs_incident_df , class ) <span class="sc">==</span> <span class="st">&#39;factor&#39;</span> ] <span class="ot">&lt;-</span></span>
<span id="cb618-16"><a href="national-crime-victimization-survey-ncvs.html#cb618-16" tabindex="-1"></a>    <span class="fu">sapply</span>( </span>
<span id="cb618-17"><a href="national-crime-victimization-survey-ncvs.html#cb618-17" tabindex="-1"></a>        ncvs_incident_df[ <span class="fu">sapply</span>( ncvs_incident_df , class ) <span class="sc">==</span> <span class="st">&#39;factor&#39;</span> ] , </span>
<span id="cb618-18"><a href="national-crime-victimization-survey-ncvs.html#cb618-18" tabindex="-1"></a>        ncvs_numeric_to_factor ,</span>
<span id="cb618-19"><a href="national-crime-victimization-survey-ncvs.html#cb618-19" tabindex="-1"></a>        <span class="at">simplify =</span> <span class="cn">FALSE</span></span>
<span id="cb618-20"><a href="national-crime-victimization-survey-ncvs.html#cb618-20" tabindex="-1"></a>    )</span></code></pre></div>
<p>Add a column of ones to each data.frame:</p>
<div class="sourceCode" id="cb619"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb619-1"><a href="national-crime-victimization-survey-ncvs.html#cb619-1" tabindex="-1"></a>ncvs_household_df[ , <span class="st">&#39;one&#39;</span> ] <span class="ot">&lt;-</span> <span class="dv">1</span></span>
<span id="cb619-2"><a href="national-crime-victimization-survey-ncvs.html#cb619-2" tabindex="-1"></a>    </span>
<span id="cb619-3"><a href="national-crime-victimization-survey-ncvs.html#cb619-3" tabindex="-1"></a>ncvs_person_df[ , <span class="st">&#39;one&#39;</span> ] <span class="ot">&lt;-</span> <span class="dv">1</span></span>
<span id="cb619-4"><a href="national-crime-victimization-survey-ncvs.html#cb619-4" tabindex="-1"></a></span>
<span id="cb619-5"><a href="national-crime-victimization-survey-ncvs.html#cb619-5" tabindex="-1"></a>ncvs_incident_df[ , <span class="st">&#39;one&#39;</span> ] <span class="ot">&lt;-</span> <span class="dv">1</span></span></code></pre></div>
<p>Add a year group variable to each data.frame:</p>
<div class="sourceCode" id="cb620"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb620-1"><a href="national-crime-victimization-survey-ncvs.html#cb620-1" tabindex="-1"></a>ncvs_household_df[ , <span class="st">&#39;yr_grp&#39;</span> ] <span class="ot">&lt;-</span></span>
<span id="cb620-2"><a href="national-crime-victimization-survey-ncvs.html#cb620-2" tabindex="-1"></a>    <span class="fu">findInterval</span>( ncvs_household_df[ , <span class="st">&#39;year&#39;</span> ] , <span class="fu">c</span>( <span class="dv">1992</span> , <span class="dv">1997</span> , <span class="dv">2006</span> , <span class="dv">2016</span> ) )</span>
<span id="cb620-3"><a href="national-crime-victimization-survey-ncvs.html#cb620-3" tabindex="-1"></a>    </span>
<span id="cb620-4"><a href="national-crime-victimization-survey-ncvs.html#cb620-4" tabindex="-1"></a>ncvs_person_df[ , <span class="st">&#39;yr_grp&#39;</span> ] <span class="ot">&lt;-</span></span>
<span id="cb620-5"><a href="national-crime-victimization-survey-ncvs.html#cb620-5" tabindex="-1"></a>    <span class="fu">findInterval</span>( ncvs_person_df[ , <span class="st">&#39;year&#39;</span> ] , <span class="fu">c</span>( <span class="dv">1992</span> , <span class="dv">1997</span> , <span class="dv">2006</span> , <span class="dv">2016</span> ) )</span>
<span id="cb620-6"><a href="national-crime-victimization-survey-ncvs.html#cb620-6" tabindex="-1"></a></span>
<span id="cb620-7"><a href="national-crime-victimization-survey-ncvs.html#cb620-7" tabindex="-1"></a>ncvs_incident_df[ , <span class="st">&#39;yr_grp&#39;</span> ] <span class="ot">&lt;-</span></span>
<span id="cb620-8"><a href="national-crime-victimization-survey-ncvs.html#cb620-8" tabindex="-1"></a>    <span class="fu">findInterval</span>( ncvs_incident_df[ , <span class="st">&#39;year&#39;</span> ] , <span class="fu">c</span>( <span class="dv">1992</span> , <span class="dv">1997</span> , <span class="dv">2006</span> , <span class="dv">2016</span> ) )</span></code></pre></div>
<p>Add a flag indicating whether each incident occurred inside the country:</p>
<div class="sourceCode" id="cb621"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb621-1"><a href="national-crime-victimization-survey-ncvs.html#cb621-1" tabindex="-1"></a>ncvs_incident_df[ , <span class="st">&#39;exclude_outus&#39;</span> ] <span class="ot">&lt;-</span></span>
<span id="cb621-2"><a href="national-crime-victimization-survey-ncvs.html#cb621-2" tabindex="-1"></a>    ncvs_incident_df[ , <span class="st">&#39;v4022&#39;</span> ] <span class="sc">%in%</span> <span class="dv">1</span></span></code></pre></div>
<p>Add a half-year indicator to the incident data.frame:</p>
<div class="sourceCode" id="cb622"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb622-1"><a href="national-crime-victimization-survey-ncvs.html#cb622-1" tabindex="-1"></a>ncvs_incident_df <span class="ot">&lt;-</span></span>
<span id="cb622-2"><a href="national-crime-victimization-survey-ncvs.html#cb622-2" tabindex="-1"></a>    <span class="fu">transform</span>(</span>
<span id="cb622-3"><a href="national-crime-victimization-survey-ncvs.html#cb622-3" tabindex="-1"></a>        ncvs_incident_df ,</span>
<span id="cb622-4"><a href="national-crime-victimization-survey-ncvs.html#cb622-4" tabindex="-1"></a>        <span class="at">half_year =</span></span>
<span id="cb622-5"><a href="national-crime-victimization-survey-ncvs.html#cb622-5" tabindex="-1"></a>            <span class="fu">ifelse</span>( <span class="fu">substr</span>( yearq , <span class="dv">6</span> , <span class="dv">6</span> ) <span class="sc">%in%</span> <span class="fu">c</span>( <span class="st">&#39;1&#39;</span> , <span class="st">&#39;2&#39;</span> ) , <span class="dv">1</span> ,</span>
<span id="cb622-6"><a href="national-crime-victimization-survey-ncvs.html#cb622-6" tabindex="-1"></a>            <span class="fu">ifelse</span>( <span class="fu">substr</span>( yearq , <span class="dv">6</span> , <span class="dv">6</span> ) <span class="sc">%in%</span> <span class="fu">c</span>( <span class="st">&#39;3&#39;</span> , <span class="st">&#39;4&#39;</span> ) , <span class="dv">2</span> ,</span>
<span id="cb622-7"><a href="national-crime-victimization-survey-ncvs.html#cb622-7" tabindex="-1"></a>                <span class="cn">NA</span> ) )</span>
<span id="cb622-8"><a href="national-crime-victimization-survey-ncvs.html#cb622-8" tabindex="-1"></a>    )</span>
<span id="cb622-9"><a href="national-crime-victimization-survey-ncvs.html#cb622-9" tabindex="-1"></a>    </span>
<span id="cb622-10"><a href="national-crime-victimization-survey-ncvs.html#cb622-10" tabindex="-1"></a><span class="fu">stopifnot</span>( <span class="fu">all</span>( ncvs_incident_df[ , <span class="st">&#39;half_year&#39;</span> ] <span class="sc">%in%</span> <span class="dv">1</span><span class="sc">:</span><span class="dv">2</span> ) )</span></code></pre></div>
<p>Define violent crimes on the incident data.frame:</p>
<div class="sourceCode" id="cb623"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb623-1"><a href="national-crime-victimization-survey-ncvs.html#cb623-1" tabindex="-1"></a><span class="co"># rape and sexual assault</span></span>
<span id="cb623-2"><a href="national-crime-victimization-survey-ncvs.html#cb623-2" tabindex="-1"></a>ncvs_incident_df[ , <span class="st">&#39;rsa&#39;</span> ] <span class="ot">&lt;-</span> </span>
<span id="cb623-3"><a href="national-crime-victimization-survey-ncvs.html#cb623-3" tabindex="-1"></a>    ncvs_incident_df[ , <span class="st">&#39;v4529&#39;</span> ] <span class="sc">%in%</span> <span class="fu">c</span>( <span class="dv">1</span><span class="sc">:</span><span class="dv">4</span> , <span class="dv">15</span> , <span class="dv">16</span> , <span class="dv">18</span> , <span class="dv">19</span> )</span>
<span id="cb623-4"><a href="national-crime-victimization-survey-ncvs.html#cb623-4" tabindex="-1"></a></span>
<span id="cb623-5"><a href="national-crime-victimization-survey-ncvs.html#cb623-5" tabindex="-1"></a><span class="co"># robbery</span></span>
<span id="cb623-6"><a href="national-crime-victimization-survey-ncvs.html#cb623-6" tabindex="-1"></a>ncvs_incident_df[ , <span class="st">&#39;rob&#39;</span> ] <span class="ot">&lt;-</span> </span>
<span id="cb623-7"><a href="national-crime-victimization-survey-ncvs.html#cb623-7" tabindex="-1"></a>    ncvs_incident_df[ , <span class="st">&#39;v4529&#39;</span> ] <span class="sc">%in%</span> <span class="dv">5</span><span class="sc">:</span><span class="dv">10</span></span>
<span id="cb623-8"><a href="national-crime-victimization-survey-ncvs.html#cb623-8" tabindex="-1"></a></span>
<span id="cb623-9"><a href="national-crime-victimization-survey-ncvs.html#cb623-9" tabindex="-1"></a><span class="co"># assault</span></span>
<span id="cb623-10"><a href="national-crime-victimization-survey-ncvs.html#cb623-10" tabindex="-1"></a>ncvs_incident_df[ , <span class="st">&#39;ast&#39;</span> ] <span class="ot">&lt;-</span> </span>
<span id="cb623-11"><a href="national-crime-victimization-survey-ncvs.html#cb623-11" tabindex="-1"></a>    ncvs_incident_df[ , <span class="st">&#39;v4529&#39;</span> ] <span class="sc">%in%</span> <span class="fu">c</span>( <span class="dv">11</span><span class="sc">:</span><span class="dv">14</span> , <span class="dv">17</span> , <span class="dv">20</span> )</span>
<span id="cb623-12"><a href="national-crime-victimization-survey-ncvs.html#cb623-12" tabindex="-1"></a>    </span>
<span id="cb623-13"><a href="national-crime-victimization-survey-ncvs.html#cb623-13" tabindex="-1"></a><span class="co"># simple assault</span></span>
<span id="cb623-14"><a href="national-crime-victimization-survey-ncvs.html#cb623-14" tabindex="-1"></a>ncvs_incident_df[ , <span class="st">&#39;sast&#39;</span> ] <span class="ot">&lt;-</span> </span>
<span id="cb623-15"><a href="national-crime-victimization-survey-ncvs.html#cb623-15" tabindex="-1"></a>    ncvs_incident_df[ , <span class="st">&#39;v4529&#39;</span> ] <span class="sc">%in%</span> <span class="fu">c</span>( <span class="dv">14</span> , <span class="dv">17</span> , <span class="dv">20</span> )</span>
<span id="cb623-16"><a href="national-crime-victimization-survey-ncvs.html#cb623-16" tabindex="-1"></a></span>
<span id="cb623-17"><a href="national-crime-victimization-survey-ncvs.html#cb623-17" tabindex="-1"></a><span class="co"># aggravated assault</span></span>
<span id="cb623-18"><a href="national-crime-victimization-survey-ncvs.html#cb623-18" tabindex="-1"></a>ncvs_incident_df[ , <span class="st">&#39;aast&#39;</span> ] <span class="ot">&lt;-</span> </span>
<span id="cb623-19"><a href="national-crime-victimization-survey-ncvs.html#cb623-19" tabindex="-1"></a>    ncvs_incident_df[ , <span class="st">&#39;v4529&#39;</span> ] <span class="sc">%in%</span> <span class="dv">11</span><span class="sc">:</span><span class="dv">13</span></span>
<span id="cb623-20"><a href="national-crime-victimization-survey-ncvs.html#cb623-20" tabindex="-1"></a></span>
<span id="cb623-21"><a href="national-crime-victimization-survey-ncvs.html#cb623-21" tabindex="-1"></a><span class="co"># violent crime</span></span>
<span id="cb623-22"><a href="national-crime-victimization-survey-ncvs.html#cb623-22" tabindex="-1"></a>ncvs_incident_df[ , <span class="st">&#39;violent&#39;</span> ] <span class="ot">&lt;-</span></span>
<span id="cb623-23"><a href="national-crime-victimization-survey-ncvs.html#cb623-23" tabindex="-1"></a>    <span class="fu">apply</span>( ncvs_incident_df[ <span class="fu">c</span>( <span class="st">&#39;rsa&#39;</span> , <span class="st">&#39;rob&#39;</span> , <span class="st">&#39;ast&#39;</span> ) ] , <span class="dv">1</span> , any )</span>
<span id="cb623-24"><a href="national-crime-victimization-survey-ncvs.html#cb623-24" tabindex="-1"></a></span>
<span id="cb623-25"><a href="national-crime-victimization-survey-ncvs.html#cb623-25" tabindex="-1"></a><span class="co"># violent crime excluding simple assault</span></span>
<span id="cb623-26"><a href="national-crime-victimization-survey-ncvs.html#cb623-26" tabindex="-1"></a>ncvs_incident_df[ , <span class="st">&#39;sviolent&#39;</span> ] <span class="ot">&lt;-</span></span>
<span id="cb623-27"><a href="national-crime-victimization-survey-ncvs.html#cb623-27" tabindex="-1"></a>    <span class="fu">apply</span>( ncvs_incident_df[ , <span class="fu">c</span>( <span class="st">&#39;rsa&#39;</span> , <span class="st">&#39;rob&#39;</span> , <span class="st">&#39;aast&#39;</span> ) ] , <span class="dv">1</span> , any )</span></code></pre></div>
<p>Define personal theft and then person-crime on the incident data.frame:</p>
<div class="sourceCode" id="cb624"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb624-1"><a href="national-crime-victimization-survey-ncvs.html#cb624-1" tabindex="-1"></a>ncvs_incident_df[ , <span class="st">&#39;ptft&#39;</span> ] <span class="ot">&lt;-</span> </span>
<span id="cb624-2"><a href="national-crime-victimization-survey-ncvs.html#cb624-2" tabindex="-1"></a>    ncvs_incident_df[ , <span class="st">&#39;v4529&#39;</span> ] <span class="sc">%in%</span> <span class="dv">21</span><span class="sc">:</span><span class="dv">23</span></span>
<span id="cb624-3"><a href="national-crime-victimization-survey-ncvs.html#cb624-3" tabindex="-1"></a></span>
<span id="cb624-4"><a href="national-crime-victimization-survey-ncvs.html#cb624-4" tabindex="-1"></a>ncvs_incident_df[ , <span class="st">&#39;personcrime&#39;</span> ] <span class="ot">&lt;-</span></span>
<span id="cb624-5"><a href="national-crime-victimization-survey-ncvs.html#cb624-5" tabindex="-1"></a>    <span class="fu">apply</span>( ncvs_incident_df[ , <span class="fu">c</span>( <span class="st">&#39;violent&#39;</span> , <span class="st">&#39;ptft&#39;</span> ) ] , <span class="dv">1</span> , any )</span></code></pre></div>
<p>Define property crimes on the incident data.frame:</p>
<div class="sourceCode" id="cb625"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb625-1"><a href="national-crime-victimization-survey-ncvs.html#cb625-1" tabindex="-1"></a>ncvs_incident_df[ , <span class="st">&#39;hhburg&#39;</span> ] <span class="ot">&lt;-</span></span>
<span id="cb625-2"><a href="national-crime-victimization-survey-ncvs.html#cb625-2" tabindex="-1"></a>    ncvs_incident_df[ , <span class="st">&#39;v4529&#39;</span> ] <span class="sc">%in%</span> <span class="dv">31</span><span class="sc">:</span><span class="dv">33</span></span>
<span id="cb625-3"><a href="national-crime-victimization-survey-ncvs.html#cb625-3" tabindex="-1"></a></span>
<span id="cb625-4"><a href="national-crime-victimization-survey-ncvs.html#cb625-4" tabindex="-1"></a><span class="co"># completed theft with something taken</span></span>
<span id="cb625-5"><a href="national-crime-victimization-survey-ncvs.html#cb625-5" tabindex="-1"></a>ncvs_incident_df[ , <span class="st">&#39;burg_ct&#39;</span> ] <span class="ot">&lt;-</span></span>
<span id="cb625-6"><a href="national-crime-victimization-survey-ncvs.html#cb625-6" tabindex="-1"></a>        ( ncvs_incident_df[ , <span class="st">&#39;v4529&#39;</span> ] <span class="sc">%in%</span> <span class="dv">31</span><span class="sc">:</span><span class="dv">33</span> ) <span class="sc">&amp;</span></span>
<span id="cb625-7"><a href="national-crime-victimization-survey-ncvs.html#cb625-7" tabindex="-1"></a>        ( ncvs_incident_df[ , <span class="st">&#39;v4288&#39;</span> ] <span class="sc">%in%</span> <span class="dv">1</span> )</span>
<span id="cb625-8"><a href="national-crime-victimization-survey-ncvs.html#cb625-8" tabindex="-1"></a></span>
<span id="cb625-9"><a href="national-crime-victimization-survey-ncvs.html#cb625-9" tabindex="-1"></a><span class="co"># attempted theft</span></span>
<span id="cb625-10"><a href="national-crime-victimization-survey-ncvs.html#cb625-10" tabindex="-1"></a>ncvs_incident_df[ , <span class="st">&#39;burg_at&#39;</span> ] <span class="ot">&lt;-</span></span>
<span id="cb625-11"><a href="national-crime-victimization-survey-ncvs.html#cb625-11" tabindex="-1"></a>        ( ncvs_incident_df[ , <span class="st">&#39;v4529&#39;</span> ] <span class="sc">%in%</span> <span class="dv">31</span><span class="sc">:</span><span class="dv">33</span> ) <span class="sc">&amp;</span></span>
<span id="cb625-12"><a href="national-crime-victimization-survey-ncvs.html#cb625-12" tabindex="-1"></a>        ( ncvs_incident_df[ , <span class="st">&#39;v4290&#39;</span> ] <span class="sc">%in%</span> <span class="dv">1</span> )</span>
<span id="cb625-13"><a href="national-crime-victimization-survey-ncvs.html#cb625-13" tabindex="-1"></a></span>
<span id="cb625-14"><a href="national-crime-victimization-survey-ncvs.html#cb625-14" tabindex="-1"></a>ncvs_incident_df[ , <span class="st">&#39;burg_ncat&#39;</span> ] <span class="ot">&lt;-</span></span>
<span id="cb625-15"><a href="national-crime-victimization-survey-ncvs.html#cb625-15" tabindex="-1"></a>        ( ncvs_incident_df[ , <span class="st">&#39;v4529&#39;</span> ] <span class="sc">%in%</span> <span class="dv">31</span><span class="sc">:</span><span class="dv">33</span> ) <span class="sc">&amp;</span></span>
<span id="cb625-16"><a href="national-crime-victimization-survey-ncvs.html#cb625-16" tabindex="-1"></a>        ( ncvs_incident_df[ , <span class="st">&#39;v4288&#39;</span> ] <span class="sc">%in%</span> <span class="dv">2</span> ) <span class="sc">&amp;</span></span>
<span id="cb625-17"><a href="national-crime-victimization-survey-ncvs.html#cb625-17" tabindex="-1"></a>        ( ncvs_incident_df[ , <span class="st">&#39;v4290&#39;</span> ] <span class="sc">%in%</span> <span class="dv">2</span> )</span>
<span id="cb625-18"><a href="national-crime-victimization-survey-ncvs.html#cb625-18" tabindex="-1"></a></span>
<span id="cb625-19"><a href="national-crime-victimization-survey-ncvs.html#cb625-19" tabindex="-1"></a>ncvs_incident_df[ , <span class="st">&#39;burgcats2&#39;</span> ] <span class="ot">&lt;-</span> <span class="dv">0</span></span>
<span id="cb625-20"><a href="national-crime-victimization-survey-ncvs.html#cb625-20" tabindex="-1"></a>ncvs_incident_df[ ncvs_incident_df[ , <span class="st">&#39;burg_ncat&#39;</span> ] , <span class="st">&#39;burgcats2&#39;</span> ] <span class="ot">&lt;-</span> <span class="dv">2</span></span>
<span id="cb625-21"><a href="national-crime-victimization-survey-ncvs.html#cb625-21" tabindex="-1"></a>ncvs_incident_df[ ncvs_incident_df[ , <span class="st">&#39;burg_ct&#39;</span> ] <span class="sc">|</span> ncvs_incident_df[ , <span class="st">&#39;burg_at&#39;</span> ] , <span class="st">&#39;burgcats2&#39;</span> ] <span class="ot">&lt;-</span> <span class="dv">1</span></span>
<span id="cb625-22"><a href="national-crime-victimization-survey-ncvs.html#cb625-22" tabindex="-1"></a>    </span>
<span id="cb625-23"><a href="national-crime-victimization-survey-ncvs.html#cb625-23" tabindex="-1"></a></span>
<span id="cb625-24"><a href="national-crime-victimization-survey-ncvs.html#cb625-24" tabindex="-1"></a>ncvs_incident_df[ , <span class="st">&#39;burg&#39;</span> ] <span class="ot">&lt;-</span> </span>
<span id="cb625-25"><a href="national-crime-victimization-survey-ncvs.html#cb625-25" tabindex="-1"></a>    ncvs_incident_df[ , <span class="st">&#39;burgcats2&#39;</span> ] <span class="sc">%in%</span> <span class="dv">1</span></span>
<span id="cb625-26"><a href="national-crime-victimization-survey-ncvs.html#cb625-26" tabindex="-1"></a></span>
<span id="cb625-27"><a href="national-crime-victimization-survey-ncvs.html#cb625-27" tabindex="-1"></a><span class="co"># trespassing</span></span>
<span id="cb625-28"><a href="national-crime-victimization-survey-ncvs.html#cb625-28" tabindex="-1"></a>ncvs_incident_df[ , <span class="st">&#39;tres&#39;</span> ] <span class="ot">&lt;-</span> </span>
<span id="cb625-29"><a href="national-crime-victimization-survey-ncvs.html#cb625-29" tabindex="-1"></a>    ncvs_incident_df[ , <span class="st">&#39;burgcats2&#39;</span> ] <span class="sc">%in%</span> <span class="dv">2</span></span>
<span id="cb625-30"><a href="national-crime-victimization-survey-ncvs.html#cb625-30" tabindex="-1"></a></span>
<span id="cb625-31"><a href="national-crime-victimization-survey-ncvs.html#cb625-31" tabindex="-1"></a><span class="co"># motor vehicle theft</span></span>
<span id="cb625-32"><a href="national-crime-victimization-survey-ncvs.html#cb625-32" tabindex="-1"></a>ncvs_incident_df[ , <span class="st">&#39;mvtft&#39;</span> ] <span class="ot">&lt;-</span></span>
<span id="cb625-33"><a href="national-crime-victimization-survey-ncvs.html#cb625-33" tabindex="-1"></a>    ncvs_incident_df[ , <span class="st">&#39;v4529&#39;</span> ] <span class="sc">%in%</span> <span class="dv">40</span><span class="sc">:</span><span class="dv">41</span></span>
<span id="cb625-34"><a href="national-crime-victimization-survey-ncvs.html#cb625-34" tabindex="-1"></a></span>
<span id="cb625-35"><a href="national-crime-victimization-survey-ncvs.html#cb625-35" tabindex="-1"></a><span class="co"># household theft</span></span>
<span id="cb625-36"><a href="national-crime-victimization-survey-ncvs.html#cb625-36" tabindex="-1"></a>ncvs_incident_df[ , <span class="st">&#39;hhtft&#39;</span> ] <span class="ot">&lt;-</span></span>
<span id="cb625-37"><a href="national-crime-victimization-survey-ncvs.html#cb625-37" tabindex="-1"></a>    ncvs_incident_df[ , <span class="st">&#39;v4529&#39;</span> ] <span class="sc">%in%</span> <span class="dv">54</span><span class="sc">:</span><span class="dv">59</span></span>
<span id="cb625-38"><a href="national-crime-victimization-survey-ncvs.html#cb625-38" tabindex="-1"></a></span>
<span id="cb625-39"><a href="national-crime-victimization-survey-ncvs.html#cb625-39" tabindex="-1"></a><span class="co"># property crime</span></span>
<span id="cb625-40"><a href="national-crime-victimization-survey-ncvs.html#cb625-40" tabindex="-1"></a>ncvs_incident_df[ , <span class="st">&#39;property&#39;</span> ] <span class="ot">&lt;-</span></span>
<span id="cb625-41"><a href="national-crime-victimization-survey-ncvs.html#cb625-41" tabindex="-1"></a>    <span class="fu">apply</span>( ncvs_incident_df[ <span class="fu">c</span>( <span class="st">&#39;hhburg&#39;</span> , <span class="st">&#39;mvtft&#39;</span> , <span class="st">&#39;hhtft&#39;</span> ) ] , <span class="dv">1</span> , any )</span></code></pre></div>
<p>Define a series weight on the incident data.frame:</p>
<div class="sourceCode" id="cb626"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb626-1"><a href="national-crime-victimization-survey-ncvs.html#cb626-1" tabindex="-1"></a>ncvs_incident_df[ , <span class="st">&#39;series&#39;</span> ] <span class="ot">&lt;-</span> <span class="dv">2</span></span>
<span id="cb626-2"><a href="national-crime-victimization-survey-ncvs.html#cb626-2" tabindex="-1"></a></span>
<span id="cb626-3"><a href="national-crime-victimization-survey-ncvs.html#cb626-3" tabindex="-1"></a>ncvs_incident_df[ </span>
<span id="cb626-4"><a href="national-crime-victimization-survey-ncvs.html#cb626-4" tabindex="-1"></a></span>
<span id="cb626-5"><a href="national-crime-victimization-survey-ncvs.html#cb626-5" tabindex="-1"></a>    ncvs_incident_df[ , <span class="st">&#39;v4017&#39;</span> ] <span class="sc">%in%</span> <span class="fu">c</span>( <span class="dv">1</span> , <span class="dv">8</span> ) <span class="sc">|</span></span>
<span id="cb626-6"><a href="national-crime-victimization-survey-ncvs.html#cb626-6" tabindex="-1"></a>    ncvs_incident_df[ , <span class="st">&#39;v4018&#39;</span> ] <span class="sc">%in%</span> <span class="fu">c</span>( <span class="dv">2</span> , <span class="dv">8</span> ) <span class="sc">|</span></span>
<span id="cb626-7"><a href="national-crime-victimization-survey-ncvs.html#cb626-7" tabindex="-1"></a>    ncvs_incident_df[ , <span class="st">&#39;v4019&#39;</span> ] <span class="sc">%in%</span> <span class="fu">c</span>( <span class="dv">1</span> , <span class="dv">8</span> )</span>
<span id="cb626-8"><a href="national-crime-victimization-survey-ncvs.html#cb626-8" tabindex="-1"></a></span>
<span id="cb626-9"><a href="national-crime-victimization-survey-ncvs.html#cb626-9" tabindex="-1"></a>    , <span class="st">&#39;series&#39;</span> ] <span class="ot">&lt;-</span> <span class="dv">1</span></span>
<span id="cb626-10"><a href="national-crime-victimization-survey-ncvs.html#cb626-10" tabindex="-1"></a>     </span>
<span id="cb626-11"><a href="national-crime-victimization-survey-ncvs.html#cb626-11" tabindex="-1"></a>ncvs_incident_df[ , <span class="st">&#39;serieswgt&#39;</span> ] <span class="ot">&lt;-</span> <span class="dv">1</span></span>
<span id="cb626-12"><a href="national-crime-victimization-survey-ncvs.html#cb626-12" tabindex="-1"></a></span>
<span id="cb626-13"><a href="national-crime-victimization-survey-ncvs.html#cb626-13" tabindex="-1"></a>ncvs_incident_df[ <span class="sc">!</span>( ncvs_incident_df[ , <span class="st">&#39;v4016&#39;</span> ] <span class="sc">%in%</span> <span class="dv">997</span><span class="sc">:</span><span class="dv">998</span> ) , <span class="st">&#39;n10v4016&#39;</span> ] <span class="ot">&lt;-</span></span>
<span id="cb626-14"><a href="national-crime-victimization-survey-ncvs.html#cb626-14" tabindex="-1"></a>    <span class="fu">pmin</span>( ncvs_incident_df[ <span class="sc">!</span>( ncvs_incident_df[ , <span class="st">&#39;v4016&#39;</span> ] <span class="sc">%in%</span> <span class="dv">997</span><span class="sc">:</span><span class="dv">998</span> ) , <span class="st">&#39;v4016&#39;</span> ] , <span class="dv">10</span> )</span>
<span id="cb626-15"><a href="national-crime-victimization-survey-ncvs.html#cb626-15" tabindex="-1"></a>     </span>
<span id="cb626-16"><a href="national-crime-victimization-survey-ncvs.html#cb626-16" tabindex="-1"></a>ncvs_incident_df[ ncvs_incident_df[ , <span class="st">&#39;series&#39;</span> ] <span class="sc">==</span> <span class="dv">2</span> , <span class="st">&#39;serieswgt&#39;</span> ] <span class="ot">&lt;-</span></span>
<span id="cb626-17"><a href="national-crime-victimization-survey-ncvs.html#cb626-17" tabindex="-1"></a>    ncvs_incident_df[ ncvs_incident_df[ , <span class="st">&#39;series&#39;</span> ] <span class="sc">==</span> <span class="dv">2</span> , <span class="st">&#39;n10v4016&#39;</span> ]</span>
<span id="cb626-18"><a href="national-crime-victimization-survey-ncvs.html#cb626-18" tabindex="-1"></a></span>
<span id="cb626-19"><a href="national-crime-victimization-survey-ncvs.html#cb626-19" tabindex="-1"></a>ncvs_incident_df[ ncvs_incident_df[ , <span class="st">&#39;series&#39;</span> ] <span class="sc">==</span> <span class="dv">2</span> <span class="sc">&amp;</span> <span class="fu">is.na</span>( ncvs_incident_df[ , <span class="st">&#39;n10v4016&#39;</span> ] ) , <span class="st">&#39;serieswgt&#39;</span> ] <span class="ot">&lt;-</span> <span class="dv">6</span></span></code></pre></div>
<p>Aggregate property-crimes to the household-interview level:</p>
<div class="sourceCode" id="cb627"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb627-1"><a href="national-crime-victimization-survey-ncvs.html#cb627-1" tabindex="-1"></a>summed_hh_crimes <span class="ot">&lt;-</span></span>
<span id="cb627-2"><a href="national-crime-victimization-survey-ncvs.html#cb627-2" tabindex="-1"></a>    <span class="fu">aggregate</span>(</span>
<span id="cb627-3"><a href="national-crime-victimization-survey-ncvs.html#cb627-3" tabindex="-1"></a>        <span class="fu">cbind</span>(</span>
<span id="cb627-4"><a href="national-crime-victimization-survey-ncvs.html#cb627-4" tabindex="-1"></a>            property <span class="sc">*</span> serieswgt ,</span>
<span id="cb627-5"><a href="national-crime-victimization-survey-ncvs.html#cb627-5" tabindex="-1"></a>            hhburg <span class="sc">*</span> serieswgt ,</span>
<span id="cb627-6"><a href="national-crime-victimization-survey-ncvs.html#cb627-6" tabindex="-1"></a>            mvtft <span class="sc">*</span> serieswgt ,</span>
<span id="cb627-7"><a href="national-crime-victimization-survey-ncvs.html#cb627-7" tabindex="-1"></a>            burg <span class="sc">*</span> serieswgt ,</span>
<span id="cb627-8"><a href="national-crime-victimization-survey-ncvs.html#cb627-8" tabindex="-1"></a>            tres <span class="sc">*</span> serieswgt</span>
<span id="cb627-9"><a href="national-crime-victimization-survey-ncvs.html#cb627-9" tabindex="-1"></a>        ) <span class="sc">~</span> yearq <span class="sc">+</span> idhh <span class="sc">+</span> v4002 <span class="sc">+</span> wgtviccy ,</span>
<span id="cb627-10"><a href="national-crime-victimization-survey-ncvs.html#cb627-10" tabindex="-1"></a>        </span>
<span id="cb627-11"><a href="national-crime-victimization-survey-ncvs.html#cb627-11" tabindex="-1"></a>        <span class="at">data =</span> <span class="fu">subset</span>( ncvs_incident_df , <span class="sc">!</span>exclude_outus <span class="sc">&amp;</span> property ) ,</span>
<span id="cb627-12"><a href="national-crime-victimization-survey-ncvs.html#cb627-12" tabindex="-1"></a>        </span>
<span id="cb627-13"><a href="national-crime-victimization-survey-ncvs.html#cb627-13" tabindex="-1"></a>        sum</span>
<span id="cb627-14"><a href="national-crime-victimization-survey-ncvs.html#cb627-14" tabindex="-1"></a>    )</span>
<span id="cb627-15"><a href="national-crime-victimization-survey-ncvs.html#cb627-15" tabindex="-1"></a></span>
<span id="cb627-16"><a href="national-crime-victimization-survey-ncvs.html#cb627-16" tabindex="-1"></a><span class="fu">names</span>( summed_hh_crimes ) <span class="ot">&lt;-</span></span>
<span id="cb627-17"><a href="national-crime-victimization-survey-ncvs.html#cb627-17" tabindex="-1"></a>    <span class="fu">c</span>( <span class="st">&#39;yearq&#39;</span> , <span class="st">&#39;idhh&#39;</span> , <span class="st">&#39;v2002&#39;</span> , <span class="st">&#39;wgtviccy&#39;</span> , <span class="st">&#39;property&#39;</span> , <span class="st">&#39;hhburg&#39;</span> , </span>
<span id="cb627-18"><a href="national-crime-victimization-survey-ncvs.html#cb627-18" tabindex="-1"></a>    <span class="st">&#39;mvtft&#39;</span> , <span class="st">&#39;burg&#39;</span> , <span class="st">&#39;tres&#39;</span> )</span></code></pre></div>
<p>Merge aggregated property-crimes on to the household-interview data.frame:</p>
<div class="sourceCode" id="cb628"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb628-1"><a href="national-crime-victimization-survey-ncvs.html#cb628-1" tabindex="-1"></a>ncvs_household_df <span class="ot">&lt;-</span> <span class="fu">left_join_zero_missings</span>( ncvs_household_df , summed_hh_crimes )</span>
<span id="cb628-2"><a href="national-crime-victimization-survey-ncvs.html#cb628-2" tabindex="-1"></a></span>
<span id="cb628-3"><a href="national-crime-victimization-survey-ncvs.html#cb628-3" tabindex="-1"></a><span class="fu">rm</span>( summed_hh_crimes ) ; <span class="fu">gc</span>()</span></code></pre></div>
<p>Aggregate person-crimes to the person-interview level:</p>
<div class="sourceCode" id="cb629"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb629-1"><a href="national-crime-victimization-survey-ncvs.html#cb629-1" tabindex="-1"></a>summed_person_crimes <span class="ot">&lt;-</span></span>
<span id="cb629-2"><a href="national-crime-victimization-survey-ncvs.html#cb629-2" tabindex="-1"></a>    <span class="fu">aggregate</span>(</span>
<span id="cb629-3"><a href="national-crime-victimization-survey-ncvs.html#cb629-3" tabindex="-1"></a>        <span class="fu">cbind</span>(</span>
<span id="cb629-4"><a href="national-crime-victimization-survey-ncvs.html#cb629-4" tabindex="-1"></a>            violent <span class="sc">*</span> serieswgt ,</span>
<span id="cb629-5"><a href="national-crime-victimization-survey-ncvs.html#cb629-5" tabindex="-1"></a>            sviolent <span class="sc">*</span> serieswgt ,</span>
<span id="cb629-6"><a href="national-crime-victimization-survey-ncvs.html#cb629-6" tabindex="-1"></a>            rsa <span class="sc">*</span> serieswgt ,</span>
<span id="cb629-7"><a href="national-crime-victimization-survey-ncvs.html#cb629-7" tabindex="-1"></a>            rob <span class="sc">*</span> serieswgt ,</span>
<span id="cb629-8"><a href="national-crime-victimization-survey-ncvs.html#cb629-8" tabindex="-1"></a>            aast <span class="sc">*</span> serieswgt ,</span>
<span id="cb629-9"><a href="national-crime-victimization-survey-ncvs.html#cb629-9" tabindex="-1"></a>            sast <span class="sc">*</span> serieswgt ,</span>
<span id="cb629-10"><a href="national-crime-victimization-survey-ncvs.html#cb629-10" tabindex="-1"></a>            ptft <span class="sc">*</span> serieswgt</span>
<span id="cb629-11"><a href="national-crime-victimization-survey-ncvs.html#cb629-11" tabindex="-1"></a>        ) <span class="sc">~</span> yearq <span class="sc">+</span> idhh <span class="sc">+</span> v4002 <span class="sc">+</span> idper <span class="sc">+</span> wgtviccy ,</span>
<span id="cb629-12"><a href="national-crime-victimization-survey-ncvs.html#cb629-12" tabindex="-1"></a>        </span>
<span id="cb629-13"><a href="national-crime-victimization-survey-ncvs.html#cb629-13" tabindex="-1"></a>        <span class="at">data =</span> <span class="fu">subset</span>( ncvs_incident_df , <span class="sc">!</span>exclude_outus <span class="sc">&amp;</span> personcrime ) ,</span>
<span id="cb629-14"><a href="national-crime-victimization-survey-ncvs.html#cb629-14" tabindex="-1"></a>        </span>
<span id="cb629-15"><a href="national-crime-victimization-survey-ncvs.html#cb629-15" tabindex="-1"></a>        sum</span>
<span id="cb629-16"><a href="national-crime-victimization-survey-ncvs.html#cb629-16" tabindex="-1"></a>    )</span>
<span id="cb629-17"><a href="national-crime-victimization-survey-ncvs.html#cb629-17" tabindex="-1"></a>    </span>
<span id="cb629-18"><a href="national-crime-victimization-survey-ncvs.html#cb629-18" tabindex="-1"></a></span>
<span id="cb629-19"><a href="national-crime-victimization-survey-ncvs.html#cb629-19" tabindex="-1"></a><span class="fu">names</span>( summed_person_crimes ) <span class="ot">&lt;-</span></span>
<span id="cb629-20"><a href="national-crime-victimization-survey-ncvs.html#cb629-20" tabindex="-1"></a>    <span class="fu">c</span>( <span class="st">&#39;yearq&#39;</span> , <span class="st">&#39;idhh&#39;</span> , <span class="st">&#39;v3002&#39;</span> , <span class="st">&#39;idper&#39;</span> , <span class="st">&#39;wgtviccy&#39;</span> , <span class="st">&#39;violent&#39;</span> , </span>
<span id="cb629-21"><a href="national-crime-victimization-survey-ncvs.html#cb629-21" tabindex="-1"></a>    <span class="st">&#39;sviolent&#39;</span> , <span class="st">&#39;rsa&#39;</span> , <span class="st">&#39;rob&#39;</span> , <span class="st">&#39;aast&#39;</span> , <span class="st">&#39;sast&#39;</span> , <span class="st">&#39;ptft&#39;</span> )</span></code></pre></div>
<p>Merge aggregated property-crimes on to the person-interview data.frame:</p>
<div class="sourceCode" id="cb630"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb630-1"><a href="national-crime-victimization-survey-ncvs.html#cb630-1" tabindex="-1"></a>ncvs_person_df <span class="ot">&lt;-</span> <span class="fu">left_join_zero_missings</span>( ncvs_person_df , summed_person_crimes )</span>
<span id="cb630-2"><a href="national-crime-victimization-survey-ncvs.html#cb630-2" tabindex="-1"></a></span>
<span id="cb630-3"><a href="national-crime-victimization-survey-ncvs.html#cb630-3" tabindex="-1"></a><span class="fu">rm</span>( summed_person_crimes ) ; <span class="fu">gc</span>()</span></code></pre></div>
<p><strong>Starting here, the weight calculation prepares an adjustment for <em>all violence combined</em> with the variables <code>violent</code> and <code>violent_year</code>. To calculate the prevalence rate of a subset of person-crimes, starting at this point, replace these two values with variables like <code>rob</code> and <code>rob_year</code>.</strong></p>
<p>Aggregate violent crimes to the person-year level:</p>
<div class="sourceCode" id="cb631"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb631-1"><a href="national-crime-victimization-survey-ncvs.html#cb631-1" tabindex="-1"></a>summed_person_year_violent_crimes <span class="ot">&lt;-</span></span>
<span id="cb631-2"><a href="national-crime-victimization-survey-ncvs.html#cb631-2" tabindex="-1"></a>    <span class="fu">aggregate</span>(</span>
<span id="cb631-3"><a href="national-crime-victimization-survey-ncvs.html#cb631-3" tabindex="-1"></a>        violent <span class="sc">*</span> serieswgt <span class="sc">~</span> idhh <span class="sc">+</span> idper <span class="sc">+</span> year ,</span>
<span id="cb631-4"><a href="national-crime-victimization-survey-ncvs.html#cb631-4" tabindex="-1"></a>        <span class="at">data =</span> <span class="fu">subset</span>( ncvs_incident_df , <span class="sc">!</span>exclude_outus <span class="sc">&amp;</span> violent ) ,</span>
<span id="cb631-5"><a href="national-crime-victimization-survey-ncvs.html#cb631-5" tabindex="-1"></a>        sum</span>
<span id="cb631-6"><a href="national-crime-victimization-survey-ncvs.html#cb631-6" tabindex="-1"></a>    )</span>
<span id="cb631-7"><a href="national-crime-victimization-survey-ncvs.html#cb631-7" tabindex="-1"></a></span>
<span id="cb631-8"><a href="national-crime-victimization-survey-ncvs.html#cb631-8" tabindex="-1"></a><span class="fu">names</span>( summed_person_year_violent_crimes )[ <span class="fu">ncol</span>( summed_person_year_violent_crimes ) ] <span class="ot">&lt;-</span> </span>
<span id="cb631-9"><a href="national-crime-victimization-survey-ncvs.html#cb631-9" tabindex="-1"></a>    <span class="st">&#39;violent_year&#39;</span></span></code></pre></div>
<p>Merge aggregated person-year violent crime series weights on to the person-interview data.frame:</p>
<div class="sourceCode" id="cb632"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb632-1"><a href="national-crime-victimization-survey-ncvs.html#cb632-1" tabindex="-1"></a>ncvs_person_df <span class="ot">&lt;-</span> <span class="fu">left_join_zero_missings</span>( ncvs_person_df , summed_person_year_violent_crimes )</span>
<span id="cb632-2"><a href="national-crime-victimization-survey-ncvs.html#cb632-2" tabindex="-1"></a></span>
<span id="cb632-3"><a href="national-crime-victimization-survey-ncvs.html#cb632-3" tabindex="-1"></a><span class="fu">rm</span>( summed_person_year_violent_crimes ) ; <span class="fu">gc</span>()</span></code></pre></div>
<p>Aggregate violent crimes to the person-half-year level, then reshape into a wide data.frame:</p>
<div class="sourceCode" id="cb633"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb633-1"><a href="national-crime-victimization-survey-ncvs.html#cb633-1" tabindex="-1"></a>summed_person_half_year_violent_crimes <span class="ot">&lt;-</span></span>
<span id="cb633-2"><a href="national-crime-victimization-survey-ncvs.html#cb633-2" tabindex="-1"></a>    <span class="fu">aggregate</span>(</span>
<span id="cb633-3"><a href="national-crime-victimization-survey-ncvs.html#cb633-3" tabindex="-1"></a>        wgtviccy <span class="sc">~</span> idhh <span class="sc">+</span> idper <span class="sc">+</span> year <span class="sc">+</span> half_year ,</span>
<span id="cb633-4"><a href="national-crime-victimization-survey-ncvs.html#cb633-4" tabindex="-1"></a>        <span class="at">data =</span> <span class="fu">subset</span>( ncvs_incident_df , <span class="sc">!</span>exclude_outus <span class="sc">&amp;</span> violent ) ,</span>
<span id="cb633-5"><a href="national-crime-victimization-survey-ncvs.html#cb633-5" tabindex="-1"></a>        mean</span>
<span id="cb633-6"><a href="national-crime-victimization-survey-ncvs.html#cb633-6" tabindex="-1"></a>    )</span>
<span id="cb633-7"><a href="national-crime-victimization-survey-ncvs.html#cb633-7" tabindex="-1"></a></span>
<span id="cb633-8"><a href="national-crime-victimization-survey-ncvs.html#cb633-8" tabindex="-1"></a>first_half_violent_crimes <span class="ot">&lt;-</span></span>
<span id="cb633-9"><a href="national-crime-victimization-survey-ncvs.html#cb633-9" tabindex="-1"></a>    <span class="fu">subset</span>( summed_person_half_year_violent_crimes , half_year <span class="sc">==</span> <span class="dv">1</span> )</span>
<span id="cb633-10"><a href="national-crime-victimization-survey-ncvs.html#cb633-10" tabindex="-1"></a>    </span>
<span id="cb633-11"><a href="national-crime-victimization-survey-ncvs.html#cb633-11" tabindex="-1"></a>second_half_violent_crimes <span class="ot">&lt;-</span></span>
<span id="cb633-12"><a href="national-crime-victimization-survey-ncvs.html#cb633-12" tabindex="-1"></a>    <span class="fu">subset</span>( summed_person_half_year_violent_crimes , half_year <span class="sc">==</span> <span class="dv">2</span> )</span>
<span id="cb633-13"><a href="national-crime-victimization-survey-ncvs.html#cb633-13" tabindex="-1"></a></span>
<span id="cb633-14"><a href="national-crime-victimization-survey-ncvs.html#cb633-14" tabindex="-1"></a>first_half_violent_crimes[ , <span class="st">&#39;half_year&#39;</span> ] <span class="ot">&lt;-</span></span>
<span id="cb633-15"><a href="national-crime-victimization-survey-ncvs.html#cb633-15" tabindex="-1"></a>    second_half_violent_crimes[ , <span class="st">&#39;half_year&#39;</span> ] <span class="ot">&lt;-</span> <span class="cn">NULL</span></span>
<span id="cb633-16"><a href="national-crime-victimization-survey-ncvs.html#cb633-16" tabindex="-1"></a>    </span>
<span id="cb633-17"><a href="national-crime-victimization-survey-ncvs.html#cb633-17" tabindex="-1"></a><span class="fu">names</span>( first_half_violent_crimes )[ <span class="fu">ncol</span>( first_half_violent_crimes ) ] <span class="ot">&lt;-</span> <span class="st">&#39;vwgt1&#39;</span></span>
<span id="cb633-18"><a href="national-crime-victimization-survey-ncvs.html#cb633-18" tabindex="-1"></a><span class="fu">names</span>( second_half_violent_crimes )[ <span class="fu">ncol</span>( second_half_violent_crimes ) ] <span class="ot">&lt;-</span> <span class="st">&#39;vwgt2&#39;</span></span>
<span id="cb633-19"><a href="national-crime-victimization-survey-ncvs.html#cb633-19" tabindex="-1"></a></span>
<span id="cb633-20"><a href="national-crime-victimization-survey-ncvs.html#cb633-20" tabindex="-1"></a>wide_person_half_year_violent_crimes <span class="ot">&lt;-</span></span>
<span id="cb633-21"><a href="national-crime-victimization-survey-ncvs.html#cb633-21" tabindex="-1"></a>    <span class="fu">merge</span>(</span>
<span id="cb633-22"><a href="national-crime-victimization-survey-ncvs.html#cb633-22" tabindex="-1"></a>        first_half_violent_crimes ,</span>
<span id="cb633-23"><a href="national-crime-victimization-survey-ncvs.html#cb633-23" tabindex="-1"></a>        second_half_violent_crimes ,</span>
<span id="cb633-24"><a href="national-crime-victimization-survey-ncvs.html#cb633-24" tabindex="-1"></a>        <span class="at">all =</span> <span class="cn">TRUE</span></span>
<span id="cb633-25"><a href="national-crime-victimization-survey-ncvs.html#cb633-25" tabindex="-1"></a>    )</span></code></pre></div>
<p>Merge both violent crime weights on to the person-interview data.frame:</p>
<div class="sourceCode" id="cb634"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb634-1"><a href="national-crime-victimization-survey-ncvs.html#cb634-1" tabindex="-1"></a>ncvs_person_df <span class="ot">&lt;-</span> <span class="fu">left_join_zero_missings</span>( ncvs_person_df , wide_person_half_year_violent_crimes )</span>
<span id="cb634-2"><a href="national-crime-victimization-survey-ncvs.html#cb634-2" tabindex="-1"></a></span>
<span id="cb634-3"><a href="national-crime-victimization-survey-ncvs.html#cb634-3" tabindex="-1"></a><span class="fu">rm</span>( wide_person_half_year_violent_crimes ) ; <span class="fu">gc</span>()</span></code></pre></div>
<p>Find the maximum incident victim weight among three half-year periods:</p>
<div class="sourceCode" id="cb635"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb635-1"><a href="national-crime-victimization-survey-ncvs.html#cb635-1" tabindex="-1"></a>max_half_v_crimes <span class="ot">&lt;-</span></span>
<span id="cb635-2"><a href="national-crime-victimization-survey-ncvs.html#cb635-2" tabindex="-1"></a>    <span class="fu">aggregate</span>(</span>
<span id="cb635-3"><a href="national-crime-victimization-survey-ncvs.html#cb635-3" tabindex="-1"></a>        wgtviccy <span class="sc">~</span> idhh <span class="sc">+</span> idper <span class="sc">+</span> year <span class="sc">+</span> half_year <span class="sc">+</span> v4002 ,</span>
<span id="cb635-4"><a href="national-crime-victimization-survey-ncvs.html#cb635-4" tabindex="-1"></a>        <span class="at">data =</span> <span class="fu">subset</span>( ncvs_incident_df , <span class="sc">!</span>exclude_outus <span class="sc">&amp;</span> violent ) ,</span>
<span id="cb635-5"><a href="national-crime-victimization-survey-ncvs.html#cb635-5" tabindex="-1"></a>        max</span>
<span id="cb635-6"><a href="national-crime-victimization-survey-ncvs.html#cb635-6" tabindex="-1"></a>    )</span>
<span id="cb635-7"><a href="national-crime-victimization-survey-ncvs.html#cb635-7" tabindex="-1"></a></span>
<span id="cb635-8"><a href="national-crime-victimization-survey-ncvs.html#cb635-8" tabindex="-1"></a>max_half_v_crimes <span class="ot">&lt;-</span></span>
<span id="cb635-9"><a href="national-crime-victimization-survey-ncvs.html#cb635-9" tabindex="-1"></a>    max_half_v_crimes[ </span>
<span id="cb635-10"><a href="national-crime-victimization-survey-ncvs.html#cb635-10" tabindex="-1"></a>        <span class="fu">do.call</span>( </span>
<span id="cb635-11"><a href="national-crime-victimization-survey-ncvs.html#cb635-11" tabindex="-1"></a>            order , </span>
<span id="cb635-12"><a href="national-crime-victimization-survey-ncvs.html#cb635-12" tabindex="-1"></a>            max_half_v_crimes[ <span class="fu">c</span>( <span class="st">&#39;idhh&#39;</span> , <span class="st">&#39;idper&#39;</span> , <span class="st">&#39;year&#39;</span> , <span class="st">&#39;half_year&#39;</span> ) ] ) , </span>
<span id="cb635-13"><a href="national-crime-victimization-survey-ncvs.html#cb635-13" tabindex="-1"></a>    ]</span>
<span id="cb635-14"><a href="national-crime-victimization-survey-ncvs.html#cb635-14" tabindex="-1"></a></span>
<span id="cb635-15"><a href="national-crime-victimization-survey-ncvs.html#cb635-15" tabindex="-1"></a>max_half_v_crimes[ , <span class="st">&#39;byvar&#39;</span> ] <span class="ot">&lt;-</span></span>
<span id="cb635-16"><a href="national-crime-victimization-survey-ncvs.html#cb635-16" tabindex="-1"></a>    <span class="fu">apply</span>( </span>
<span id="cb635-17"><a href="national-crime-victimization-survey-ncvs.html#cb635-17" tabindex="-1"></a>        max_half_v_crimes[ <span class="fu">c</span>( <span class="st">&#39;idhh&#39;</span> , <span class="st">&#39;idper&#39;</span> , <span class="st">&#39;year&#39;</span> , <span class="st">&#39;half_year&#39;</span> ) ] , </span>
<span id="cb635-18"><a href="national-crime-victimization-survey-ncvs.html#cb635-18" tabindex="-1"></a>        <span class="dv">1</span> , </span>
<span id="cb635-19"><a href="national-crime-victimization-survey-ncvs.html#cb635-19" tabindex="-1"></a>        paste , </span>
<span id="cb635-20"><a href="national-crime-victimization-survey-ncvs.html#cb635-20" tabindex="-1"></a>        <span class="at">collapse =</span> <span class="st">&#39; &#39;</span> </span>
<span id="cb635-21"><a href="national-crime-victimization-survey-ncvs.html#cb635-21" tabindex="-1"></a>    )</span>
<span id="cb635-22"><a href="national-crime-victimization-survey-ncvs.html#cb635-22" tabindex="-1"></a>    </span>
<span id="cb635-23"><a href="national-crime-victimization-survey-ncvs.html#cb635-23" tabindex="-1"></a>max_half_v_crimes[ <span class="dv">1</span> , <span class="st">&#39;id&#39;</span> ] <span class="ot">&lt;-</span> <span class="dv">1</span></span>
<span id="cb635-24"><a href="national-crime-victimization-survey-ncvs.html#cb635-24" tabindex="-1"></a></span>
<span id="cb635-25"><a href="national-crime-victimization-survey-ncvs.html#cb635-25" tabindex="-1"></a><span class="cf">for</span>( i <span class="cf">in</span> <span class="fu">seq</span>( <span class="dv">2</span> , <span class="fu">nrow</span>( max_half_v_crimes ) ) ){</span>
<span id="cb635-26"><a href="national-crime-victimization-survey-ncvs.html#cb635-26" tabindex="-1"></a></span>
<span id="cb635-27"><a href="national-crime-victimization-survey-ncvs.html#cb635-27" tabindex="-1"></a>    <span class="cf">if</span>( max_half_v_crimes[ i , <span class="st">&#39;byvar&#39;</span> ] <span class="sc">==</span> max_half_v_crimes[ i <span class="sc">-</span> <span class="dv">1</span> , <span class="st">&#39;byvar&#39;</span> ] ){</span>
<span id="cb635-28"><a href="national-crime-victimization-survey-ncvs.html#cb635-28" tabindex="-1"></a>    </span>
<span id="cb635-29"><a href="national-crime-victimization-survey-ncvs.html#cb635-29" tabindex="-1"></a>        max_half_v_crimes[ i , <span class="st">&#39;id&#39;</span> ] <span class="ot">&lt;-</span> max_half_v_crimes[ i <span class="sc">-</span> <span class="dv">1</span> , <span class="st">&#39;id&#39;</span> ] <span class="sc">+</span> <span class="dv">1</span></span>
<span id="cb635-30"><a href="national-crime-victimization-survey-ncvs.html#cb635-30" tabindex="-1"></a>        </span>
<span id="cb635-31"><a href="national-crime-victimization-survey-ncvs.html#cb635-31" tabindex="-1"></a>    } <span class="cf">else</span> {</span>
<span id="cb635-32"><a href="national-crime-victimization-survey-ncvs.html#cb635-32" tabindex="-1"></a>    </span>
<span id="cb635-33"><a href="national-crime-victimization-survey-ncvs.html#cb635-33" tabindex="-1"></a>        max_half_v_crimes[ i , <span class="st">&#39;id&#39;</span> ] <span class="ot">&lt;-</span> <span class="dv">1</span></span>
<span id="cb635-34"><a href="national-crime-victimization-survey-ncvs.html#cb635-34" tabindex="-1"></a>        </span>
<span id="cb635-35"><a href="national-crime-victimization-survey-ncvs.html#cb635-35" tabindex="-1"></a>    }</span>
<span id="cb635-36"><a href="national-crime-victimization-survey-ncvs.html#cb635-36" tabindex="-1"></a>}</span>
<span id="cb635-37"><a href="national-crime-victimization-survey-ncvs.html#cb635-37" tabindex="-1"></a></span>
<span id="cb635-38"><a href="national-crime-victimization-survey-ncvs.html#cb635-38" tabindex="-1"></a>max_half_v_crimes[ , <span class="st">&#39;label&#39;</span> ] <span class="ot">&lt;-</span> </span>
<span id="cb635-39"><a href="national-crime-victimization-survey-ncvs.html#cb635-39" tabindex="-1"></a>    <span class="fu">paste0</span>( </span>
<span id="cb635-40"><a href="national-crime-victimization-survey-ncvs.html#cb635-40" tabindex="-1"></a>        <span class="st">&#39;_&#39;</span> , </span>
<span id="cb635-41"><a href="national-crime-victimization-survey-ncvs.html#cb635-41" tabindex="-1"></a>        max_half_v_crimes[ , <span class="st">&#39;half_year&#39;</span> ] , </span>
<span id="cb635-42"><a href="national-crime-victimization-survey-ncvs.html#cb635-42" tabindex="-1"></a>        <span class="st">&#39;_&#39;</span> , </span>
<span id="cb635-43"><a href="national-crime-victimization-survey-ncvs.html#cb635-43" tabindex="-1"></a>        max_half_v_crimes[ , <span class="st">&#39;id&#39;</span> ] </span>
<span id="cb635-44"><a href="national-crime-victimization-survey-ncvs.html#cb635-44" tabindex="-1"></a>    )</span>
<span id="cb635-45"><a href="national-crime-victimization-survey-ncvs.html#cb635-45" tabindex="-1"></a></span>
<span id="cb635-46"><a href="national-crime-victimization-survey-ncvs.html#cb635-46" tabindex="-1"></a>max_half_v_crimes[ , <span class="st">&#39;byvar&#39;</span> ] <span class="ot">&lt;-</span> <span class="cn">NULL</span></span>
<span id="cb635-47"><a href="national-crime-victimization-survey-ncvs.html#cb635-47" tabindex="-1"></a></span>
<span id="cb635-48"><a href="national-crime-victimization-survey-ncvs.html#cb635-48" tabindex="-1"></a><span class="fu">stopifnot</span>( <span class="fu">all</span>( max_half_v_crimes[ , <span class="st">&#39;label&#39;</span> ] <span class="sc">%in%</span> <span class="fu">c</span>( <span class="st">&#39;_1_1&#39;</span> , <span class="st">&#39;_2_1&#39;</span> , <span class="st">&#39;_1_2&#39;</span> ) ) )</span>
<span id="cb635-49"><a href="national-crime-victimization-survey-ncvs.html#cb635-49" tabindex="-1"></a></span>
<span id="cb635-50"><a href="national-crime-victimization-survey-ncvs.html#cb635-50" tabindex="-1"></a>h_1_1_df <span class="ot">&lt;-</span></span>
<span id="cb635-51"><a href="national-crime-victimization-survey-ncvs.html#cb635-51" tabindex="-1"></a>    max_half_v_crimes[ </span>
<span id="cb635-52"><a href="national-crime-victimization-survey-ncvs.html#cb635-52" tabindex="-1"></a>        max_half_v_crimes[ , <span class="st">&#39;label&#39;</span> ] <span class="sc">==</span> <span class="st">&#39;_1_1&#39;</span> , </span>
<span id="cb635-53"><a href="national-crime-victimization-survey-ncvs.html#cb635-53" tabindex="-1"></a>        <span class="fu">c</span>( <span class="st">&#39;idhh&#39;</span> , <span class="st">&#39;idper&#39;</span> , <span class="st">&#39;year&#39;</span> , <span class="st">&#39;wgtviccy&#39;</span> )</span>
<span id="cb635-54"><a href="national-crime-victimization-survey-ncvs.html#cb635-54" tabindex="-1"></a>    ]</span>
<span id="cb635-55"><a href="national-crime-victimization-survey-ncvs.html#cb635-55" tabindex="-1"></a>    </span>
<span id="cb635-56"><a href="national-crime-victimization-survey-ncvs.html#cb635-56" tabindex="-1"></a><span class="fu">names</span>( h_1_1_df )[ <span class="fu">ncol</span>( h_1_1_df ) ] <span class="ot">&lt;-</span> <span class="st">&#39;wgtviccy_1_1&#39;</span></span>
<span id="cb635-57"><a href="national-crime-victimization-survey-ncvs.html#cb635-57" tabindex="-1"></a>    </span>
<span id="cb635-58"><a href="national-crime-victimization-survey-ncvs.html#cb635-58" tabindex="-1"></a>h_2_1_df <span class="ot">&lt;-</span></span>
<span id="cb635-59"><a href="national-crime-victimization-survey-ncvs.html#cb635-59" tabindex="-1"></a>    max_half_v_crimes[ </span>
<span id="cb635-60"><a href="national-crime-victimization-survey-ncvs.html#cb635-60" tabindex="-1"></a>        max_half_v_crimes[ , <span class="st">&#39;label&#39;</span> ] <span class="sc">==</span> <span class="st">&#39;_2_1&#39;</span> , </span>
<span id="cb635-61"><a href="national-crime-victimization-survey-ncvs.html#cb635-61" tabindex="-1"></a>        <span class="fu">c</span>( <span class="st">&#39;idhh&#39;</span> , <span class="st">&#39;idper&#39;</span> , <span class="st">&#39;year&#39;</span> , <span class="st">&#39;wgtviccy&#39;</span> )</span>
<span id="cb635-62"><a href="national-crime-victimization-survey-ncvs.html#cb635-62" tabindex="-1"></a>    ]</span>
<span id="cb635-63"><a href="national-crime-victimization-survey-ncvs.html#cb635-63" tabindex="-1"></a>    </span>
<span id="cb635-64"><a href="national-crime-victimization-survey-ncvs.html#cb635-64" tabindex="-1"></a><span class="fu">names</span>( h_2_1_df )[ <span class="fu">ncol</span>( h_2_1_df ) ] <span class="ot">&lt;-</span> <span class="st">&#39;wgtviccy_2_1&#39;</span></span>
<span id="cb635-65"><a href="national-crime-victimization-survey-ncvs.html#cb635-65" tabindex="-1"></a>    </span>
<span id="cb635-66"><a href="national-crime-victimization-survey-ncvs.html#cb635-66" tabindex="-1"></a>h_1_2_df <span class="ot">&lt;-</span></span>
<span id="cb635-67"><a href="national-crime-victimization-survey-ncvs.html#cb635-67" tabindex="-1"></a>    max_half_v_crimes[ </span>
<span id="cb635-68"><a href="national-crime-victimization-survey-ncvs.html#cb635-68" tabindex="-1"></a>        max_half_v_crimes[ , <span class="st">&#39;label&#39;</span> ] <span class="sc">==</span> <span class="st">&#39;_1_2&#39;</span> , </span>
<span id="cb635-69"><a href="national-crime-victimization-survey-ncvs.html#cb635-69" tabindex="-1"></a>        <span class="fu">c</span>( <span class="st">&#39;idhh&#39;</span> , <span class="st">&#39;idper&#39;</span> , <span class="st">&#39;year&#39;</span> , <span class="st">&#39;wgtviccy&#39;</span> )</span>
<span id="cb635-70"><a href="national-crime-victimization-survey-ncvs.html#cb635-70" tabindex="-1"></a>    ]</span>
<span id="cb635-71"><a href="national-crime-victimization-survey-ncvs.html#cb635-71" tabindex="-1"></a>    </span>
<span id="cb635-72"><a href="national-crime-victimization-survey-ncvs.html#cb635-72" tabindex="-1"></a><span class="fu">names</span>( h_1_2_df )[ <span class="fu">ncol</span>( h_1_2_df ) ] <span class="ot">&lt;-</span> <span class="st">&#39;wgtviccy_1_2&#39;</span></span>
<span id="cb635-73"><a href="national-crime-victimization-survey-ncvs.html#cb635-73" tabindex="-1"></a></span>
<span id="cb635-74"><a href="national-crime-victimization-survey-ncvs.html#cb635-74" tabindex="-1"></a>three_half_df <span class="ot">&lt;-</span></span>
<span id="cb635-75"><a href="national-crime-victimization-survey-ncvs.html#cb635-75" tabindex="-1"></a>    <span class="fu">Reduce</span>( <span class="cf">function</span>( ... ) <span class="fu">merge</span>( ... , <span class="at">all =</span> <span class="cn">TRUE</span> ) , <span class="fu">list</span>( h_1_1_df , h_2_1_df , h_1_2_df ) )</span>
<span id="cb635-76"><a href="national-crime-victimization-survey-ncvs.html#cb635-76" tabindex="-1"></a>    </span>
<span id="cb635-77"><a href="national-crime-victimization-survey-ncvs.html#cb635-77" tabindex="-1"></a><span class="fu">rm</span>( h_1_1_df , h_2_1_df , h_1_2_df ) ; <span class="fu">gc</span>()</span></code></pre></div>
<p>Merge these three half-year period weights on to the person-interview data.frame:</p>
<div class="sourceCode" id="cb636"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb636-1"><a href="national-crime-victimization-survey-ncvs.html#cb636-1" tabindex="-1"></a>ncvs_person_df <span class="ot">&lt;-</span> <span class="fu">left_join_zero_missings</span>( ncvs_person_df , three_half_df )</span>
<span id="cb636-2"><a href="national-crime-victimization-survey-ncvs.html#cb636-2" tabindex="-1"></a></span>
<span id="cb636-3"><a href="national-crime-victimization-survey-ncvs.html#cb636-3" tabindex="-1"></a><span class="fu">rm</span>( three_half_df ) ; <span class="fu">gc</span>()</span></code></pre></div>
<p>Aggregate interview counts to the person-year level:</p>
<div class="sourceCode" id="cb637"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb637-1"><a href="national-crime-victimization-survey-ncvs.html#cb637-1" tabindex="-1"></a>summed_person_year_interviews <span class="ot">&lt;-</span></span>
<span id="cb637-2"><a href="national-crime-victimization-survey-ncvs.html#cb637-2" tabindex="-1"></a>    <span class="fu">aggregate</span>(</span>
<span id="cb637-3"><a href="national-crime-victimization-survey-ncvs.html#cb637-3" tabindex="-1"></a>        one <span class="sc">~</span> idhh <span class="sc">+</span> idper <span class="sc">+</span> year ,</span>
<span id="cb637-4"><a href="national-crime-victimization-survey-ncvs.html#cb637-4" tabindex="-1"></a>        <span class="at">data =</span> <span class="fu">subset</span>( ncvs_person_df , wgtpercy <span class="sc">&gt;</span> <span class="dv">0</span> ) ,</span>
<span id="cb637-5"><a href="national-crime-victimization-survey-ncvs.html#cb637-5" tabindex="-1"></a>        sum</span>
<span id="cb637-6"><a href="national-crime-victimization-survey-ncvs.html#cb637-6" tabindex="-1"></a>    )</span>
<span id="cb637-7"><a href="national-crime-victimization-survey-ncvs.html#cb637-7" tabindex="-1"></a></span>
<span id="cb637-8"><a href="national-crime-victimization-survey-ncvs.html#cb637-8" tabindex="-1"></a><span class="fu">names</span>( summed_person_year_interviews )[ <span class="fu">ncol</span>( summed_person_year_interviews ) ] <span class="ot">&lt;-</span> </span>
<span id="cb637-9"><a href="national-crime-victimization-survey-ncvs.html#cb637-9" tabindex="-1"></a>    <span class="st">&#39;interview_count&#39;</span></span></code></pre></div>
<p>Merge interview_count on to the person-interview data.frame:</p>
<div class="sourceCode" id="cb638"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb638-1"><a href="national-crime-victimization-survey-ncvs.html#cb638-1" tabindex="-1"></a>ncvs_person_df <span class="ot">&lt;-</span> <span class="fu">left_join_zero_missings</span>( ncvs_person_df , summed_person_year_interviews )</span>
<span id="cb638-2"><a href="national-crime-victimization-survey-ncvs.html#cb638-2" tabindex="-1"></a></span>
<span id="cb638-3"><a href="national-crime-victimization-survey-ncvs.html#cb638-3" tabindex="-1"></a><span class="fu">rm</span>( summed_person_year_interviews ) ; <span class="fu">gc</span>()</span></code></pre></div>
<p>Apply Interview/Incident Groups:</p>
<div class="sourceCode" id="cb639"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb639-1"><a href="national-crime-victimization-survey-ncvs.html#cb639-1" tabindex="-1"></a>ncvs_person_df <span class="ot">&lt;-</span></span>
<span id="cb639-2"><a href="national-crime-victimization-survey-ncvs.html#cb639-2" tabindex="-1"></a>    <span class="fu">transform</span>(</span>
<span id="cb639-3"><a href="national-crime-victimization-survey-ncvs.html#cb639-3" tabindex="-1"></a>        ncvs_person_df ,</span>
<span id="cb639-4"><a href="national-crime-victimization-survey-ncvs.html#cb639-4" tabindex="-1"></a>        <span class="at">interview_incident_groups =</span></span>
<span id="cb639-5"><a href="national-crime-victimization-survey-ncvs.html#cb639-5" tabindex="-1"></a>        </span>
<span id="cb639-6"><a href="national-crime-victimization-survey-ncvs.html#cb639-6" tabindex="-1"></a>            <span class="fu">ifelse</span>( violent_year <span class="sc">==</span> <span class="dv">0</span> , </span>
<span id="cb639-7"><a href="national-crime-victimization-survey-ncvs.html#cb639-7" tabindex="-1"></a>                <span class="dv">1</span> ,</span>
<span id="cb639-8"><a href="national-crime-victimization-survey-ncvs.html#cb639-8" tabindex="-1"></a>        </span>
<span id="cb639-9"><a href="national-crime-victimization-survey-ncvs.html#cb639-9" tabindex="-1"></a>            <span class="fu">ifelse</span>( </span>
<span id="cb639-10"><a href="national-crime-victimization-survey-ncvs.html#cb639-10" tabindex="-1"></a>                interview_count <span class="sc">==</span> <span class="dv">1</span> <span class="sc">&amp;</span> </span>
<span id="cb639-11"><a href="national-crime-victimization-survey-ncvs.html#cb639-11" tabindex="-1"></a>                ( ( <span class="fu">as.numeric</span>( vwgt1 <span class="sc">&gt;</span> <span class="dv">0</span> ) <span class="sc">+</span> <span class="fu">as.numeric</span>( vwgt2 <span class="sc">&gt;</span> <span class="dv">0</span> ) ) <span class="sc">==</span> <span class="dv">1</span> ) <span class="sc">&amp;</span> </span>
<span id="cb639-12"><a href="national-crime-victimization-survey-ncvs.html#cb639-12" tabindex="-1"></a>                wgtviccy <span class="sc">&gt;</span> <span class="dv">0</span> , </span>
<span id="cb639-13"><a href="national-crime-victimization-survey-ncvs.html#cb639-13" tabindex="-1"></a>                <span class="dv">2</span> ,</span>
<span id="cb639-14"><a href="national-crime-victimization-survey-ncvs.html#cb639-14" tabindex="-1"></a>            </span>
<span id="cb639-15"><a href="national-crime-victimization-survey-ncvs.html#cb639-15" tabindex="-1"></a>            <span class="fu">ifelse</span>( </span>
<span id="cb639-16"><a href="national-crime-victimization-survey-ncvs.html#cb639-16" tabindex="-1"></a>                interview_count <span class="sc">==</span> <span class="dv">2</span> <span class="sc">&amp;</span> </span>
<span id="cb639-17"><a href="national-crime-victimization-survey-ncvs.html#cb639-17" tabindex="-1"></a>                ( ( <span class="fu">as.numeric</span>( vwgt1 <span class="sc">&gt;</span> <span class="dv">0</span> ) <span class="sc">+</span> <span class="fu">as.numeric</span>( vwgt2 <span class="sc">&gt;</span> <span class="dv">0</span> ) ) <span class="sc">==</span> <span class="dv">1</span> ) , </span>
<span id="cb639-18"><a href="national-crime-victimization-survey-ncvs.html#cb639-18" tabindex="-1"></a>                <span class="dv">3</span> ,</span>
<span id="cb639-19"><a href="national-crime-victimization-survey-ncvs.html#cb639-19" tabindex="-1"></a>            </span>
<span id="cb639-20"><a href="national-crime-victimization-survey-ncvs.html#cb639-20" tabindex="-1"></a>            <span class="fu">ifelse</span>( </span>
<span id="cb639-21"><a href="national-crime-victimization-survey-ncvs.html#cb639-21" tabindex="-1"></a>                interview_count <span class="sc">==</span> <span class="dv">2</span> <span class="sc">&amp;</span> </span>
<span id="cb639-22"><a href="national-crime-victimization-survey-ncvs.html#cb639-22" tabindex="-1"></a>                ( vwgt1 <span class="sc">&gt;</span> <span class="dv">0</span> ) <span class="sc">&amp;</span> ( vwgt2 <span class="sc">&gt;</span> <span class="dv">0</span> ) <span class="sc">&amp;</span> ( wgtviccy <span class="sc">&gt;</span> <span class="dv">0</span> ) , </span>
<span id="cb639-23"><a href="national-crime-victimization-survey-ncvs.html#cb639-23" tabindex="-1"></a>                <span class="dv">4</span> ,</span>
<span id="cb639-24"><a href="national-crime-victimization-survey-ncvs.html#cb639-24" tabindex="-1"></a>            </span>
<span id="cb639-25"><a href="national-crime-victimization-survey-ncvs.html#cb639-25" tabindex="-1"></a>            <span class="fu">ifelse</span>( </span>
<span id="cb639-26"><a href="national-crime-victimization-survey-ncvs.html#cb639-26" tabindex="-1"></a>                interview_count <span class="sc">==</span> <span class="dv">3</span> <span class="sc">&amp;</span> </span>
<span id="cb639-27"><a href="national-crime-victimization-survey-ncvs.html#cb639-27" tabindex="-1"></a>                ( ( </span>
<span id="cb639-28"><a href="national-crime-victimization-survey-ncvs.html#cb639-28" tabindex="-1"></a>                    <span class="fu">as.numeric</span>( wgtviccy_1_1 <span class="sc">&gt;</span> <span class="dv">0</span> ) <span class="sc">+</span> </span>
<span id="cb639-29"><a href="national-crime-victimization-survey-ncvs.html#cb639-29" tabindex="-1"></a>                    <span class="fu">as.numeric</span>( wgtviccy_2_1 <span class="sc">&gt;</span> <span class="dv">0</span> ) <span class="sc">+</span> </span>
<span id="cb639-30"><a href="national-crime-victimization-survey-ncvs.html#cb639-30" tabindex="-1"></a>                    <span class="fu">as.numeric</span>( wgtviccy_1_2 <span class="sc">&gt;</span> <span class="dv">0</span> ) </span>
<span id="cb639-31"><a href="national-crime-victimization-survey-ncvs.html#cb639-31" tabindex="-1"></a>                ) <span class="sc">==</span> <span class="dv">1</span> ) , </span>
<span id="cb639-32"><a href="national-crime-victimization-survey-ncvs.html#cb639-32" tabindex="-1"></a>                <span class="dv">5</span> ,</span>
<span id="cb639-33"><a href="national-crime-victimization-survey-ncvs.html#cb639-33" tabindex="-1"></a>            </span>
<span id="cb639-34"><a href="national-crime-victimization-survey-ncvs.html#cb639-34" tabindex="-1"></a>            <span class="fu">ifelse</span>( </span>
<span id="cb639-35"><a href="national-crime-victimization-survey-ncvs.html#cb639-35" tabindex="-1"></a>                interview_count <span class="sc">==</span> <span class="dv">3</span> <span class="sc">&amp;</span> </span>
<span id="cb639-36"><a href="national-crime-victimization-survey-ncvs.html#cb639-36" tabindex="-1"></a>                ( wgtviccy_1_1 <span class="sc">&gt;</span> <span class="dv">0</span> ) <span class="sc">&amp;</span> ( wgtviccy_2_1 <span class="sc">&gt;</span> <span class="dv">0</span> ) <span class="sc">&amp;</span> ( wgtviccy_1_2 <span class="sc">&gt;</span> <span class="dv">0</span> ) , </span>
<span id="cb639-37"><a href="national-crime-victimization-survey-ncvs.html#cb639-37" tabindex="-1"></a>                <span class="dv">6</span> ,</span>
<span id="cb639-38"><a href="national-crime-victimization-survey-ncvs.html#cb639-38" tabindex="-1"></a>            </span>
<span id="cb639-39"><a href="national-crime-victimization-survey-ncvs.html#cb639-39" tabindex="-1"></a>            <span class="fu">ifelse</span>( </span>
<span id="cb639-40"><a href="national-crime-victimization-survey-ncvs.html#cb639-40" tabindex="-1"></a>                interview_count <span class="sc">==</span> <span class="dv">3</span> <span class="sc">&amp;</span> </span>
<span id="cb639-41"><a href="national-crime-victimization-survey-ncvs.html#cb639-41" tabindex="-1"></a>                ( wgtviccy_1_1 <span class="sc">&gt;</span> <span class="dv">0</span> ) <span class="sc">&amp;</span> ( wgtviccy_2_1 <span class="sc">&gt;</span> <span class="dv">0</span> ) <span class="sc">&amp;</span> </span>
<span id="cb639-42"><a href="national-crime-victimization-survey-ncvs.html#cb639-42" tabindex="-1"></a>                <span class="fu">substr</span>( yearq , <span class="dv">6</span> , <span class="dv">6</span> ) <span class="sc">%in%</span> <span class="dv">1</span><span class="sc">:</span><span class="dv">2</span> , </span>
<span id="cb639-43"><a href="national-crime-victimization-survey-ncvs.html#cb639-43" tabindex="-1"></a>                <span class="dv">7</span> ,</span>
<span id="cb639-44"><a href="national-crime-victimization-survey-ncvs.html#cb639-44" tabindex="-1"></a>                </span>
<span id="cb639-45"><a href="national-crime-victimization-survey-ncvs.html#cb639-45" tabindex="-1"></a>            <span class="fu">ifelse</span>( </span>
<span id="cb639-46"><a href="national-crime-victimization-survey-ncvs.html#cb639-46" tabindex="-1"></a>                interview_count <span class="sc">==</span> <span class="dv">3</span> <span class="sc">&amp;</span> </span>
<span id="cb639-47"><a href="national-crime-victimization-survey-ncvs.html#cb639-47" tabindex="-1"></a>                ( wgtviccy_1_1 <span class="sc">&gt;</span> <span class="dv">0</span> ) <span class="sc">&amp;</span> ( wgtviccy_2_1 <span class="sc">&gt;</span> <span class="dv">0</span> ) <span class="sc">&amp;</span> </span>
<span id="cb639-48"><a href="national-crime-victimization-survey-ncvs.html#cb639-48" tabindex="-1"></a>                <span class="fu">substr</span>( yearq , <span class="dv">6</span> , <span class="dv">6</span> ) <span class="sc">%in%</span> <span class="dv">3</span><span class="sc">:</span><span class="dv">4</span> , </span>
<span id="cb639-49"><a href="national-crime-victimization-survey-ncvs.html#cb639-49" tabindex="-1"></a>                <span class="dv">8</span> , </span>
<span id="cb639-50"><a href="national-crime-victimization-survey-ncvs.html#cb639-50" tabindex="-1"></a>                </span>
<span id="cb639-51"><a href="national-crime-victimization-survey-ncvs.html#cb639-51" tabindex="-1"></a>                <span class="dv">9</span> </span>
<span id="cb639-52"><a href="national-crime-victimization-survey-ncvs.html#cb639-52" tabindex="-1"></a>            ) ) ) ) ) ) ) )</span>
<span id="cb639-53"><a href="national-crime-victimization-survey-ncvs.html#cb639-53" tabindex="-1"></a>    )</span>
<span id="cb639-54"><a href="national-crime-victimization-survey-ncvs.html#cb639-54" tabindex="-1"></a>            </span>
<span id="cb639-55"><a href="national-crime-victimization-survey-ncvs.html#cb639-55" tabindex="-1"></a></span>
<span id="cb639-56"><a href="national-crime-victimization-survey-ncvs.html#cb639-56" tabindex="-1"></a><span class="co"># confirm all records in group 9 have both a wgtviccy == 0 &amp; wgtpercy == 0</span></span>
<span id="cb639-57"><a href="national-crime-victimization-survey-ncvs.html#cb639-57" tabindex="-1"></a><span class="fu">stopifnot</span>( <span class="fu">nrow</span>( <span class="fu">subset</span>( ncvs_person_df , interview_incident_groups <span class="sc">==</span> <span class="dv">9</span> <span class="sc">&amp;</span> wgtviccy <span class="sc">&gt;</span> <span class="dv">0</span> ) ) <span class="sc">==</span> <span class="dv">0</span> )</span>
<span id="cb639-58"><a href="national-crime-victimization-survey-ncvs.html#cb639-58" tabindex="-1"></a><span class="fu">stopifnot</span>( <span class="fu">nrow</span>( <span class="fu">subset</span>( ncvs_person_df , interview_incident_groups <span class="sc">==</span> <span class="dv">9</span> <span class="sc">&amp;</span> wgtpercy <span class="sc">&gt;</span> <span class="dv">0</span> ) ) <span class="sc">==</span> <span class="dv">0</span> )</span>
<span id="cb639-59"><a href="national-crime-victimization-survey-ncvs.html#cb639-59" tabindex="-1"></a></span>
<span id="cb639-60"><a href="national-crime-victimization-survey-ncvs.html#cb639-60" tabindex="-1"></a>ncvs_person_df <span class="ot">&lt;-</span></span>
<span id="cb639-61"><a href="national-crime-victimization-survey-ncvs.html#cb639-61" tabindex="-1"></a>    <span class="fu">transform</span>(</span>
<span id="cb639-62"><a href="national-crime-victimization-survey-ncvs.html#cb639-62" tabindex="-1"></a>        ncvs_person_df ,</span>
<span id="cb639-63"><a href="national-crime-victimization-survey-ncvs.html#cb639-63" tabindex="-1"></a>        </span>
<span id="cb639-64"><a href="national-crime-victimization-survey-ncvs.html#cb639-64" tabindex="-1"></a>        <span class="at">prev_wgt0 =</span></span>
<span id="cb639-65"><a href="national-crime-victimization-survey-ncvs.html#cb639-65" tabindex="-1"></a>            <span class="fu">ifelse</span>( interview_incident_groups <span class="sc">==</span> <span class="dv">1</span> , wgtpercy ,</span>
<span id="cb639-66"><a href="national-crime-victimization-survey-ncvs.html#cb639-66" tabindex="-1"></a>            <span class="fu">ifelse</span>( interview_incident_groups <span class="sc">==</span> <span class="dv">2</span> , wgtviccy <span class="sc">/</span> <span class="dv">2</span> ,</span>
<span id="cb639-67"><a href="national-crime-victimization-survey-ncvs.html#cb639-67" tabindex="-1"></a>            <span class="fu">ifelse</span>( interview_incident_groups <span class="sc">==</span> <span class="dv">3</span> , <span class="fu">pmax</span>( vwgt1 , vwgt2 , <span class="at">na.rm =</span> <span class="cn">TRUE</span> ) <span class="sc">/</span> <span class="dv">2</span> ,</span>
<span id="cb639-68"><a href="national-crime-victimization-survey-ncvs.html#cb639-68" tabindex="-1"></a>            <span class="fu">ifelse</span>( interview_incident_groups <span class="sc">==</span> <span class="dv">4</span> , wgtviccy <span class="sc">/</span> <span class="dv">2</span> ,</span>
<span id="cb639-69"><a href="national-crime-victimization-survey-ncvs.html#cb639-69" tabindex="-1"></a>            <span class="fu">ifelse</span>( interview_incident_groups <span class="sc">==</span> <span class="dv">5</span> , </span>
<span id="cb639-70"><a href="national-crime-victimization-survey-ncvs.html#cb639-70" tabindex="-1"></a>                <span class="fu">pmax</span>( wgtviccy_1_1 , wgtviccy_1_2 , wgtviccy_2_1 , <span class="at">na.rm =</span> <span class="cn">TRUE</span> ) <span class="sc">/</span> <span class="dv">2</span> ,</span>
<span id="cb639-71"><a href="national-crime-victimization-survey-ncvs.html#cb639-71" tabindex="-1"></a>            <span class="fu">ifelse</span>( interview_incident_groups <span class="sc">==</span> <span class="dv">6</span> , wgtviccy <span class="sc">/</span> <span class="dv">2</span> ,</span>
<span id="cb639-72"><a href="national-crime-victimization-survey-ncvs.html#cb639-72" tabindex="-1"></a>            <span class="fu">ifelse</span>( interview_incident_groups <span class="sc">==</span> <span class="dv">7</span> , wgtviccy_1_1 <span class="sc">/</span> <span class="dv">2</span> ,</span>
<span id="cb639-73"><a href="national-crime-victimization-survey-ncvs.html#cb639-73" tabindex="-1"></a>            <span class="fu">ifelse</span>( interview_incident_groups <span class="sc">==</span> <span class="dv">8</span> , wgtviccy_2_1 <span class="sc">/</span> <span class="dv">2</span> ,</span>
<span id="cb639-74"><a href="national-crime-victimization-survey-ncvs.html#cb639-74" tabindex="-1"></a>            <span class="fu">ifelse</span>( interview_incident_groups <span class="sc">==</span> <span class="dv">9</span> , <span class="dv">0</span> ,</span>
<span id="cb639-75"><a href="national-crime-victimization-survey-ncvs.html#cb639-75" tabindex="-1"></a>                <span class="cn">NA</span> ) ) ) ) ) ) ) ) )</span>
<span id="cb639-76"><a href="national-crime-victimization-survey-ncvs.html#cb639-76" tabindex="-1"></a>    )</span>
<span id="cb639-77"><a href="national-crime-victimization-survey-ncvs.html#cb639-77" tabindex="-1"></a></span>
<span id="cb639-78"><a href="national-crime-victimization-survey-ncvs.html#cb639-78" tabindex="-1"></a><span class="co"># matches table 8</span></span>
<span id="cb639-79"><a href="national-crime-victimization-survey-ncvs.html#cb639-79" tabindex="-1"></a><span class="co"># https://www.ojp.gov/pdffiles1/bjs/grants/308745.pdf#page=44</span></span></code></pre></div>
<p>Aggregate <code>wgtviccy</code> and <code>prev_wgt0</code> sums to the year level, then merge:</p>
<div class="sourceCode" id="cb640"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb640-1"><a href="national-crime-victimization-survey-ncvs.html#cb640-1" tabindex="-1"></a>summed_year_weights <span class="ot">&lt;-</span></span>
<span id="cb640-2"><a href="national-crime-victimization-survey-ncvs.html#cb640-2" tabindex="-1"></a>    <span class="fu">aggregate</span>(</span>
<span id="cb640-3"><a href="national-crime-victimization-survey-ncvs.html#cb640-3" tabindex="-1"></a>        <span class="fu">cbind</span>( wgtviccy , prev_wgt0 ) <span class="sc">~</span> year ,</span>
<span id="cb640-4"><a href="national-crime-victimization-survey-ncvs.html#cb640-4" tabindex="-1"></a>        <span class="at">data =</span> <span class="fu">subset</span>( ncvs_person_df , violent_year <span class="sc">==</span> <span class="dv">1</span> ) ,</span>
<span id="cb640-5"><a href="national-crime-victimization-survey-ncvs.html#cb640-5" tabindex="-1"></a>        sum</span>
<span id="cb640-6"><a href="national-crime-victimization-survey-ncvs.html#cb640-6" tabindex="-1"></a>    )</span>
<span id="cb640-7"><a href="national-crime-victimization-survey-ncvs.html#cb640-7" tabindex="-1"></a></span>
<span id="cb640-8"><a href="national-crime-victimization-survey-ncvs.html#cb640-8" tabindex="-1"></a><span class="fu">names</span>( summed_year_weights ) <span class="ot">&lt;-</span> <span class="fu">c</span>( <span class="st">&#39;year&#39;</span> , <span class="st">&#39;vwgt_1v&#39;</span> , <span class="st">&#39;prev_1v&#39;</span> )</span>
<span id="cb640-9"><a href="national-crime-victimization-survey-ncvs.html#cb640-9" tabindex="-1"></a></span>
<span id="cb640-10"><a href="national-crime-victimization-survey-ncvs.html#cb640-10" tabindex="-1"></a>ncvs_person_df <span class="ot">&lt;-</span> <span class="fu">left_join_zero_missings</span>( ncvs_person_df , summed_year_weights )</span>
<span id="cb640-11"><a href="national-crime-victimization-survey-ncvs.html#cb640-11" tabindex="-1"></a></span>
<span id="cb640-12"><a href="national-crime-victimization-survey-ncvs.html#cb640-12" tabindex="-1"></a><span class="fu">rm</span>( summed_year_weights ) ; <span class="fu">gc</span>()</span></code></pre></div>
<p>Calibrate so that the weight sums to <code>wgtviccy</code> for persons with exactly one victimization:</p>
<div class="sourceCode" id="cb641"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb641-1"><a href="national-crime-victimization-survey-ncvs.html#cb641-1" tabindex="-1"></a>ncvs_person_df <span class="ot">&lt;-</span></span>
<span id="cb641-2"><a href="national-crime-victimization-survey-ncvs.html#cb641-2" tabindex="-1"></a>    <span class="fu">transform</span>(</span>
<span id="cb641-3"><a href="national-crime-victimization-survey-ncvs.html#cb641-3" tabindex="-1"></a>        ncvs_person_df ,</span>
<span id="cb641-4"><a href="national-crime-victimization-survey-ncvs.html#cb641-4" tabindex="-1"></a></span>
<span id="cb641-5"><a href="national-crime-victimization-survey-ncvs.html#cb641-5" tabindex="-1"></a>        <span class="at">prev_wgt1 =</span> </span>
<span id="cb641-6"><a href="national-crime-victimization-survey-ncvs.html#cb641-6" tabindex="-1"></a>            <span class="fu">ifelse</span>( violent_year <span class="sc">==</span> <span class="dv">0</span> , prev_wgt0 ,</span>
<span id="cb641-7"><a href="national-crime-victimization-survey-ncvs.html#cb641-7" tabindex="-1"></a>            <span class="fu">ifelse</span>( violent_year <span class="sc">&gt;</span> <span class="dv">0</span> <span class="sc">&amp;</span> wgtpercy <span class="sc">&gt;</span> <span class="dv">0</span> , </span>
<span id="cb641-8"><a href="national-crime-victimization-survey-ncvs.html#cb641-8" tabindex="-1"></a>                prev_wgt0 <span class="sc">*</span> ( vwgt_1v <span class="sc">/</span> prev_1v ) , <span class="dv">0</span> ) )</span>
<span id="cb641-9"><a href="national-crime-victimization-survey-ncvs.html#cb641-9" tabindex="-1"></a>    )</span></code></pre></div>
<p>Aggregate <code>wgtviccy</code> and <code>prev_wgt0</code> sums to the year level, then merge:</p>
<div class="sourceCode" id="cb642"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb642-1"><a href="national-crime-victimization-survey-ncvs.html#cb642-1" tabindex="-1"></a>summed_year_crimes <span class="ot">&lt;-</span></span>
<span id="cb642-2"><a href="national-crime-victimization-survey-ncvs.html#cb642-2" tabindex="-1"></a>    <span class="fu">aggregate</span>(</span>
<span id="cb642-3"><a href="national-crime-victimization-survey-ncvs.html#cb642-3" tabindex="-1"></a>        <span class="fu">cbind</span>( </span>
<span id="cb642-4"><a href="national-crime-victimization-survey-ncvs.html#cb642-4" tabindex="-1"></a>            wgtpercy , </span>
<span id="cb642-5"><a href="national-crime-victimization-survey-ncvs.html#cb642-5" tabindex="-1"></a>            <span class="fu">ifelse</span>( violent_year <span class="sc">&gt;</span> <span class="dv">0</span> , prev_wgt1 , <span class="dv">0</span> ) , </span>
<span id="cb642-6"><a href="national-crime-victimization-survey-ncvs.html#cb642-6" tabindex="-1"></a>            <span class="fu">ifelse</span>( violent_year <span class="sc">==</span> <span class="dv">0</span> , prev_wgt1 , <span class="dv">0</span> )</span>
<span id="cb642-7"><a href="national-crime-victimization-survey-ncvs.html#cb642-7" tabindex="-1"></a>        ) <span class="sc">~</span> year ,</span>
<span id="cb642-8"><a href="national-crime-victimization-survey-ncvs.html#cb642-8" tabindex="-1"></a>        <span class="at">data =</span> ncvs_person_df ,</span>
<span id="cb642-9"><a href="national-crime-victimization-survey-ncvs.html#cb642-9" tabindex="-1"></a>        sum</span>
<span id="cb642-10"><a href="national-crime-victimization-survey-ncvs.html#cb642-10" tabindex="-1"></a>    )</span>
<span id="cb642-11"><a href="national-crime-victimization-survey-ncvs.html#cb642-11" tabindex="-1"></a></span>
<span id="cb642-12"><a href="national-crime-victimization-survey-ncvs.html#cb642-12" tabindex="-1"></a><span class="fu">names</span>( summed_year_crimes ) <span class="ot">&lt;-</span> <span class="fu">c</span>( <span class="st">&#39;year&#39;</span> , <span class="st">&#39;total_persons&#39;</span> , <span class="st">&#39;prev_with_crime&#39;</span> , <span class="st">&#39;prev_no_crime&#39;</span> )</span>
<span id="cb642-13"><a href="national-crime-victimization-survey-ncvs.html#cb642-13" tabindex="-1"></a></span>
<span id="cb642-14"><a href="national-crime-victimization-survey-ncvs.html#cb642-14" tabindex="-1"></a>ncvs_person_df <span class="ot">&lt;-</span> <span class="fu">left_join_zero_missings</span>( ncvs_person_df , summed_year_crimes )</span>
<span id="cb642-15"><a href="national-crime-victimization-survey-ncvs.html#cb642-15" tabindex="-1"></a></span>
<span id="cb642-16"><a href="national-crime-victimization-survey-ncvs.html#cb642-16" tabindex="-1"></a><span class="fu">rm</span>( summed_year_crimes ) ; <span class="fu">gc</span>()</span></code></pre></div>
<p>Calibrate so that the weight sums to <code>wgtpercy</code> for all persons:</p>
<div class="sourceCode" id="cb643"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb643-1"><a href="national-crime-victimization-survey-ncvs.html#cb643-1" tabindex="-1"></a>ncvs_person_df <span class="ot">&lt;-</span></span>
<span id="cb643-2"><a href="national-crime-victimization-survey-ncvs.html#cb643-2" tabindex="-1"></a>    <span class="fu">transform</span>(</span>
<span id="cb643-3"><a href="national-crime-victimization-survey-ncvs.html#cb643-3" tabindex="-1"></a>        ncvs_person_df ,</span>
<span id="cb643-4"><a href="national-crime-victimization-survey-ncvs.html#cb643-4" tabindex="-1"></a></span>
<span id="cb643-5"><a href="national-crime-victimization-survey-ncvs.html#cb643-5" tabindex="-1"></a>        <span class="at">prev_wgt =</span></span>
<span id="cb643-6"><a href="national-crime-victimization-survey-ncvs.html#cb643-6" tabindex="-1"></a>            <span class="fu">ifelse</span>( </span>
<span id="cb643-7"><a href="national-crime-victimization-survey-ncvs.html#cb643-7" tabindex="-1"></a>                violent_year <span class="sc">==</span> <span class="dv">0</span> ,</span>
<span id="cb643-8"><a href="national-crime-victimization-survey-ncvs.html#cb643-8" tabindex="-1"></a>                prev_wgt1 <span class="sc">*</span> ( ( total_persons <span class="sc">-</span> prev_with_crime ) <span class="sc">/</span> prev_no_crime ) ,</span>
<span id="cb643-9"><a href="national-crime-victimization-survey-ncvs.html#cb643-9" tabindex="-1"></a>                prev_wgt1 </span>
<span id="cb643-10"><a href="national-crime-victimization-survey-ncvs.html#cb643-10" tabindex="-1"></a>            )</span>
<span id="cb643-11"><a href="national-crime-victimization-survey-ncvs.html#cb643-11" tabindex="-1"></a>    )</span></code></pre></div>
<div id="save-locally-21" class="section level3 unnumbered hasAnchor">
<h3>Save Locally  <a href="national-crime-victimization-survey-ncvs.html#save-locally-21" class="anchor-section" aria-label="Anchor link to header"></a></h3>
<p>Save the object at any point:</p>
<div class="sourceCode" id="cb644"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb644-1"><a href="national-crime-victimization-survey-ncvs.html#cb644-1" tabindex="-1"></a><span class="co"># ncvs_fn &lt;- file.path( path.expand( &quot;~&quot; ) , &quot;NCVS&quot; , &quot;this_file.rds&quot; )</span></span>
<span id="cb644-2"><a href="national-crime-victimization-survey-ncvs.html#cb644-2" tabindex="-1"></a><span class="co"># saveRDS( ncvs_df , file = ncvs_fn , compress = FALSE )</span></span></code></pre></div>
<p>Load the same object:</p>
<div class="sourceCode" id="cb645"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb645-1"><a href="national-crime-victimization-survey-ncvs.html#cb645-1" tabindex="-1"></a><span class="co"># ncvs_df &lt;- readRDS( ncvs_fn )</span></span></code></pre></div>
</div>
<div id="survey-design-definition-15" class="section level3 unnumbered hasAnchor">
<h3>Survey Design Definition<a href="national-crime-victimization-survey-ncvs.html#survey-design-definition-15" class="anchor-section" aria-label="Anchor link to header"></a></h3>
<p>Construct a complex sample survey design:</p>
<div class="sourceCode" id="cb646"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb646-1"><a href="national-crime-victimization-survey-ncvs.html#cb646-1" tabindex="-1"></a><span class="fu">library</span>(survey)</span>
<span id="cb646-2"><a href="national-crime-victimization-survey-ncvs.html#cb646-2" tabindex="-1"></a>    </span>
<span id="cb646-3"><a href="national-crime-victimization-survey-ncvs.html#cb646-3" tabindex="-1"></a><span class="fu">options</span>(<span class="st">&#39;survey.lonely.psu&#39;</span> <span class="ot">=</span> <span class="st">&#39;adjust&#39;</span>)</span>
<span id="cb646-4"><a href="national-crime-victimization-survey-ncvs.html#cb646-4" tabindex="-1"></a></span>
<span id="cb646-5"><a href="national-crime-victimization-survey-ncvs.html#cb646-5" tabindex="-1"></a><span class="co"># replace missing clusters</span></span>
<span id="cb646-6"><a href="national-crime-victimization-survey-ncvs.html#cb646-6" tabindex="-1"></a>ncvs_person_df[ <span class="fu">is.na</span>( ncvs_person_df[ , <span class="st">&#39;v2118&#39;</span> ] ) , <span class="st">&#39;v2118&#39;</span> ] <span class="ot">&lt;-</span> <span class="sc">-</span><span class="dv">1</span></span>
<span id="cb646-7"><a href="national-crime-victimization-survey-ncvs.html#cb646-7" tabindex="-1"></a>ncvs_person_df[ <span class="fu">is.na</span>( ncvs_person_df[ , <span class="st">&#39;v2117&#39;</span> ] ) , <span class="st">&#39;v2117&#39;</span> ] <span class="ot">&lt;-</span> <span class="sc">-</span><span class="dv">1</span></span>
<span id="cb646-8"><a href="national-crime-victimization-survey-ncvs.html#cb646-8" tabindex="-1"></a></span>
<span id="cb646-9"><a href="national-crime-victimization-survey-ncvs.html#cb646-9" tabindex="-1"></a><span class="co"># subset this dataset to only 2022</span></span>
<span id="cb646-10"><a href="national-crime-victimization-survey-ncvs.html#cb646-10" tabindex="-1"></a>ncvs_df <span class="ot">&lt;-</span> <span class="fu">subset</span>( ncvs_person_df , year <span class="sc">==</span> <span class="fu">max</span>( year ) )</span>
<span id="cb646-11"><a href="national-crime-victimization-survey-ncvs.html#cb646-11" tabindex="-1"></a></span>
<span id="cb646-12"><a href="national-crime-victimization-survey-ncvs.html#cb646-12" tabindex="-1"></a>ncvs_design <span class="ot">&lt;-</span></span>
<span id="cb646-13"><a href="national-crime-victimization-survey-ncvs.html#cb646-13" tabindex="-1"></a>    <span class="fu">svydesign</span>( </span>
<span id="cb646-14"><a href="national-crime-victimization-survey-ncvs.html#cb646-14" tabindex="-1"></a>        <span class="sc">~</span> v2118 ,</span>
<span id="cb646-15"><a href="national-crime-victimization-survey-ncvs.html#cb646-15" tabindex="-1"></a>        <span class="at">strata =</span> <span class="sc">~</span> <span class="fu">interaction</span>( yr_grp , v2117 ) ,</span>
<span id="cb646-16"><a href="national-crime-victimization-survey-ncvs.html#cb646-16" tabindex="-1"></a>        <span class="at">data =</span> ncvs_df ,</span>
<span id="cb646-17"><a href="national-crime-victimization-survey-ncvs.html#cb646-17" tabindex="-1"></a>        <span class="at">weights =</span> <span class="sc">~</span> prev_wgt ,</span>
<span id="cb646-18"><a href="national-crime-victimization-survey-ncvs.html#cb646-18" tabindex="-1"></a>        <span class="at">nest =</span> <span class="cn">TRUE</span></span>
<span id="cb646-19"><a href="national-crime-victimization-survey-ncvs.html#cb646-19" tabindex="-1"></a>    )</span></code></pre></div>
</div>
<div id="variable-recoding-21" class="section level3 unnumbered hasAnchor">
<h3>Variable Recoding<a href="national-crime-victimization-survey-ncvs.html#variable-recoding-21" class="anchor-section" aria-label="Anchor link to header"></a></h3>
<p>Add new columns to the data set:</p>
<div class="sourceCode" id="cb647"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb647-1"><a href="national-crime-victimization-survey-ncvs.html#cb647-1" tabindex="-1"></a>ncvs_design <span class="ot">&lt;-</span> </span>
<span id="cb647-2"><a href="national-crime-victimization-survey-ncvs.html#cb647-2" tabindex="-1"></a>    <span class="fu">update</span>( </span>
<span id="cb647-3"><a href="national-crime-victimization-survey-ncvs.html#cb647-3" tabindex="-1"></a>        ncvs_design , </span>
<span id="cb647-4"><a href="national-crime-victimization-survey-ncvs.html#cb647-4" tabindex="-1"></a></span>
<span id="cb647-5"><a href="national-crime-victimization-survey-ncvs.html#cb647-5" tabindex="-1"></a>        <span class="at">one =</span> <span class="dv">1</span> ,</span>
<span id="cb647-6"><a href="national-crime-victimization-survey-ncvs.html#cb647-6" tabindex="-1"></a></span>
<span id="cb647-7"><a href="national-crime-victimization-survey-ncvs.html#cb647-7" tabindex="-1"></a>        <span class="at">victim =</span> <span class="fu">as.numeric</span>( violent_year <span class="sc">&gt;</span> <span class="dv">0</span> ) ,</span>
<span id="cb647-8"><a href="national-crime-victimization-survey-ncvs.html#cb647-8" tabindex="-1"></a></span>
<span id="cb647-9"><a href="national-crime-victimization-survey-ncvs.html#cb647-9" tabindex="-1"></a>        <span class="at">sex =</span> <span class="fu">factor</span>( v3018 , <span class="at">levels =</span> <span class="dv">1</span><span class="sc">:</span><span class="dv">2</span> , <span class="at">labels =</span> <span class="fu">c</span>( <span class="st">&#39;male&#39;</span> , <span class="st">&#39;female&#39;</span> ) ) ,</span>
<span id="cb647-10"><a href="national-crime-victimization-survey-ncvs.html#cb647-10" tabindex="-1"></a>            </span>
<span id="cb647-11"><a href="national-crime-victimization-survey-ncvs.html#cb647-11" tabindex="-1"></a>        <span class="at">linear_age =</span> <span class="fu">ifelse</span>( v3014 <span class="sc">==</span> <span class="dv">99</span> , <span class="cn">NA</span> , v3014 ) ,</span>
<span id="cb647-12"><a href="national-crime-victimization-survey-ncvs.html#cb647-12" tabindex="-1"></a>        </span>
<span id="cb647-13"><a href="national-crime-victimization-survey-ncvs.html#cb647-13" tabindex="-1"></a>        <span class="at">times_moved_in_prior_five_years =</span></span>
<span id="cb647-14"><a href="national-crime-victimization-survey-ncvs.html#cb647-14" tabindex="-1"></a>            <span class="fu">ifelse</span>( v3033 <span class="sc">==</span> <span class="dv">99</span> , <span class="cn">NA</span> , v3033 ) ,</span>
<span id="cb647-15"><a href="national-crime-victimization-survey-ncvs.html#cb647-15" tabindex="-1"></a>        </span>
<span id="cb647-16"><a href="national-crime-victimization-survey-ncvs.html#cb647-16" tabindex="-1"></a>        <span class="at">current_marital_status =</span></span>
<span id="cb647-17"><a href="national-crime-victimization-survey-ncvs.html#cb647-17" tabindex="-1"></a>            <span class="fu">factor</span>( </span>
<span id="cb647-18"><a href="national-crime-victimization-survey-ncvs.html#cb647-18" tabindex="-1"></a>                v3015 , </span>
<span id="cb647-19"><a href="national-crime-victimization-survey-ncvs.html#cb647-19" tabindex="-1"></a>                <span class="at">levels =</span> <span class="fu">c</span>( <span class="dv">1</span><span class="sc">:</span><span class="dv">5</span> , <span class="dv">8</span> ) , </span>
<span id="cb647-20"><a href="national-crime-victimization-survey-ncvs.html#cb647-20" tabindex="-1"></a>                <span class="at">labels =</span> </span>
<span id="cb647-21"><a href="national-crime-victimization-survey-ncvs.html#cb647-21" tabindex="-1"></a>                    <span class="fu">c</span>( <span class="st">&#39;married&#39;</span> , <span class="st">&#39;widowed&#39;</span> , <span class="st">&#39;divorced&#39;</span> , <span class="st">&#39;separated&#39;</span> , <span class="st">&#39;single&#39;</span> , <span class="st">&#39;residue&#39;</span> )</span>
<span id="cb647-22"><a href="national-crime-victimization-survey-ncvs.html#cb647-22" tabindex="-1"></a>            ) ,</span>
<span id="cb647-23"><a href="national-crime-victimization-survey-ncvs.html#cb647-23" tabindex="-1"></a>        </span>
<span id="cb647-24"><a href="national-crime-victimization-survey-ncvs.html#cb647-24" tabindex="-1"></a>        <span class="at">household_income_starting_2015q1 =</span></span>
<span id="cb647-25"><a href="national-crime-victimization-survey-ncvs.html#cb647-25" tabindex="-1"></a>            <span class="fu">factor</span>(</span>
<span id="cb647-26"><a href="national-crime-victimization-survey-ncvs.html#cb647-26" tabindex="-1"></a>                <span class="fu">findInterval</span>( sc214a , <span class="fu">c</span>( <span class="dv">1</span> , <span class="dv">9</span> , <span class="dv">13</span> , <span class="dv">16</span> , <span class="dv">18</span> ) ) ,</span>
<span id="cb647-27"><a href="national-crime-victimization-survey-ncvs.html#cb647-27" tabindex="-1"></a>                <span class="at">levels =</span> <span class="dv">1</span><span class="sc">:</span><span class="dv">5</span> ,</span>
<span id="cb647-28"><a href="national-crime-victimization-survey-ncvs.html#cb647-28" tabindex="-1"></a>                <span class="at">labels =</span> </span>
<span id="cb647-29"><a href="national-crime-victimization-survey-ncvs.html#cb647-29" tabindex="-1"></a>                    <span class="fu">c</span>( <span class="st">&#39;less than $25,000&#39;</span> , <span class="st">&#39;$25,000 - $49,999&#39;</span> , <span class="st">&#39;$50,000 - $99,999&#39;</span> , </span>
<span id="cb647-30"><a href="national-crime-victimization-survey-ncvs.html#cb647-30" tabindex="-1"></a>                    <span class="st">&#39;$100,000 - $199,999&#39;</span> , <span class="st">&#39;$200,000 or more&#39;</span> )</span>
<span id="cb647-31"><a href="national-crime-victimization-survey-ncvs.html#cb647-31" tabindex="-1"></a>            ) ,</span>
<span id="cb647-32"><a href="national-crime-victimization-survey-ncvs.html#cb647-32" tabindex="-1"></a>        </span>
<span id="cb647-33"><a href="national-crime-victimization-survey-ncvs.html#cb647-33" tabindex="-1"></a>        <span class="at">household_income_75k =</span> </span>
<span id="cb647-34"><a href="national-crime-victimization-survey-ncvs.html#cb647-34" tabindex="-1"></a>            <span class="fu">ifelse</span>( v2026 <span class="sc">==</span> <span class="dv">98</span> , <span class="cn">NA</span> , <span class="fu">as.numeric</span>( v2026 <span class="sc">%in%</span> <span class="dv">14</span><span class="sc">:</span><span class="dv">18</span> ) )</span>
<span id="cb647-35"><a href="national-crime-victimization-survey-ncvs.html#cb647-35" tabindex="-1"></a>    )</span></code></pre></div>
<hr />
</div>
</div>
<div id="analysis-examples-with-the-survey-library-15" class="section level2 unnumbered hasAnchor">
<h2>Analysis Examples with the <code>survey</code> library  <a href="national-crime-victimization-survey-ncvs.html#analysis-examples-with-the-survey-library-15" class="anchor-section" aria-label="Anchor link to header"></a></h2>
<div id="unweighted-counts-21" class="section level3 unnumbered hasAnchor">
<h3>Unweighted Counts<a href="national-crime-victimization-survey-ncvs.html#unweighted-counts-21" class="anchor-section" aria-label="Anchor link to header"></a></h3>
<p>Count the unweighted number of records in the survey sample, overall and by groups:</p>
<div class="sourceCode" id="cb648"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb648-1"><a href="national-crime-victimization-survey-ncvs.html#cb648-1" tabindex="-1"></a><span class="fu">sum</span>( <span class="fu">weights</span>( ncvs_design , <span class="st">&quot;sampling&quot;</span> ) <span class="sc">!=</span> <span class="dv">0</span> )</span>
<span id="cb648-2"><a href="national-crime-victimization-survey-ncvs.html#cb648-2" tabindex="-1"></a></span>
<span id="cb648-3"><a href="national-crime-victimization-survey-ncvs.html#cb648-3" tabindex="-1"></a><span class="fu">svyby</span>( <span class="sc">~</span> one , <span class="sc">~</span> sex , ncvs_design , unwtd.count )</span></code></pre></div>
</div>
<div id="weighted-counts-15" class="section level3 unnumbered hasAnchor">
<h3>Weighted Counts<a href="national-crime-victimization-survey-ncvs.html#weighted-counts-15" class="anchor-section" aria-label="Anchor link to header"></a></h3>
<p>Count the weighted size of the generalizable population, overall and by groups:</p>
<div class="sourceCode" id="cb649"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb649-1"><a href="national-crime-victimization-survey-ncvs.html#cb649-1" tabindex="-1"></a><span class="fu">svytotal</span>( <span class="sc">~</span> one , ncvs_design )</span>
<span id="cb649-2"><a href="national-crime-victimization-survey-ncvs.html#cb649-2" tabindex="-1"></a></span>
<span id="cb649-3"><a href="national-crime-victimization-survey-ncvs.html#cb649-3" tabindex="-1"></a><span class="fu">svyby</span>( <span class="sc">~</span> one , <span class="sc">~</span> sex , ncvs_design , svytotal )</span></code></pre></div>
</div>
<div id="descriptive-statistics-21" class="section level3 unnumbered hasAnchor">
<h3>Descriptive Statistics<a href="national-crime-victimization-survey-ncvs.html#descriptive-statistics-21" class="anchor-section" aria-label="Anchor link to header"></a></h3>
<p>Calculate the mean (average) of a linear variable, overall and by groups:</p>
<div class="sourceCode" id="cb650"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb650-1"><a href="national-crime-victimization-survey-ncvs.html#cb650-1" tabindex="-1"></a><span class="fu">svymean</span>( <span class="sc">~</span> victim , ncvs_design )</span>
<span id="cb650-2"><a href="national-crime-victimization-survey-ncvs.html#cb650-2" tabindex="-1"></a></span>
<span id="cb650-3"><a href="national-crime-victimization-survey-ncvs.html#cb650-3" tabindex="-1"></a><span class="fu">svyby</span>( <span class="sc">~</span> victim , <span class="sc">~</span> sex , ncvs_design , svymean )</span></code></pre></div>
<p>Calculate the distribution of a categorical variable, overall and by groups:</p>
<div class="sourceCode" id="cb651"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb651-1"><a href="national-crime-victimization-survey-ncvs.html#cb651-1" tabindex="-1"></a><span class="fu">svymean</span>( <span class="sc">~</span> current_marital_status , ncvs_design )</span>
<span id="cb651-2"><a href="national-crime-victimization-survey-ncvs.html#cb651-2" tabindex="-1"></a></span>
<span id="cb651-3"><a href="national-crime-victimization-survey-ncvs.html#cb651-3" tabindex="-1"></a><span class="fu">svyby</span>( <span class="sc">~</span> current_marital_status , <span class="sc">~</span> sex , ncvs_design , svymean )</span></code></pre></div>
<p>Calculate the sum of a linear variable, overall and by groups:</p>
<div class="sourceCode" id="cb652"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb652-1"><a href="national-crime-victimization-survey-ncvs.html#cb652-1" tabindex="-1"></a><span class="fu">svytotal</span>( <span class="sc">~</span> victim , ncvs_design )</span>
<span id="cb652-2"><a href="national-crime-victimization-survey-ncvs.html#cb652-2" tabindex="-1"></a></span>
<span id="cb652-3"><a href="national-crime-victimization-survey-ncvs.html#cb652-3" tabindex="-1"></a><span class="fu">svyby</span>( <span class="sc">~</span> victim , <span class="sc">~</span> sex , ncvs_design , svytotal )</span></code></pre></div>
<p>Calculate the weighted sum of a categorical variable, overall and by groups:</p>
<div class="sourceCode" id="cb653"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb653-1"><a href="national-crime-victimization-survey-ncvs.html#cb653-1" tabindex="-1"></a><span class="fu">svytotal</span>( <span class="sc">~</span> current_marital_status , ncvs_design )</span>
<span id="cb653-2"><a href="national-crime-victimization-survey-ncvs.html#cb653-2" tabindex="-1"></a></span>
<span id="cb653-3"><a href="national-crime-victimization-survey-ncvs.html#cb653-3" tabindex="-1"></a><span class="fu">svyby</span>( <span class="sc">~</span> current_marital_status , <span class="sc">~</span> sex , ncvs_design , svytotal )</span></code></pre></div>
<p>Calculate the median (50th percentile) of a linear variable, overall and by groups:</p>
<div class="sourceCode" id="cb654"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb654-1"><a href="national-crime-victimization-survey-ncvs.html#cb654-1" tabindex="-1"></a><span class="fu">svyquantile</span>( <span class="sc">~</span> victim , ncvs_design , <span class="fl">0.5</span> )</span>
<span id="cb654-2"><a href="national-crime-victimization-survey-ncvs.html#cb654-2" tabindex="-1"></a></span>
<span id="cb654-3"><a href="national-crime-victimization-survey-ncvs.html#cb654-3" tabindex="-1"></a><span class="fu">svyby</span>( </span>
<span id="cb654-4"><a href="national-crime-victimization-survey-ncvs.html#cb654-4" tabindex="-1"></a>    <span class="sc">~</span> victim , </span>
<span id="cb654-5"><a href="national-crime-victimization-survey-ncvs.html#cb654-5" tabindex="-1"></a>    <span class="sc">~</span> sex , </span>
<span id="cb654-6"><a href="national-crime-victimization-survey-ncvs.html#cb654-6" tabindex="-1"></a>    ncvs_design , </span>
<span id="cb654-7"><a href="national-crime-victimization-survey-ncvs.html#cb654-7" tabindex="-1"></a>    svyquantile , </span>
<span id="cb654-8"><a href="national-crime-victimization-survey-ncvs.html#cb654-8" tabindex="-1"></a>    <span class="fl">0.5</span> ,</span>
<span id="cb654-9"><a href="national-crime-victimization-survey-ncvs.html#cb654-9" tabindex="-1"></a>    <span class="at">ci =</span> <span class="cn">TRUE</span> </span>
<span id="cb654-10"><a href="national-crime-victimization-survey-ncvs.html#cb654-10" tabindex="-1"></a>)</span></code></pre></div>
<p>Estimate a ratio:</p>
<div class="sourceCode" id="cb655"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb655-1"><a href="national-crime-victimization-survey-ncvs.html#cb655-1" tabindex="-1"></a><span class="fu">svyratio</span>( </span>
<span id="cb655-2"><a href="national-crime-victimization-survey-ncvs.html#cb655-2" tabindex="-1"></a>    <span class="at">numerator =</span> <span class="sc">~</span> times_moved_in_prior_five_years , </span>
<span id="cb655-3"><a href="national-crime-victimization-survey-ncvs.html#cb655-3" tabindex="-1"></a>    <span class="at">denominator =</span> <span class="sc">~</span> linear_age , </span>
<span id="cb655-4"><a href="national-crime-victimization-survey-ncvs.html#cb655-4" tabindex="-1"></a>    ncvs_design ,</span>
<span id="cb655-5"><a href="national-crime-victimization-survey-ncvs.html#cb655-5" tabindex="-1"></a>    <span class="at">na.rm =</span> <span class="cn">TRUE</span></span>
<span id="cb655-6"><a href="national-crime-victimization-survey-ncvs.html#cb655-6" tabindex="-1"></a>)</span></code></pre></div>
</div>
<div id="subsetting-21" class="section level3 unnumbered hasAnchor">
<h3>Subsetting<a href="national-crime-victimization-survey-ncvs.html#subsetting-21" class="anchor-section" aria-label="Anchor link to header"></a></h3>
<p>Restrict the survey design to elderly americans:</p>
<div class="sourceCode" id="cb656"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb656-1"><a href="national-crime-victimization-survey-ncvs.html#cb656-1" tabindex="-1"></a>sub_ncvs_design <span class="ot">&lt;-</span> <span class="fu">subset</span>( ncvs_design , linear_age <span class="sc">&gt;=</span> <span class="dv">65</span> )</span></code></pre></div>
<p>Calculate the mean (average) of this subset:</p>
<div class="sourceCode" id="cb657"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb657-1"><a href="national-crime-victimization-survey-ncvs.html#cb657-1" tabindex="-1"></a><span class="fu">svymean</span>( <span class="sc">~</span> victim , sub_ncvs_design )</span></code></pre></div>
</div>
<div id="measures-of-uncertainty-21" class="section level3 unnumbered hasAnchor">
<h3>Measures of Uncertainty<a href="national-crime-victimization-survey-ncvs.html#measures-of-uncertainty-21" class="anchor-section" aria-label="Anchor link to header"></a></h3>
<p>Extract the coefficient, standard error, confidence interval, and coefficient of variation from any descriptive statistics function result, overall and by groups:</p>
<div class="sourceCode" id="cb658"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb658-1"><a href="national-crime-victimization-survey-ncvs.html#cb658-1" tabindex="-1"></a>this_result <span class="ot">&lt;-</span> <span class="fu">svymean</span>( <span class="sc">~</span> victim , ncvs_design )</span>
<span id="cb658-2"><a href="national-crime-victimization-survey-ncvs.html#cb658-2" tabindex="-1"></a></span>
<span id="cb658-3"><a href="national-crime-victimization-survey-ncvs.html#cb658-3" tabindex="-1"></a><span class="fu">coef</span>( this_result )</span>
<span id="cb658-4"><a href="national-crime-victimization-survey-ncvs.html#cb658-4" tabindex="-1"></a><span class="fu">SE</span>( this_result )</span>
<span id="cb658-5"><a href="national-crime-victimization-survey-ncvs.html#cb658-5" tabindex="-1"></a><span class="fu">confint</span>( this_result )</span>
<span id="cb658-6"><a href="national-crime-victimization-survey-ncvs.html#cb658-6" tabindex="-1"></a><span class="fu">cv</span>( this_result )</span>
<span id="cb658-7"><a href="national-crime-victimization-survey-ncvs.html#cb658-7" tabindex="-1"></a></span>
<span id="cb658-8"><a href="national-crime-victimization-survey-ncvs.html#cb658-8" tabindex="-1"></a>grouped_result <span class="ot">&lt;-</span></span>
<span id="cb658-9"><a href="national-crime-victimization-survey-ncvs.html#cb658-9" tabindex="-1"></a>    <span class="fu">svyby</span>( </span>
<span id="cb658-10"><a href="national-crime-victimization-survey-ncvs.html#cb658-10" tabindex="-1"></a>        <span class="sc">~</span> victim , </span>
<span id="cb658-11"><a href="national-crime-victimization-survey-ncvs.html#cb658-11" tabindex="-1"></a>        <span class="sc">~</span> sex , </span>
<span id="cb658-12"><a href="national-crime-victimization-survey-ncvs.html#cb658-12" tabindex="-1"></a>        ncvs_design , </span>
<span id="cb658-13"><a href="national-crime-victimization-survey-ncvs.html#cb658-13" tabindex="-1"></a>        svymean </span>
<span id="cb658-14"><a href="national-crime-victimization-survey-ncvs.html#cb658-14" tabindex="-1"></a>    )</span>
<span id="cb658-15"><a href="national-crime-victimization-survey-ncvs.html#cb658-15" tabindex="-1"></a>    </span>
<span id="cb658-16"><a href="national-crime-victimization-survey-ncvs.html#cb658-16" tabindex="-1"></a><span class="fu">coef</span>( grouped_result )</span>
<span id="cb658-17"><a href="national-crime-victimization-survey-ncvs.html#cb658-17" tabindex="-1"></a><span class="fu">SE</span>( grouped_result )</span>
<span id="cb658-18"><a href="national-crime-victimization-survey-ncvs.html#cb658-18" tabindex="-1"></a><span class="fu">confint</span>( grouped_result )</span>
<span id="cb658-19"><a href="national-crime-victimization-survey-ncvs.html#cb658-19" tabindex="-1"></a><span class="fu">cv</span>( grouped_result )</span></code></pre></div>
<p>Calculate the degrees of freedom of any survey design object:</p>
<div class="sourceCode" id="cb659"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb659-1"><a href="national-crime-victimization-survey-ncvs.html#cb659-1" tabindex="-1"></a><span class="fu">degf</span>( ncvs_design )</span></code></pre></div>
<p>Calculate the complex sample survey-adjusted variance of any statistic:</p>
<div class="sourceCode" id="cb660"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb660-1"><a href="national-crime-victimization-survey-ncvs.html#cb660-1" tabindex="-1"></a><span class="fu">svyvar</span>( <span class="sc">~</span> victim , ncvs_design )</span></code></pre></div>
<p>Include the complex sample design effect in the result for a specific statistic:</p>
<div class="sourceCode" id="cb661"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb661-1"><a href="national-crime-victimization-survey-ncvs.html#cb661-1" tabindex="-1"></a><span class="co"># SRS without replacement</span></span>
<span id="cb661-2"><a href="national-crime-victimization-survey-ncvs.html#cb661-2" tabindex="-1"></a><span class="fu">svymean</span>( <span class="sc">~</span> victim , ncvs_design , <span class="at">deff =</span> <span class="cn">TRUE</span> )</span>
<span id="cb661-3"><a href="national-crime-victimization-survey-ncvs.html#cb661-3" tabindex="-1"></a></span>
<span id="cb661-4"><a href="national-crime-victimization-survey-ncvs.html#cb661-4" tabindex="-1"></a><span class="co"># SRS with replacement</span></span>
<span id="cb661-5"><a href="national-crime-victimization-survey-ncvs.html#cb661-5" tabindex="-1"></a><span class="fu">svymean</span>( <span class="sc">~</span> victim , ncvs_design , <span class="at">deff =</span> <span class="st">&quot;replace&quot;</span> )</span></code></pre></div>
<p>Compute confidence intervals for proportions using methods that may be more accurate near 0 and 1. See <code>?svyciprop</code> for alternatives:</p>
<div class="sourceCode" id="cb662"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb662-1"><a href="national-crime-victimization-survey-ncvs.html#cb662-1" tabindex="-1"></a><span class="fu">svyciprop</span>( <span class="sc">~</span> household_income_75k , ncvs_design ,</span>
<span id="cb662-2"><a href="national-crime-victimization-survey-ncvs.html#cb662-2" tabindex="-1"></a>    <span class="at">method =</span> <span class="st">&quot;likelihood&quot;</span> )</span></code></pre></div>
</div>
<div id="regression-models-and-tests-of-association-21" class="section level3 unnumbered hasAnchor">
<h3>Regression Models and Tests of Association<a href="national-crime-victimization-survey-ncvs.html#regression-models-and-tests-of-association-21" class="anchor-section" aria-label="Anchor link to header"></a></h3>
<p>Perform a design-based t-test:</p>
<div class="sourceCode" id="cb663"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb663-1"><a href="national-crime-victimization-survey-ncvs.html#cb663-1" tabindex="-1"></a><span class="fu">svyttest</span>( victim <span class="sc">~</span> household_income_75k , ncvs_design )</span></code></pre></div>
<p>Perform a chi-squared test of association for survey data:</p>
<div class="sourceCode" id="cb664"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb664-1"><a href="national-crime-victimization-survey-ncvs.html#cb664-1" tabindex="-1"></a><span class="fu">svychisq</span>( </span>
<span id="cb664-2"><a href="national-crime-victimization-survey-ncvs.html#cb664-2" tabindex="-1"></a>    <span class="sc">~</span> household_income_75k <span class="sc">+</span> current_marital_status , </span>
<span id="cb664-3"><a href="national-crime-victimization-survey-ncvs.html#cb664-3" tabindex="-1"></a>    ncvs_design </span>
<span id="cb664-4"><a href="national-crime-victimization-survey-ncvs.html#cb664-4" tabindex="-1"></a>)</span></code></pre></div>
<p>Perform a survey-weighted generalized linear model:</p>
<div class="sourceCode" id="cb665"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb665-1"><a href="national-crime-victimization-survey-ncvs.html#cb665-1" tabindex="-1"></a>glm_result <span class="ot">&lt;-</span> </span>
<span id="cb665-2"><a href="national-crime-victimization-survey-ncvs.html#cb665-2" tabindex="-1"></a>    <span class="fu">svyglm</span>( </span>
<span id="cb665-3"><a href="national-crime-victimization-survey-ncvs.html#cb665-3" tabindex="-1"></a>        victim <span class="sc">~</span> household_income_75k <span class="sc">+</span> current_marital_status , </span>
<span id="cb665-4"><a href="national-crime-victimization-survey-ncvs.html#cb665-4" tabindex="-1"></a>        ncvs_design </span>
<span id="cb665-5"><a href="national-crime-victimization-survey-ncvs.html#cb665-5" tabindex="-1"></a>    )</span>
<span id="cb665-6"><a href="national-crime-victimization-survey-ncvs.html#cb665-6" tabindex="-1"></a></span>
<span id="cb665-7"><a href="national-crime-victimization-survey-ncvs.html#cb665-7" tabindex="-1"></a><span class="fu">summary</span>( glm_result )</span></code></pre></div>
<hr />
</div>
</div>
<div id="replication-example-21" class="section level2 unnumbered hasAnchor">
<h2>Replication Example<a href="national-crime-victimization-survey-ncvs.html#replication-example-21" class="anchor-section" aria-label="Anchor link to header"></a></h2>
<p>This example matches the 1994 and 2022 victimization rates and SEs in <a href="https://bjs.ojp.gov/document/nmpncvs.pdf#page=16">Appendix Table 1</a>:</p>
<div class="sourceCode" id="cb666"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb666-1"><a href="national-crime-victimization-survey-ncvs.html#cb666-1" tabindex="-1"></a>new_prevalence_design <span class="ot">&lt;-</span></span>
<span id="cb666-2"><a href="national-crime-victimization-survey-ncvs.html#cb666-2" tabindex="-1"></a>    <span class="fu">svydesign</span>( </span>
<span id="cb666-3"><a href="national-crime-victimization-survey-ncvs.html#cb666-3" tabindex="-1"></a>        <span class="sc">~</span> v2118 ,</span>
<span id="cb666-4"><a href="national-crime-victimization-survey-ncvs.html#cb666-4" tabindex="-1"></a>        <span class="at">strata =</span> <span class="sc">~</span> <span class="fu">interaction</span>( yr_grp , v2117 ) ,</span>
<span id="cb666-5"><a href="national-crime-victimization-survey-ncvs.html#cb666-5" tabindex="-1"></a>        <span class="at">data =</span> ncvs_person_df ,</span>
<span id="cb666-6"><a href="national-crime-victimization-survey-ncvs.html#cb666-6" tabindex="-1"></a>        <span class="at">weights =</span> <span class="sc">~</span> prev_wgt ,</span>
<span id="cb666-7"><a href="national-crime-victimization-survey-ncvs.html#cb666-7" tabindex="-1"></a>        <span class="at">nest =</span> <span class="cn">TRUE</span></span>
<span id="cb666-8"><a href="national-crime-victimization-survey-ncvs.html#cb666-8" tabindex="-1"></a>    )</span>
<span id="cb666-9"><a href="national-crime-victimization-survey-ncvs.html#cb666-9" tabindex="-1"></a></span>
<span id="cb666-10"><a href="national-crime-victimization-survey-ncvs.html#cb666-10" tabindex="-1"></a>new_prevalence_results <span class="ot">&lt;-</span></span>
<span id="cb666-11"><a href="national-crime-victimization-survey-ncvs.html#cb666-11" tabindex="-1"></a>    <span class="fu">svyby</span>( </span>
<span id="cb666-12"><a href="national-crime-victimization-survey-ncvs.html#cb666-12" tabindex="-1"></a>        <span class="sc">~</span> <span class="fu">as.numeric</span>( violent_year <span class="sc">&gt;</span> <span class="dv">0</span> ) , </span>
<span id="cb666-13"><a href="national-crime-victimization-survey-ncvs.html#cb666-13" tabindex="-1"></a>        <span class="sc">~</span> year , </span>
<span id="cb666-14"><a href="national-crime-victimization-survey-ncvs.html#cb666-14" tabindex="-1"></a>        new_prevalence_design , </span>
<span id="cb666-15"><a href="national-crime-victimization-survey-ncvs.html#cb666-15" tabindex="-1"></a>        svymean</span>
<span id="cb666-16"><a href="national-crime-victimization-survey-ncvs.html#cb666-16" tabindex="-1"></a>    )</span>
<span id="cb666-17"><a href="national-crime-victimization-survey-ncvs.html#cb666-17" tabindex="-1"></a></span>
<span id="cb666-18"><a href="national-crime-victimization-survey-ncvs.html#cb666-18" tabindex="-1"></a><span class="co"># match new method (wgt_ovam) 1994 and 2022 estimates</span></span>
<span id="cb666-19"><a href="national-crime-victimization-survey-ncvs.html#cb666-19" tabindex="-1"></a><span class="fu">stopifnot</span>( </span>
<span id="cb666-20"><a href="national-crime-victimization-survey-ncvs.html#cb666-20" tabindex="-1"></a>    <span class="fu">round</span>( <span class="fu">coef</span>( new_prevalence_results )[ <span class="fu">c</span>( <span class="dv">1</span> , <span class="fu">nrow</span>( new_prevalence_results ) ) ] , <span class="dv">4</span> ) <span class="sc">==</span> </span>
<span id="cb666-21"><a href="national-crime-victimization-survey-ncvs.html#cb666-21" tabindex="-1"></a>    <span class="fu">c</span>( <span class="fl">0.0442</span> , <span class="fl">0.0151</span> )</span>
<span id="cb666-22"><a href="national-crime-victimization-survey-ncvs.html#cb666-22" tabindex="-1"></a>)</span>
<span id="cb666-23"><a href="national-crime-victimization-survey-ncvs.html#cb666-23" tabindex="-1"></a></span>
<span id="cb666-24"><a href="national-crime-victimization-survey-ncvs.html#cb666-24" tabindex="-1"></a><span class="co"># match new method (wgt_ovam) 1994 and 2022 standard errors</span></span>
<span id="cb666-25"><a href="national-crime-victimization-survey-ncvs.html#cb666-25" tabindex="-1"></a><span class="fu">stopifnot</span>( </span>
<span id="cb666-26"><a href="national-crime-victimization-survey-ncvs.html#cb666-26" tabindex="-1"></a>    <span class="fu">round</span>( <span class="fu">SE</span>( new_prevalence_results )[ <span class="fu">c</span>( <span class="dv">1</span> , <span class="fu">nrow</span>( new_prevalence_results ) ) ] , <span class="dv">5</span> ) <span class="sc">==</span> </span>
<span id="cb666-27"><a href="national-crime-victimization-survey-ncvs.html#cb666-27" tabindex="-1"></a>    <span class="fu">c</span>( <span class="fl">0.0010</span> , <span class="fl">0.00054</span> )</span>
<span id="cb666-28"><a href="national-crime-victimization-survey-ncvs.html#cb666-28" tabindex="-1"></a>)</span>
<span id="cb666-29"><a href="national-crime-victimization-survey-ncvs.html#cb666-29" tabindex="-1"></a></span>
<span id="cb666-30"><a href="national-crime-victimization-survey-ncvs.html#cb666-30" tabindex="-1"></a>old_prevalence_design <span class="ot">&lt;-</span></span>
<span id="cb666-31"><a href="national-crime-victimization-survey-ncvs.html#cb666-31" tabindex="-1"></a>    <span class="fu">svydesign</span>( </span>
<span id="cb666-32"><a href="national-crime-victimization-survey-ncvs.html#cb666-32" tabindex="-1"></a>        <span class="sc">~</span> v2118 ,</span>
<span id="cb666-33"><a href="national-crime-victimization-survey-ncvs.html#cb666-33" tabindex="-1"></a>        <span class="at">strata =</span> <span class="sc">~</span> <span class="fu">interaction</span>( yr_grp , v2117 ) ,</span>
<span id="cb666-34"><a href="national-crime-victimization-survey-ncvs.html#cb666-34" tabindex="-1"></a>        <span class="at">data =</span> ncvs_person_df ,</span>
<span id="cb666-35"><a href="national-crime-victimization-survey-ncvs.html#cb666-35" tabindex="-1"></a>        <span class="at">weights =</span> <span class="sc">~</span> wgtpercy ,</span>
<span id="cb666-36"><a href="national-crime-victimization-survey-ncvs.html#cb666-36" tabindex="-1"></a>        <span class="at">nest =</span> <span class="cn">TRUE</span></span>
<span id="cb666-37"><a href="national-crime-victimization-survey-ncvs.html#cb666-37" tabindex="-1"></a>    )</span>
<span id="cb666-38"><a href="national-crime-victimization-survey-ncvs.html#cb666-38" tabindex="-1"></a></span>
<span id="cb666-39"><a href="national-crime-victimization-survey-ncvs.html#cb666-39" tabindex="-1"></a>old_prevalence_results <span class="ot">&lt;-</span></span>
<span id="cb666-40"><a href="national-crime-victimization-survey-ncvs.html#cb666-40" tabindex="-1"></a>    <span class="fu">svyby</span>(</span>
<span id="cb666-41"><a href="national-crime-victimization-survey-ncvs.html#cb666-41" tabindex="-1"></a>        <span class="sc">~</span> <span class="fu">as.numeric</span>( violent_year <span class="sc">&gt;</span> <span class="dv">0</span> ) ,</span>
<span id="cb666-42"><a href="national-crime-victimization-survey-ncvs.html#cb666-42" tabindex="-1"></a>        <span class="sc">~</span> year ,</span>
<span id="cb666-43"><a href="national-crime-victimization-survey-ncvs.html#cb666-43" tabindex="-1"></a>        old_prevalence_design ,</span>
<span id="cb666-44"><a href="national-crime-victimization-survey-ncvs.html#cb666-44" tabindex="-1"></a>        svymean</span>
<span id="cb666-45"><a href="national-crime-victimization-survey-ncvs.html#cb666-45" tabindex="-1"></a>    )</span>
<span id="cb666-46"><a href="national-crime-victimization-survey-ncvs.html#cb666-46" tabindex="-1"></a></span>
<span id="cb666-47"><a href="national-crime-victimization-survey-ncvs.html#cb666-47" tabindex="-1"></a><span class="co"># match old method (wgtpercy) 1994 and 2022 estimates</span></span>
<span id="cb666-48"><a href="national-crime-victimization-survey-ncvs.html#cb666-48" tabindex="-1"></a><span class="fu">stopifnot</span>( </span>
<span id="cb666-49"><a href="national-crime-victimization-survey-ncvs.html#cb666-49" tabindex="-1"></a>    <span class="fu">round</span>( <span class="fu">coef</span>( old_prevalence_results )[ <span class="fu">c</span>( <span class="dv">1</span> , <span class="fu">nrow</span>( old_prevalence_results ) ) ] , <span class="dv">4</span> ) <span class="sc">==</span> </span>
<span id="cb666-50"><a href="national-crime-victimization-survey-ncvs.html#cb666-50" tabindex="-1"></a>    <span class="fu">c</span>( <span class="fl">0.0328</span> , <span class="fl">0.0124</span> )</span>
<span id="cb666-51"><a href="national-crime-victimization-survey-ncvs.html#cb666-51" tabindex="-1"></a>)</span>
<span id="cb666-52"><a href="national-crime-victimization-survey-ncvs.html#cb666-52" tabindex="-1"></a></span>
<span id="cb666-53"><a href="national-crime-victimization-survey-ncvs.html#cb666-53" tabindex="-1"></a><span class="co"># match old method (wgtpercy) 1994 and 2022 standard errors</span></span>
<span id="cb666-54"><a href="national-crime-victimization-survey-ncvs.html#cb666-54" tabindex="-1"></a><span class="fu">stopifnot</span>( </span>
<span id="cb666-55"><a href="national-crime-victimization-survey-ncvs.html#cb666-55" tabindex="-1"></a>    <span class="fu">round</span>( <span class="fu">SE</span>( old_prevalence_results )[ <span class="fu">c</span>( <span class="dv">1</span> , <span class="fu">nrow</span>( old_prevalence_results ) ) ] , <span class="dv">5</span> ) <span class="sc">==</span> </span>
<span id="cb666-56"><a href="national-crime-victimization-survey-ncvs.html#cb666-56" tabindex="-1"></a>    <span class="fu">c</span>( <span class="fl">0.00075</span> , <span class="fl">0.00042</span> )</span>
<span id="cb666-57"><a href="national-crime-victimization-survey-ncvs.html#cb666-57" tabindex="-1"></a>)</span></code></pre></div>
<hr />
</div>
<div id="analysis-examples-with-srvyr-14" class="section level2 unnumbered hasAnchor">
<h2>Analysis Examples with <code>srvyr</code>  <a href="national-crime-victimization-survey-ncvs.html#analysis-examples-with-srvyr-14" class="anchor-section" aria-label="Anchor link to header"></a></h2>
<p>The R <code>srvyr</code> library calculates summary statistics from survey data, such as the mean, total or quantile using <a href="https://github.com/tidyverse/dplyr/">dplyr</a>-like syntax. <a href="https://github.com/gergness/srvyr">srvyr</a> allows for the use of many verbs, such as <code>summarize</code>, <code>group_by</code>, and <code>mutate</code>, the convenience of pipe-able functions, the <code>tidyverse</code> style of non-standard evaluation and more consistent return types than the <code>survey</code> package. <a href="https://cran.r-project.org/web/packages/srvyr/vignettes/srvyr-vs-survey.html">This vignette</a> details the available features. As a starting point for NCVS users, this code replicates previously-presented examples:</p>
<div class="sourceCode" id="cb667"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb667-1"><a href="national-crime-victimization-survey-ncvs.html#cb667-1" tabindex="-1"></a><span class="fu">library</span>(srvyr)</span>
<span id="cb667-2"><a href="national-crime-victimization-survey-ncvs.html#cb667-2" tabindex="-1"></a>ncvs_srvyr_design <span class="ot">&lt;-</span> <span class="fu">as_survey</span>( ncvs_design )</span></code></pre></div>
<p>Calculate the mean (average) of a linear variable, overall and by groups:</p>
<div class="sourceCode" id="cb668"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb668-1"><a href="national-crime-victimization-survey-ncvs.html#cb668-1" tabindex="-1"></a>ncvs_srvyr_design <span class="sc">%&gt;%</span></span>
<span id="cb668-2"><a href="national-crime-victimization-survey-ncvs.html#cb668-2" tabindex="-1"></a>    <span class="fu">summarize</span>( <span class="at">mean =</span> <span class="fu">survey_mean</span>( victim ) )</span>
<span id="cb668-3"><a href="national-crime-victimization-survey-ncvs.html#cb668-3" tabindex="-1"></a></span>
<span id="cb668-4"><a href="national-crime-victimization-survey-ncvs.html#cb668-4" tabindex="-1"></a>ncvs_srvyr_design <span class="sc">%&gt;%</span></span>
<span id="cb668-5"><a href="national-crime-victimization-survey-ncvs.html#cb668-5" tabindex="-1"></a>    <span class="fu">group_by</span>( sex ) <span class="sc">%&gt;%</span></span>
<span id="cb668-6"><a href="national-crime-victimization-survey-ncvs.html#cb668-6" tabindex="-1"></a>    <span class="fu">summarize</span>( <span class="at">mean =</span> <span class="fu">survey_mean</span>( victim ) )</span></code></pre></div>

</div>
</div>
            </section>

          </div>
        </div>
      </div>
<a href="national-beneficiary-survey-nbs.html" class="navigation navigation-prev " aria-label="Previous page"><i class="fa fa-angle-left"></i></a>
<a href="national-financial-capability-study-nfcs.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": null,
"fontsettings": {
"theme": "white",
"family": "sans",
"size": 2
},
"edit": {
"link": "https://github.com/ajdamico/asdfree/edit/master/metadata/ncvs.txt",
"text": "Edit"
},
"history": {
"link": null,
"text": null
},
"view": {
"link": null,
"text": null
},
"download": null,
"search": {
"engine": "fuse",
"options": null
},
"toc": {
"collapse": "section"
}
});
});
</script>

</body>

</html>
