sysuse state_geocodes, clear
list, ab(20)
+---------------------------------------------------------------------------------------------------------+
| state_name state_abb fips census division division_name region region_name |
|---------------------------------------------------------------------------------------------------------|
1. | Connecticut CT 9 16 1 New England 1 Northeast |
2. | Maine ME 23 11 1 New England 1 Northeast |
3. | Massachusetts MA 25 14 1 New England 1 Northeast |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| * Example Stata script using postfile to create | |
| * a dataset of results from an analysis. | |
| * This example simulates a female wage penalty X times | |
| * and compares the density of estimates to the normal density. | |
| * parameters for simulation | |
| local numiterations = 50 | |
| local samplesize = 500 | |
| * set the simulation seed just for reproducibility of this artificial example |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(tidyverse) | |
| library(EmpElastR) | |
| library(viridis) | |
| # Dube (2019) review: median estimates | |
| ests <- tibble(`Median, \n low-wage` = -0.04, `Median, \n any group` = -0.17) | |
| # SR elasticity is the base elasticity scaled by real barsize and indexing adjustments | |
| cbo_sr_rwta_elas <- function(x) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| set more off | |
| clear all | |
| * load CPS for population weights | |
| load_epiextracts, begin(1979m1) end(2018m12) sample(basic) keep(age statefips) | |
| keep if age >= 16 | |
| * convert monthly weight to annual | |
| replace basicwgt = basicwgt / 12 | |
| collapse (sum) pop = basicwgt, by(statefips year) | |
| tempfile statepops |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| marchcps %>% | |
| # adult/af universe for health insurance q | |
| filter(prpertyp == 2 | prpertyp == 3) %>% | |
| # workers last year with industry info | |
| filter(industry > 0) %>% | |
| # keep only private and public emp (drop self employed & without pay) | |
| filter(clwk == 1 | clwk == 2) %>% | |
| # convert 2012 Census industry codes to NAICS sectors | |
| # using codebook https://www2.census.gov/programs-surveys/demo/guidance/industry-occupation/census-2012-final-code-list.xls | |
| mutate( |
We use rclone to mount OneDrive as a network share in the directory ~/OneDrive.
First, log in as the user who needs OneDrive, and create the directory:
mkdir ~/OneDriveThen configure rclone:
rclone config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| clear all | |
| set more off | |
| * download CES data, if new | |
| !wget -N https://download.bls.gov/pub/time.series/ce/ce.data.0.AllCESSeries | |
| !wget -N https://download.bls.gov/pub/time.series/ce/ce.series | |
| !wget -N https://download.bls.gov/pub/time.series/ce/ce.industry | |
| * identify 3-digit industries | |
| insheet using ce.industry, clear tab |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(tidyverse) | |
| library(vroom) | |
| # sector names | |
| sector_names <- read_csv("https://raw.githubusercontent.com/Economic/ui_state_detailed/master/output/state_ui_industry_recoded.csv") %>% | |
| group_by(sector, sectorname) %>% | |
| tally() %>% | |
| select(sector, sector_name = sectorname) | |
| # Read in 2019 March CPS |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| YEAR | JAN | FEB | MAR | APR | MAY | JUNE | JULY | AUG | SEP | OCT | NOV | DEC | AVG | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1977 | 100.0 | |||||||||||||
| 1978 | 100.5 | 101.1 | 101.8 | 102.7 | 103.6 | 104.5 | 105.0 | 105.5 | 106.1 | 106.7 | 107.3 | 107.8 | 104.4 | |
| 1979 | 108.7 | 109.7 | 110.7 | 111.8 | 113.0 | 114.1 | 115.1 | 116.0 | 117.1 | 117.9 | 118.5 | 119.5 | 114.3 | |
| 1980 | 120.8 | 122.4 | 123.8 | 124.7 | 125.7 | 126.7 | 127.5 | 128.6 | 129.9 | 130.7 | 131.5 | 132.4 | 127.1 | |
| 1981 | 133.6 | 135.2 | 136.3 | 137.1 | 137.9 | 138.7 | 139.7 | 140.7 | 141.8 | 142.4 | 142.9 | 143.4 | 139.1 | |
| 1982 | 144.2 | 144.7 | 144.9 | 145.0 | 146.1 | 147.5 | 148.5 | 148.8 | 149.5 | 150.2 | 150.5 | 150.6 | 147.5 | |
| 1983 | 151.0 | 151.1 | 151.2 | 152.4 | 153.2 | 153.7 | 154.3 | 154.8 | 155.6 | 156.0 | 156.2 | 156.4 | 153.8 | |
| 1984 | 157.2 | 158.0 | 158.3 | 159.1 | 159.5 | 160.0 | 160.5 | 161.1 | 161.8 | 162.2 | 162.2 | 162.4 | 160.2 | |
| 1985 | 162.6 | 163.2 | 164.0 | 164.6 | 165.3 | 165.7 | 166.0 | 166.4 | 166.9 | 167.3 | 167.9 | 168.2 | 165.7 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(tidyverse) | |
| mydata <- mtcars | |
| groups <- c("cyl", "gear", "carb") | |
| group_summarize <- function(x) { | |
| mydata %>% | |
| rename(group_value = {{ x }}) %>% | |
| group_by(group_value) %>% |