Recitation 2

Part 1

Review the code and solution method for the search model.

Part 2

Review the code and solution method for the entry/exit model.

Part 3: CPS data

Reading the data

Let’s take a look at data from the CPS on wages, employment status, and labor market transitions. Here is code to read in the data:

using CSV, DataFrames, DataFramesMeta, Statistics

data = CSV.read("../data/cps_00019.csv",DataFrame)
183277×22 DataFrame
183252 rows omitted
Row YEAR SERIAL MONTH HWTFINL CPSID ASECFLAG PERNUM WTFINL CPSIDP AGE SEX RACE MARST EMPSTAT LABFORCE UHRSWORKT DURUNEMP EDUC HOURWAGE PAIDHOUR EARNWEEK UHRSWORKORG
Int64 Int64 Int64 Float64 Int64 Int64? Int64 Float64 Int64 Int64 Int64 Int64 Int64 Int64 Int64 Int64 Int64 Int64 Float64 Int64 Float64 Int64
1 2018 2 1 1609.49 20161200000200 missing 1 1420.75 20161200000201 72 1 100 1 10 2 55 999 81 99.99 0 9999.99 999
2 2018 3 1 1797.04 20180100000300 missing 1 2053.27 20180100000301 66 1 100 1 10 2 997 999 111 99.99 0 9999.99 999
3 2018 3 1 1797.04 20180100000300 missing 2 1797.04 20180100000302 61 2 100 1 10 2 997 999 111 99.99 0 9999.99 999
4 2018 9 1 1735.76 20171000000400 missing 1 1735.76 20171000000401 52 2 200 4 10 2 40 999 73 20.84 2 903.0 999
5 2018 9 1 1735.76 20171000000400 missing 4 3069.4 20171000000404 19 2 200 6 10 2 40 999 73 10.0 2 400.0 40
6 2018 10 1 1582.77 20171000000600 missing 1 1582.77 20171000000601 56 2 200 4 10 2 40 999 111 25.0 2 1250.0 999
7 2018 10 1 1582.77 20171000000600 missing 2 2409.42 20171000000602 22 2 200 6 10 2 30 999 81 9.5 2 70.0 999
8 2018 11 1 1795.64 20170100000900 missing 1 1795.64 20170100000901 23 2 100 6 10 2 40 999 124 99.99 0 9999.99 999
9 2018 11 1 1795.64 20170100000900 missing 2 1795.64 20170100000902 24 2 100 6 10 2 40 999 124 99.99 0 9999.99 999
10 2018 12 1 1927.69 20170100001000 missing 1 1927.69 20170100001001 59 2 200 1 10 2 55 999 111 99.99 0 9999.99 999
11 2018 12 1 1927.69 20170100001000 missing 2 2151.5 20170100001002 53 1 200 1 10 2 58 999 81 99.99 0 9999.99 999
12 2018 14 1 2926.96 20171200001200 missing 1 2926.96 20171200001201 24 2 200 6 10 2 40 999 73 99.99 0 9999.99 999
13 2018 15 1 1861.24 20161200000800 missing 1 1557.36 20161200000801 60 1 100 1 10 2 40 999 124 99.99 0 9999.99 999
183266 2018 72283 3 275.748 20170107444500 2 3 280.118 20170107444503 33 1 100 6 21 2 999 61 73 99.99 0 9999.99 999
183267 2018 72286 3 332.029 20170307448900 2 1 332.029 20170307448901 44 2 100 1 10 2 30 999 111 99.99 0 9999.99 999
183268 2018 72286 3 332.029 20170307448900 2 2 334.955 20170307448902 46 1 100 1 10 2 45 999 91 99.99 0 9999.99 999
183269 2018 72288 3 341.227 20171207232200 2 1 341.227 20171207232201 42 1 100 6 10 2 40 999 111 99.99 1 365.0 999
183270 2018 72288 3 341.227 20171207232200 2 2 281.741 20171207232202 41 2 100 4 10 2 40 999 73 14.0 2 560.0 40
183271 2018 72289 3 256.804 20170107445500 2 1 256.804 20170107445501 42 1 100 4 10 2 45 999 73 99.99 0 9999.99 999
183272 2018 72291 3 281.741 20171207232600 2 1 507.056 20171207232601 42 1 100 1 10 2 40 999 111 99.99 1 519.23 999
183273 2018 72291 3 281.741 20171207232600 2 2 281.741 20171207232602 43 2 100 1 10 2 50 999 123 99.99 1 1442.3 999
183274 2018 72291 3 281.741 20171207232600 2 4 377.923 20171207232604 18 1 100 6 10 2 15 999 60 9.0 2 108.0 12
183275 2018 72292 3 288.99 20171207232700 2 1 288.99 20171207232701 32 2 100 6 10 2 40 999 81 25.0 2 1000.0 40
183276 2018 72292 3 288.99 20171207232700 2 2 288.99 20171207232702 30 2 100 1 10 2 20 999 81 99.99 0 9999.99 999
183277 2018 72292 3 288.99 20171207232700 2 3 336.057 20171207232703 31 1 100 1 10 2 997 999 91 99.99 1 1346.0 999

