DEPARTMENT OF ECONOMICS ECON 4041H – RESEARCH METHODOLOGY Fall 2021, Peterborough Assignment #2 Due date: November 3, 2021 Instructions: You must provide your own unique solution. You may work with...

1 answer below »
knit in pdf please


DEPARTMENT OF ECONOMICS ECON 4041H – RESEARCH METHODOLOGY Fall 2021, Peterborough Assignment #2 Due date: November 3, 2021 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. Each question is 20 marks and each part is of equal value. Submit solution through SafeAssign. Submission of one file generated using RMarkdown is best. I will also accept the submission of two files: your R command file, and a MS Word .doc (or alternative wordprocessor) file containing graphs and comments/answers to questions. If you cannot knit your RMarkdown file, submit the output from the parts that knit success- fully, then submit your code that won’t knit in a separate file. Do NOT submit an RMarkdown command file only. Data: Use the labour force survey from Bb, “lfs21.rds”. For the analysis below, include only those age <70 years (variable age_12). 1. test the relationship between age (age_12) and wages (hrlyearn). a. generate a scatterplot between wages on the y-axis and age on the x-axis. comment on anything you see. b. generate a lowess plot of wages and age using a random sample of 10,000 observations. this command is computationally-intensive, so running it on the full sample will be very slow. comment on what you see. c. run a regression using age to explain wages, wage = α + β age+ ε . treat age as a cardinal variable (ie. not categorical—acceptable here because the age categories are all equally-spaced 5-year intervals). report the regression output, and explain what the output means. d. test whether wages are a linear function of age using age as a factor variable. supple- ment your test using “contrast() with “poly” option. comment on your results 2. run a regression of wages on age_12 and age_122 (wage = α +β1 age+β2 age2 + ε). a. report the regression output and explain the coefficients. b. test the residuals of this regression, and of the regression in question 1.c. above. c. compare the results of this regression to the regression in question 1.c., and compare the results from the residual tests above. can you draw a conclusion regarding which model fits better? econ 4041h - assignment 2 3. run the regression from 2, and add in sex and educ (education). your regression is now wage = α +β1 age+β2 age2 +β3 sex+β4 education+ ε . a. report regression results and comment. b. estimate the adjusted mean wage for: i. a 25 year-old female. ii. a 52 year-old male with a highschool education only. iii. university degree (undergrad and beyond), by sex. c. generate a plot of estimated wages for each level of education by sex. d. generate a plot of estimated wages by age. e. generate a plot of the marginal effect of age on wages. note: margins() is computationally- intensive and will take some time to run. 4. rerun the model from question 2, and add in a third-order polynomial term on age_12 a. discuss the coefficients, and comment on whether scaling of age variable is necessary. does this model fit better than the quadratic model from question 2? b. modify the regression, adding in covariates sex and educ (wage=α+β1 age+β2 age2+ β3 age3 + β4 sex+ β5 education+ ε). estimate the adjusted mean wage for university degree holders, by sex. how do these results compare to those of question 3.b.iii? c. using the revised model from 4.c. above, plot the estimated wages by age. compare results to those from question 3.d. what is effect of adding a third-order polynomial? d. using the revised model from 4.c. above, plot the marginal effect of age on wages. compare results to those from question 3.e. what is effect of adding a third-order polynomial? 5. fit a fractional polynomial explaining wages as a fractional polynomial function of age. in- clude the sex and educ covariates in the model, but not in the fractional polynomial function. a. discuss the coefficients, and comment on whether scaling of age variable is necessary b. generate a plot of estimated wages by age c. generate a plot of the marginal effect of age on wages d. estimate the adjusted mean wage for university degree holders, by sex. how do these results compare to those of question 3.b.iii and 4.b? 2 years="" (variable="" age_12).="" 1.="" test="" the="" relationship="" between="" age="" (age_12)="" and="" wages="" (hrlyearn).="" a.="" generate="" a="" scatterplot="" between="" wages="" on="" the="" y-axis="" and="" age="" on="" the="" x-axis.="" comment="" on="" anything="" you="" see.="" b.="" generate="" a="" lowess="" plot="" of="" wages="" and="" age="" using="" a="" random="" sample="" of="" 10,000="" observations.="" this="" command="" is="" computationally-intensive,="" so="" running="" it="" on="" the="" full="" sample="" will="" be="" very="" slow.="" comment="" on="" what="" you="" see.="" c.="" run="" a="" regression="" using="" age="" to="" explain="" wages,="" wage="α" +="" β="" age+="" ε="" .="" treat="" age="" as="" a="" cardinal="" variable="" (ie.="" not="" categorical—acceptable="" here="" because="" the="" age="" categories="" are="" all="" equally-spaced="" 5-year="" intervals).="" report="" the="" regression="" output,="" and="" explain="" what="" the="" output="" means.="" d.="" test="" whether="" wages="" are="" a="" linear="" function="" of="" age="" using="" age="" as="" a="" factor="" variable.="" supple-="" ment="" your="" test="" using="" “contrast()="" with="" “poly”="" option.="" comment="" on="" your="" results="" 2.="" run="" a="" regression="" of="" wages="" on="" age_12="" and="" age_122="" (wage="α" +β1="" age+β2="" age2="" +="" ε).="" a.="" report="" the="" regression="" output="" and="" explain="" the="" coefficients.="" b.="" test="" the="" residuals="" of="" this="" regression,="" and="" of="" the="" regression="" in="" question="" 1.c.="" above.="" c.="" compare="" the="" results="" of="" this="" regression="" to="" the="" regression="" in="" question="" 1.c.,="" and="" compare="" the="" results="" from="" the="" residual="" tests="" above.="" can="" you="" draw="" a="" conclusion="" regarding="" which="" model="" fits="" better?="" econ="" 4041h="" -="" assignment="" 2="" 3.="" run="" the="" regression="" from="" 2,="" and="" add="" in="" sex="" and="" educ="" (education).="" your="" regression="" is="" now="" wage="α" +β1="" age+β2="" age2="" +β3="" sex+β4="" education+="" ε="" .="" a.="" report="" regression="" results="" and="" comment.="" b.="" estimate="" the="" adjusted="" mean="" wage="" for:="" i.="" a="" 25="" year-old="" female.="" ii.="" a="" 52="" year-old="" male="" with="" a="" highschool="" education="" only.="" iii.="" university="" degree="" (undergrad="" and="" beyond),="" by="" sex.="" c.="" generate="" a="" plot="" of="" estimated="" wages="" for="" each="" level="" of="" education="" by="" sex.="" d.="" generate="" a="" plot="" of="" estimated="" wages="" by="" age.="" e.="" generate="" a="" plot="" of="" the="" marginal="" effect="" of="" age="" on="" wages.="" note:="" margins()="" is="" computationally-="" intensive="" and="" will="" take="" some="" time="" to="" run.="" 4.="" rerun="" the="" model="" from="" question="" 2,="" and="" add="" in="" a="" third-order="" polynomial="" term="" on="" age_12="" a.="" discuss="" the="" coefficients,="" and="" comment="" on="" whether="" scaling="" of="" age="" variable="" is="" necessary.="" does="" this="" model="" fit="" better="" than="" the="" quadratic="" model="" from="" question="" 2?="" b.="" modify="" the="" regression,="" adding="" in="" covariates="" sex="" and="" educ="" (wage="α+β1" age+β2="" age2+="" β3="" age3="" +="" β4="" sex+="" β5="" education+="" ε).="" estimate="" the="" adjusted="" mean="" wage="" for="" university="" degree="" holders,="" by="" sex.="" how="" do="" these="" results="" compare="" to="" those="" of="" question="" 3.b.iii?="" c.="" using="" the="" revised="" model="" from="" 4.c.="" above,="" plot="" the="" estimated="" wages="" by="" age.="" compare="" results="" to="" those="" from="" question="" 3.d.="" what="" is="" effect="" of="" adding="" a="" third-order="" polynomial?="" d.="" using="" the="" revised="" model="" from="" 4.c.="" above,="" plot="" the="" marginal="" effect="" of="" age="" on="" wages.="" compare="" results="" to="" those="" from="" question="" 3.e.="" what="" is="" effect="" of="" adding="" a="" third-order="" polynomial?="" 5.="" fit="" a="" fractional="" polynomial="" explaining="" wages="" as="" a="" fractional="" polynomial="" function="" of="" age.="" in-="" clude="" the="" sex="" and="" educ="" covariates="" in="" the="" model,="" but="" not="" in="" the="" fractional="" polynomial="" function.="" a.="" discuss="" the="" coefficients,="" and="" comment="" on="" whether="" scaling="" of="" age="" variable="" is="" necessary="" b.="" generate="" a="" plot="" of="" estimated="" wages="" by="" age="" c.="" generate="" a="" plot="" of="" the="" marginal="" effect="" of="" age="" on="" wages="" d.="" estimate="" the="" adjusted="" mean="" wage="" for="" university="" degree="" holders,="" by="" sex.="" how="" do="" these="" results="" compare="" to="" those="" of="" question="" 3.b.iii="" and="" 4.b?="">
Answered 1 days AfterNov 02, 2021

