> head(data)
# A tibble: 6 × 114
  year        datanum  serial  hhwt statefip     gq      pernum perwt nchild  nchlt5  relate  age     sex     marst   race    bpl       citizen yrimmig hispan  school  educ     empstat
  <dbl+lbl>     <dbl>   <dbl> <dbl> <dbl+lbl>    <dbl+l>  <dbl> <dbl> <dbl+l> <dbl+l> <dbl+l> <dbl+l> <dbl+l> <dbl+l> <dbl+l> <dbl+lbl> <dbl+l>   <dbl> <dbl+l> <dbl+l> <dbl+lb> <dbl+l>
1 2006 [2006]       1  168496    96  6 [Califor… 1 [Hou…      2   119 4 [4]   1 [1 c… 2 [Spo… 48 [48] 1 [Mal… 1 [Mar… 7 [Oth… 200 [Mex… 3 [Not…    1974 4 [Oth… 1 [No,… 11 [5+ … 3 [Not…
2 2006 [2006]       1  204251   287  6 [Califor… 1 [Hou…      1   283 3 [3]   0 [No … 1 [Hea… 44 [44] 1 [Mal… 1 [Mar… 1 [Whi… 200 [Mex… 3 [Not…    2004 1 [Mex… 1 [No,… 10 [4 y… 1 [Emp…
3 2005 [2005]       1 1050101    82 48 [Texas]   1 [Hou…      1   106 0 [0 c… 0 [No … 1 [Hea… 33 [33] 1 [Mal… 1 [Mar… 8 [Two… 200 [Mex… 3 [Not…    1999 1 [Mex… 1 [No,… 10 [4 y… 1 [Emp…
4 2005 [2005]       1  266418    81 12 [Florida] 1 [Hou…      1    80 1 [1 c… 0 [No … 1 [Hea… 37 [37] 1 [Mal… 4 [Div… 1 [Whi… 200 [Mex… 3 [Not…    2004 0 [Not… 1 [No,…  6 [Gra… 1 [Emp…
5 2005 [2005]       1  128135    79  6 [Califor… 1 [Hou…      1   101 0 [0 c… 0 [No … 1 [Hea… 30 [30] 1 [Mal… 1 [Mar… 1 [Whi… 200 [Mex… 3 [Not…    2002 1 [Mex… 1 [No,… 10 [4 y… 1 [Emp…
6 2005 [2005]       1  164590    59  6 [Califor… 1 [Hou…      2    80 6 [6]   0 [No … 2 [Spo… 38 [38] 1 [Mal… 1 [Mar… 7 [Oth… 200 [Mex… 3 [Not…    2005 1 [Mex… 1 [No,…  6 [Gra… 1 [Emp…
# ℹ 92 more variables: occ <dbl+lbl>, occ1990 <dbl+lbl>, ind <dbl+lbl>, ind1990 <dbl+lbl>, classwkr <dbl+lbl>, wkswork1 <dbl+lbl>, uhrswork <dbl+lbl>, incwage <dbl+lbl>,
#   qbpl <dbl+lbl>, qempstat <dbl+lbl>, qincwage <dbl+lbl>, mexico <dbl>, elsalv <dbl>, guatem <dbl>, earnhr <dbl>, earnwk <dbl>, rearnhr <dbl>, rearnwk <dbl>, rearnhr_occavgyr <dbl>,
#   rearnwk_occavgyr <dbl>, statefip_1 <int>, statefip_2 <int>, statefip_4 <int>, statefip_5 <int>, statefip_6 <int>, statefip_8 <int>, statefip_9 <int>, statefip_10 <int>,
#   statefip_11 <int>, statefip_12 <int>, statefip_13 <int>, statefip_15 <int>, statefip_16 <int>, statefip_17 <int>, statefip_18 <int>, statefip_19 <int>, statefip_20 <int>,
#   statefip_21 <int>, statefip_22 <int>, statefip_23 <int>, statefip_24 <int>, statefip_25 <int>, statefip_26 <int>, statefip_27 <int>, statefip_28 <int>, statefip_29 <int>,
#   statefip_30 <int>, statefip_31 <int>, statefip_32 <int>, statefip_33 <int>, statefip_34 <int>, statefip_35 <int>, statefip_36 <int>, statefip_37 <int>, statefip_38 <int>,
#   statefip_39 <int>, statefip_40 <int>, statefip_41 <int>, statefip_42 <int>, statefip_44 <int>, statefip_45 <int>, statefip_46 <int>, statefip_47 <int>, statefip_48 <int>, …
> sapply(data, function(x) attr(x, "label"))
$year
[1] "Census year"

$datanum
[1] "Data set number"

$serial
[1] "Household serial number"

$hhwt
[1] "Household weight"

$statefip
[1] "State (FIPS code)"

$gq
[1] "Group quarters status"

$pernum
[1] "Person number in sample unit"

$perwt
[1] "ACS person weight"

$nchild
[1] "Number of own children in the household"

$nchlt5
[1] "Number of own children under age 5 in household"

$relate
[1] "Relationship to household head [general version]"

$age
[1] "Age"

$sex
[1] "Sex"

$marst
[1] "Marital status"

$race
[1] "Race [general version]"

$bpl
[1] "Birthplace [general version]"

$citizen
[1] "Citizenship status"

$yrimmig
NULL

$hispan
[1] "Hispanic origin [general version]"

$school
[1] "School attendance"

$educ
[1] "Educational attainment [general version]"

$empstat
[1] "Employment status [general version]"

$occ
[1] "Occupation"

$occ1990
[1] "Occupation, 1990 basis"

$ind
[1] "Industry"

$ind1990
[1] "Industry, 1990 basis"

$classwkr
[1] "Class of worker [general version]"

$wkswork1
[1] "Weeks worked last year"

$uhrswork
[1] "Usual hours worked per week"

$incwage
[1] "Wage and salary income"

$qbpl
[1] "Flag for Bpl, Nativity"

$qempstat
[1] "Flag for Empstat, Labforce"

$qincwage
[1] "Flag for Incwage, Inctot, Incearn"

$mexico
[1] "Originally from Mexico"

$elsalv
[1] "Originally from El-Salvador"

$guatem
[1] "Originally from Guatemala"

$earnhr
[1] "Earnings per hour"

$earnwk
[1] "Earnings per week"

$rearnhr
[1] "Real hourly earnings (2005 base)"

$rearnwk
[1] "Real weekly earnings (2005 base)"

$rearnhr_occavgyr
[1] "Mean occup. hourly earn. for natives"

$rearnwk_occavgyr
[1] "Mean occup. weekly earn. for natives"

$statefip_1
NULL

$statefip_2
NULL

$statefip_4
NULL

$statefip_5
NULL

$statefip_6
NULL

$statefip_8
NULL

$statefip_9
NULL

$statefip_10
NULL

$statefip_11
NULL

$statefip_12
NULL

$statefip_13
NULL

$statefip_15
NULL

$statefip_16
NULL

$statefip_17
NULL

$statefip_18
NULL

$statefip_19
NULL

$statefip_20
NULL

$statefip_21
NULL

$statefip_22
NULL

$statefip_23
NULL

$statefip_24
NULL

$statefip_25
NULL

$statefip_26
NULL

$statefip_27
NULL

$statefip_28
NULL

$statefip_29
NULL

$statefip_30
NULL

$statefip_31
NULL

$statefip_32
NULL

$statefip_33
NULL

$statefip_34
NULL

$statefip_35
NULL

$statefip_36
NULL

$statefip_37
NULL

$statefip_38
NULL

$statefip_39
NULL

$statefip_40
NULL

$statefip_41
NULL

$statefip_42
NULL

$statefip_44
NULL

$statefip_45
NULL

$statefip_46
NULL

$statefip_47
NULL

$statefip_48
NULL

$statefip_49
NULL

$statefip_50
NULL

$statefip_51
NULL

$statefip_53
NULL

$statefip_54
NULL

$statefip_55
NULL

$statefip_56
NULL

$age_squared
NULL

$age_cubed
NULL

$age_to_fourth
NULL

$female
NULL

$married
NULL

$separated_divorced_widowed
NULL

$never_married
NULL

$less_than_high_school
NULL

$high_school_completion
NULL

$some_college
NULL

$bachelors_or_more
NULL

$years_in_usa
NULL

$employed
NULL

$unemployed
NULL

$in_labor_force
NULL

$rearnhr_occavgyr_fixed
NULL

$rearnwk_occavgyr_fixed
NULL

$log_rearnhr
[1] "Real hourly earnings (2005 base)"

$log_rearnwk
[1] "Real weekly earnings (2005 base)"

$log_rearnhr_occavgyr
NULL

$log_rearnwk_occavgyr
NULL

Task 2
In this task, we practise preparing the data.
(a) Create a dummy variable for each state. There are 51 states in the data. Hint: You can
use the variable statep. (3 %)
(b) Create the second, third, and fourth power of age. (3 %)
(c) Create a dummy variable that takes value 1 for females (sex equal to 2). (3 %)
(d) Create three dummy variables: for persons with marital status categorized as I) 1 or
2 (married, spouse present or absent), II) 3, 4, or 5 (separated, divorced, widowed), and
III) 6 (never married). (3 %)
1The discussion paper was later published as an article: Orrenius, Pia M.  Zavodny, Madeline (2015) The
Impact of Temporary Protected Status on Immigrants' Labor Market Outcomes. American Economic Review,
Vol. 105 (5), 576580.
1Syventävä ekonometria I / Advanced Econometrics I University of Turku
(e) Create four dummy variables for dierent educational levels: I) less than high school
(educational attainment less than 6), II) high school completion (educational attainment
equal to 6), III) some college (educational attainment more than 6 but less than 10), and
IV) bachelors or more (educational attainment at least 10). (3 %)
(f) Create a variable that tells the number of year spent in the USA. Note that there
might be errors such that the year immigrated is greater than the year of observation in
which case you can code the years in the USA as zeros. (3 %)
(g) Create three dummy variables describing labor force participation: I) for those employed (employment status equal to 1), II) for those unemployed (employment status equal
to 2), and III) for those part of the labor force. (3 %)
(h) Make a correction to the real hourly and weekly occupational earnings such that a
missing value is treated as zero. (3 %)
(i) Create the natural logarithms of I) real hourly earnings, II) real weekly earnings, III)
real hourly occupational earnings for natives, and IV) real weekly occupational earnings
for natives. (3 %)
Task 3
In this task, we practise describing the data both in table and graph form.
(a) Compute summary statistics for the data. Do some variables have missing observations?
If yes, which ones? (3 %)
(b) Draw a graph to describe some aspects of the data. Make sure that both axes have
understandable labels, and include a legend if necessary. (5 %)
(c) Discuss shortly why you chose that particular graph in (b) and explain your ndings. (5
%)
(d) Draw a second graph to describe some aspects of the data. Make sure that both axes have
understandable labels, and include a legend if necessary. The graph must be of dierent
type than you used in (b). (5 %)
(e) Discuss shortly why you chose that particular graph in (d) and explain your ndings. (5
%)
Task 4
In this task, we practise estimating linear regressions with ordinary least squares (OLS). These
regressions are not included in the Orrenius and Zavodny (2015) discussion paper. Use robust
standard errors in these regressions.
2Syventävä ekonometria I / Advanced Econometrics I University of Turku
(a) Estimate the impact of years in the US, gender, and age on employed. (5 %)
(b) Dene a control variable. Cite the source you used. (5 %)
(c) Add the other 3 powers of age, state, marital status, and education level as controls
into regression (a), and estimate it again. It is not necessary to report the coecients of
controls. (5 %)
(d) Run the same regression as in (a) using the natural logarithm of real weekly earnings as
the response variable. (5 %)
(e) Add the other 3 powers of age, state, marital status, and education level as controls
into regression (d), and estimate it again. It is not necessary to report the coecients of
controls. (5 %)
(f) Collect the results from (a), (c), (d), and (e) into table form. (5 %) The table should
include for each regression:
 the dependent variable (employed, natural logarithm of real weekly earnings),
 three independent variables (years in the US, gender, age) with their estimates and
robust standard errors,
 indicate which estimates are statistically signicant (p < 0.05),
 number of observations,
 R2,
 state whether the regression used controls or not.
(g) Interpret the results you collected in (f). (10 %)