Assignment #2
Due date: February 28, 2023 Instructions: You must provide your own unique solution. You may work with others, but each of you is responsible for submitting your own problem set solution. Question values are listed for each question. Submit solution through SafeAssign. Ideally you will submit your RMarkdown file output, preferably in pdf format, but word or html are acceptable. Blackboard won’t accept html files, so if submitting an html file, first zip it and submit the zipped version.
For this assignment you will use three labour force surveys, from June 1977, June 1997 and June 2022. They are amalgamated and saved for you in the datafile lfs3. rds, in the Bb data folder. All variables required will be referenced below.
1. Data cleaning and preparation. [5 marks] We need to create two variables, and adjust wages: a. Create a variable capturing part-time vs. full-time work status. The datafile contains a variable ftptmain. Recode this variable from its current four categories into two. Code it as a 1 for part-time and 0 for full-time. To confirm you have coded it correctly, generate a 2×2 table of the original variable and the new variable. b. Create a numeric version of age. The datafile contains an age variable age_12, coded as a factor variable with 12 levels. Create a numeric version of age_12 using the as_numeric() function. Note that the variable age_12 consists of five-year age group-ings from 15-19 through 65-69, and then there is a catch-all category for 70 and over. Drop the category for 70 and over so that the numeric variable captures five-year age groupings. By converting a factor into a numeric with equal numeric spacing, it is a true linear representation of age, and we can use polynomial functions of age. To con-firm you have it correctly coded, you could generate a basic 2×2 table, but that will be large. Instead report the diagonal elements (function diag()) of the 2×2 table of the original age variable and the numeric variable of age. If you have done it correctly, all off-diagonal elements of this table will be zeroes, so the diagonal element will show the correct number of observations. c. Adjust wages for inflation by multiplying the wage variable hrlyearn by the ratio of the CPIs from June 2022 and June 1997, a ratio of 152.9/90.5. Multiplying the wages in 1997 by this ratio converts them into the same base year as for the 2022 data. Report the mean, median, maximum and minimum wages for 1997 (adjusted) and for 2022. Note: wages were not collected until 1997, so all earlier labour force surveys, including 1977, do not include wages.