R_Quiz_2

.pdf

School

New York University *

*We aren’t endorsed by this school

Course

266

Subject

Statistics

Date

Jan 9, 2024

Type

pdf

Pages

2

Uploaded by KidGooseMaster538

Report
R Quiz II 11/12/2023 Instructions : There is one long question in the quiz, you have 24 hours to complete and submit the quiz. Please submit your R script (.R) file with the code as well as one pdf document containing all the figures, tables and descriptions. The R code should only be in the R script, no other format will be graded. The tables and figures generated by R can be copied and pasted into a word document and then converted into a pdf document (use type=“text” in stargazer to generate the tables in proper format). The quiz uses one dataset you have already worked with ( census.csv ). Please comment out the absolute relative path once you have run the code and set the working directory to setwd(“ /Downloads") in the beginning of your script. E.g. #setwd(“C:/iris/Downloads") setwd(“ /Downloads") Questions about the quiz will not be entertained for the duration of the quiz. Good luck! Question 1 (a) Read in the census data ( census.csv ). Keep only data from the year 1940 for people between 20 and 55 years of age and retain only the following variables: year, sex, age, race, educ, labforce, wkswork1 . ( Hint : Examine the age variable and convert it to a variable of appropriate type named Age ) (10 points) (b) Examine the educ variable. What data type is it? Convert the educ variable to a numeric variable named education using the following key: (0:"n/a or no schooling", 2:"nursery school to grade 4", 6:"grade 5, 6, 7, or 8", 9:"grade 9", 10:"grade 10", 11:"grade 11", 12:"grade 12", 13:"1 year of college", 14:"2 years of college", 15:"3 years of college", 16:"4 years of college", 17:"5+ years of college") Be careful to code the variables exactly as given. (10 points) (c) Examine the sex variable. What data type is it? Create two dummy variables named female (which takes the value 1 when the person is female and takes the value 0 when the person is male) and male (which takes the value 1 when the person is male and takes the value 0 when the person is female). (10 points) (d) Regress wkswork1 on Age, education, male and female . Report the coefficient for male . What do you find? Why? (10 points) 1
(e) What alternative model would you suggest instead of the model specified in (d). Run the regression, generate a regression table and interpret the results. (10 points) (f) Examine the labforce variable. What data type is it? Create binary variable named employed which takes the value 1 when the person is in the laborforce and 0 when the person is not in the laborforce. (10 points) (g) Regress employed on Age, education and female , generate a regression table and interpret the results. What do you find? (10 points) (h) Test the joint hypothesis that the coefficients for education and female are zero and report the results of the joint test. What do you conclude? ( Hint : Use the library car and the function linearHypothesis() ) (10 points) (i) Is the model in part (g) appropriate? Provide a clear argument as to why or why not. (10 points) (j) Generate a descriptive statistics table for the following variables Age, wkswork1, education, female, employed . The table should contain mean, standard deviation, minimum, maximum and number of observations for each variable. (10 points) 2
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help