{"id":408,"date":"2012-04-06T14:03:12","date_gmt":"2012-04-06T18:03:12","guid":{"rendered":"http:\/\/web.colby.edu\/mgimond\/?p=408"},"modified":"2012-04-06T14:06:23","modified_gmt":"2012-04-06T18:06:23","slug":"aggregate-census-education-data-estimate-and-margin-of-error","status":"publish","type":"post","link":"https:\/\/web.colby.edu\/mgimond\/2012\/04\/06\/aggregate-census-education-data-estimate-and-margin-of-error\/","title":{"rendered":"Aggregate census education data (estimate and Margin of Error)"},"content":{"rendered":"<p>Data for this exercise can be downloaded here:\u00a0<a title=\"Here\" href=\"http:\/\/web.colby.edu\/mgimond\/files\/2012\/04\/ACS2010.csv\">ACS2010<\/a>.<\/p>\n<pre class=\"brush: r; title: ; notranslate\" title=\"\">\r\n\r\n# Read data file\r\n\r\ndat = read.csv(&quot;ACS2010.csv&quot;, header=T)\r\n\r\nattach(dat)\r\n# Verify sums\r\nplot(B15002_001E ~ eval(B15002_002E + B15002_019E)) # check that pop = M + F\r\n\r\n# Sums of errors are the sqrt of the sums of the SE squared\r\n# SE can be computed from MoE \/ 1.645\r\n# src: 'American Community Survey Accuracy of the Data (2009)'\r\n\r\n# Compute percentage with bachelors degree (or greater)\r\n\r\n# Estimate\r\nnumE = B15002_015E + B15002_016E + B15002_017E + B15002_018E +\r\n B15002_032E + B15002_033E + B15002_034E + B15002_035E\r\n\r\n# Standard error\r\nnumSE = sqrt( (B15002_015M^2 + B15002_016M^2 + B15002_017M^2 + B15002_018M^2 +\r\n B15002_032M^2 + B15002_033M^2 + B15002_034M^2 + B15002_035M^2) \/ 1.645^2)\r\n\r\n# Percent with Bachelor's or greater\r\npercE_E = numE \/ B15002_001E\r\n\r\n# Compute the two radical term\r\nrad1 = numSE^2\r\nrad2 = (numE^2 \/ B15002_001E^2) * (B15002_001M \/ 1.645)^2\r\n# Identify records for which the radical is less than 0\r\nA = rad1 &gt;= rad2\r\nB = !A \u00a0 \u00a0 \u00a0 # The inverse of A\r\n\r\n# If the radical term is negative, use an alternate form of the equation (equation for ratios)\r\n\r\npercE_SE = 1\/B15002_001E * sqrt( A * (rad1 - rad2 ) + B * (rad1 + rad2))\r\npercE_MoE = percE_SE * 1.645\r\n\r\n# Output income and percent with Bachelor's or greater\r\nwrite.csv(cbind(GEOID_DBL,B19301_001E,B19301_001M,percE_E,percE_MoE),&quot;inc_ed.csv&quot;,na=&quot;&quot;)\r\n\r\ndetach(dat)\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Data for this exercise can be downloaded here:\u00a0ACS2010.<\/p>\n","protected":false},"author":1199,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[12807],"tags":[],"_links":{"self":[{"href":"https:\/\/web.colby.edu\/mgimond\/wp-json\/wp\/v2\/posts\/408"}],"collection":[{"href":"https:\/\/web.colby.edu\/mgimond\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/web.colby.edu\/mgimond\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/web.colby.edu\/mgimond\/wp-json\/wp\/v2\/users\/1199"}],"replies":[{"embeddable":true,"href":"https:\/\/web.colby.edu\/mgimond\/wp-json\/wp\/v2\/comments?post=408"}],"version-history":[{"count":8,"href":"https:\/\/web.colby.edu\/mgimond\/wp-json\/wp\/v2\/posts\/408\/revisions"}],"predecessor-version":[{"id":414,"href":"https:\/\/web.colby.edu\/mgimond\/wp-json\/wp\/v2\/posts\/408\/revisions\/414"}],"wp:attachment":[{"href":"https:\/\/web.colby.edu\/mgimond\/wp-json\/wp\/v2\/media?parent=408"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/web.colby.edu\/mgimond\/wp-json\/wp\/v2\/categories?post=408"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/web.colby.edu\/mgimond\/wp-json\/wp\/v2\/tags?post=408"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}