Assignment 0
- #intro-econometrics
- #assignment
- #R
- #data-cleaning
- #descriptive-statistics
- #wage-gap
- #expectation-variance
Toolkit
- 0
Part 0: Set-up. Create a project folder with sub-folders
Data,Code,Assignment,Solutions. Save the two data files inData. Open a new R script first thing, set the working directory withsetwd(...), installrioand load it withlibrary(rio). Submit a PDF solution set and the.Rfile; the first line of both has the student ID and assignment number, and "group:" plus names if you worked with others. - 1a
Q1: Read in the data. Read
exp2015_v2025.xlsxinto R as an object calledmydata. (A 2015 survey of household costs and incomes in Israel: 23,134 rows, 78 columns.) - 1b
Create
newdatacontaining only:sex age national marital ussrborn schoolty schooly diploma weekwhrs weekwrk workstat incomems chld017. - 2a
Q2: Data types. Use
summaryto find each variable's type. Which are characters? - 2b
Convert each character variable (including
age) to a factor withas.factor. - 2c
Create
age_numeric, a numeric version of the factorage(hint:as.numeric). - 3a
Q3: Subset the data. Subset the observations in
newdatato those with age between 25 and 62. Refer to the variable description file to interpret the values ofage_numeric. Why do we need to limit our observations to this age range? - 3b
Limit the observations in
newdatato individuals with less than 25 years of education (individuals with more than 24 years are considered data-entry errors). - 4a
Q4: Explore the data. Create a table with the following summary statistics for each numeric (non-factor) variable: average, median, minimum, maximum.
- 4b
What can be learned about the variable
incomemsfrom this table? - 4c
What percentage of the observations are women? (hint: use
sex) - 4d
What percentage of the observations are for people born in the USSR? (hint: use
ussrborn) - 5a
Q5: New variables. Create a variable called
empwhich takes the value 0 if the person is unemployed and 1 otherwise (hint: useworkstat). - 5b
Create a new variable for hourly wage called
wage_per_hour(hint: useweekwrk,weekwhrs,incomems). - 5c
Drop (delete) the variable
age_numericyou created in 2c (hint: usesubset). - 5d
Remove observations that have an outlier hourly wage (higher than 1,000 NIS), while keeping those that have hourly wage of
NA. Use the commandis.na. - 5e
Create a new variable
sex_by_nationthat classifies individuals into one of the following groups (andNAotherwise): Jewish men, Arab men, Jewish women, Arab women. Save it as a factor. - 6
Q6: Save the cleaned data. The object
newdatawill be used in other problem sets for this class. Save the cleaned version in yourDatafolder asHW1-cleanData.RDatausing the commandexport. - 7a
Q7: Explore across different groups. Calculate the average hourly wage for each of the groups in 5e.
- 7b
Describe in a couple of sentences the wage gaps between these different groups. What are some things that could cause these gaps?
- 7c
For the same groupings in 5e, calculate the employment rates (hint: use
empfrom 5a). - 8
Q8: Marriage in the labour market. Through independent analysis, answer: does being married provide an advantage or a disadvantage in the labour market?
a. Address differences in both wage and employment between married and unmarried people.
b. Does your answer change between men and women?
- 9a
Q9: Expectation, variance, covariance. is a random variable with mean and variance , and has mean and variance . Let . Evaluate:
a.
- 9b
b.
- 9c
c.
- 9d
d.
- 9e
e.
- 9f
f.
- 10a
Q10: Summation identities. Prove the following equalities hold.
a.
- 10b
b.
- 10c
c.
- 11a
Q11: A weighted average of independent variables. are independent random variables with and for all . Let
where are non-random real numbers.
a. Find in terms of and the 's.
- 11b
b. Find in terms of and the 's.
Solutions are Alfie's submitted work, not an official key.
Part B (R data handling) comes from Alfie's own R script, re-run on the raw data to check the outputs. Part A (statistics review, Q9 to Q11) has no solution in the source and is left as TODO. The cleaned newdata object from this assignment is reused in later problem sets.
Course review: Lec_13-Exam Review