As you can see from the preview of the data, the data is taken from January-March 2018. Here is a quick snippet of code to see how many observations we have on average per person:

@chain data begin
    groupby(:CPSIDP)
    @combine :T = length(:EMPSTAT)
    @combine :average = mean(:T) :frac_panel = mean(:T.>1)
end
1×2 DataFrame
Row average frac_panel
Float64 Float64
1 1.83191 0.582806

So we see that more than half of the individuals in this sample can be found in more than one month of the data.

The @chain macro comes from the package DataFramesMeta and is a convenient syntax for composing operations into one block. For example:

@chain x begin
    func1(y1)
    func2(y2)
    func3(y3)
end

is equivalent to

func3(func2(func1(x,y1),y2),y3)

Calculating some moments

You may find the codebook useful for understanding particular variables. We have already limited the data to individuals who are working (EMPSTAT=10), have a job but did not work last week (EMPSTAT==12), or are unemployed (EMPSTAT==21).

Suppose we wanted to use the panel dimension to measure transition rates. Here is a simple way to do that by simply measuring transitions between January and Feburary.

data[!,:E] .= data.EMPSTAT.<21 #<- code the employment variable

data_jan = @chain data begin
    @subset :MONTH.==1
    @select :CPSIDP :AGE :SEX :EDUC :RACE :E
    @rename :E_lag = :E
end

data_merged = @chain data begin
    @subset :MONTH.==2
    @select :CPSIDP :E
    innerjoin(data_jan,on=:CPSIDP)
end
41262×7 DataFrame
41237 rows omitted
Row CPSIDP E AGE SEX EDUC RACE E_lag
Int64 Bool Int64 Int64 Int64 Int64 Bool
1 20161200000201 true 72 1 81 100 true
2 20180100000301 true 66 1 111 100 true
3 20180100000302 true 61 2 111 100 true
4 20170100000901 true 23 2 124 100 true
5 20170100000902 true 24 2 124 100 true
6 20170100001001 true 59 2 111 200 true
7 20170100001002 true 53 1 81 200 true
8 20171200001201 true 24 2 73 200 true
9 20161200000801 true 60 1 124 100 true
10 20161200000802 true 57 2 123 100 true
11 20170100001401 false 50 2 73 200 false
12 20170100001403 true 18 1 81 200 true
13 20170100001405 true 29 1 50 200 true
41251 20161107451001 true 59 1 92 100 true
41252 20161107451901 true 59 1 91 100 true
41253 20171107237801 true 45 1 91 100 true
41254 20171107237802 true 37 2 123 100 true
41255 20171207232201 true 41 1 111 100 true
41256 20171207232202 true 41 2 73 100 true
41257 20161107452301 true 38 1 73 100 true
41258 20161107452302 true 29 2 73 100 true
41259 20170107445501 true 41 1 73 100 true
41260 20171207232601 true 42 1 111 100 true
41261 20171207232602 true 43 2 123 100 true
41262 20171207232604 true 17 1 60 100 true

So now we can calculate the overall transition rate out of unemployment:

@combine data_merged begin
    :EU =  1-mean(:E[:E_lag.==1])
    :UE = mean(:E[:E_lag.==0])
end 
1×2 DataFrame
Row EU UE
Float64 Float64
1 0.00997824 0.377255

So here we’re estimating a very low separation rate and a pretty high hazard rate out of unemployment.

Observable heterogeneity

Next we’ll define a very simple education classification (Bachelor’s degree or not) and race classification (white vs non-white), and use groupby to calculate rates separately by demographics:

@chain data_merged begin
    @transform begin
        :bachelors = :EDUC.>=111
        :nonwhite = :RACE.!=100 
    end
    groupby([:bachelors,:nonwhite,:SEX])
    @combine begin
       :EU =  1-mean(:E[:E_lag.==1])
       :UE = mean(:E[:E_lag.==0])
    end 
end
8×5 DataFrame
Row bachelors nonwhite SEX EU UE
Bool Bool Int64 Float64 Float64
1 false false 1 0.0131 0.40257
2 false false 2 0.0110061 0.385417
3 false true 1 0.0159176 0.338346
4 false true 2 0.0150977 0.300885
5 true false 1 0.00447284 0.315315
6 true false 2 0.00601388 0.489362
7 true true 1 0.00547303 0.342105
8 true true 2 0.00836237 0.290323

What do these differences in transition rates tell you about how we should extend the simple model with homogenous parameters?

A Disclaimer for IPUMS CPS data

These data are a subsample of the IPUMS CPS data available from cps.ipums.org. Any use of these data should be cited as follows:

Sarah Flood, Miriam King, Renae Rodgers, Steven Ruggles, J. Robert Warren, Daniel Backman, Annie Chen, Grace Cooper, Stephanie Richards, Megan Schouweiler, and Michael Westberry. IPUMS CPS: Version 11.0 [dataset]. Minneapolis, MN: IPUMS, 2023. https://doi.org/10.18128/D030.V11.0

The CPS data file is intended only for exercises as part of ECON8208. Individuals are not to redistribute the data without permission. Contact for redistribution requests. For all other uses of these data, please access data directly via cps.ipums.org.