Answer To: DEPARTMENT OF ECONOMICS ECON 4041H – RESEARCH METHODOLOGY Fall 2021, Peterborough Assignment #2 Due...

Mohd answered on Nov 03 2021
138 Votes
---
title: "Regression economics"
author: "Bassi"
date: "11/03/2021"
output:
word_document: default
html_document:
df_print: paged
pdf_document: default

---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE,cache = TRUE,warning = FALSE,message = FALSE,dpi = 180,fig.width = 8,fig.height = 5)
```
```{r}
library(readr)
library(magrittr)
library(dplyr)
library(ggplot2)
library(rmarkdown)
library(MASS)
library(skimr)
library(ggeffects)
```
Test the relationship between age (age_12) and wages (hrlyearn).
a. Generate a scatterplot between wages on the y-axis and age on the x-axis. Comment on anything you see.
b. Generate a lowess plot of wages and age using a random sample of 10,000 observations.
This command is computationally-intensive, so running it on the full sample will be
very slow. Comment on what you see.
c. Run a regression using age to explain wages, wage = α + β age + ε. Treat age as a
cardinal variable (ie. not categorical—acceptable here because the age categories are
all equally-spaced 5-year intervals). Report the regression output, and explain what the
output means.
d. Test whether wages are a linear function of age using age as a factor variable. Supple�ment your test using “contrast() with “poly” option. Comment on your results
```{r}
lfs <- readRDS("~/data/lfs21.rds")
lfs<-lfs%>%
filter(age_12!="70 and over")
```
#1a) Generate a scatterplot
```{r}
age=lfs$age_12
wage=lfs$hrlyearn
plot(age,wage,main="Scatterplot of Wages and Age",xlab="age",ylab="wages",pch=12)
```
```{r}
#1b) lowess plot
#lowess(age,wage,iter=10000,f=0.01)
#lines(lowess(age,wage,iter=10000,f=0.01),col="red")
```
```{r}
#1c)...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here