Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

BEEM011 Assignment 2023 Instructions

Summative assessment

Direction:This Assignment consists of 2 questions.There are 100 marks in total.

For each question,5%of marks are reserved for evidence of best practice in R coding,marks for sub-questions therefore add up to 95 of the 100 total marks for the assignment.

Unless otherwise stated you should use a 5%significance level for hypothesis tests.

Answer all the questions and upload your Jupyter Notebook and a PDF copy to the ELE2 submission point.

WRITE YOUR R CODE AND ANSWERS FOR ALL OF THE QUESTIONS IN THIS JUPYTER NOTEBOOK.PLEASE INCLUDE YOUR CANDIDATE NUMBER IN A COMMENT AT THE

TOP OF YOUR CODE.

DO NOT PUT YOUR NAME ANYWHERE IN THE ASSIGNMENT.

Make sure to include your Jupyter Notebook file (.ipynb)as an upload to your submission. Please comment on each procedure to explain what you are doing (or intend to do).

Submission is via ELE2.Submission of an incorrect filetype will result in the deduction of marks.

Read and answer each of the questions using your own code and words.

Collaboration with others and plagiarism of other people's code is not permitted.Presenting  someone else's code as your own work is misrepresentation,an academic conduct offence.

For the assignment I am not expecting you to use packages outside of what we have learnt in class.If you use additional packages I expect you to explain why,demonstrate your

understanding of how they are functioning and justify why you need this package.

We have covered the following packages in the libraries:

· readx

·AER

·sandwich

· MASS

·margins

·stargazer

·plm

·ggplot2

· haven

·psych

Some people will also have used the following packages for installation:

· base

· devtool

Question 1:Probability

The average yields per hectare for cereal crops in the UK are normally distributed with mean 3,500 tonnes per hectare and standard deviation 2,500 tonnes.

Any crop whose yield is greater than 5,000 tonnes is defined as being productive.

a)Define the mean and standard deviation of the distribution as variables in R [2 marks]

In [  ]:

b)Write down the probability that a randomly selected/sampled crop is productive and use R to calculate this probability using the standard normal transformation.[4 marks]

In  [ ]:

In    [  ]:

In  [ ]:

c)Write down the probability that a randomly selected crop yields more than 6,500 tonnes per hectare annually and use R to calculate this probability.[4 marks]

d)A crop is chosen at random.Given that the crop is productive,write down an equation for  calculating the probability that the yield for this crop is greater than 6,500 tonnes.You should

use   P(A|B),P(B|A)and   P(A∩B)in    your    equation   where:

A=crop is productive (exceeds 5,000 tonnes per year)

B=crop yield exceeds 6,500 tonnes per year

[5 marks]

Answer

e)Use R to calculate the probability that the yield for this randomly chosen crop is greater than 6,500 tonnes.Round your result to two decimal places.[2 marks]

 

f)A researcher has collected data on a sample of 105 new genetically modified (GM)cereal crops.The sample mean of the yields is 3,900 tonnes per hectare and the sample standard deviation is 2,100 tonnes per hectare.

Test the null hypothesis that the genetically modified (GM)cereal crops have a population

mean yield equal to that of the UK cereal crops in part a)against the alternative hypothesis

that the GM crops have a higher population mean yield.Use a 5%significance level.[5 marks]

Answer

In  [  ]:


In  [  ]:

In  [  ]:

In  [  ]:

In  [  ]:

g)Calculate the p-value for this test statistic and provide an interpretation of what this means. [3 marks]

Answer

Question 22023

The Salary Gap data set (salarydata.csv)contains data on salaries for a sample of individuals between 2001 and 2020.The variables in the data set include:

·Salary:the annual salary of the individual before tax in British pounds (GBP) ·Age:the  age  of  the  individual

·Duration:The number of years an individual has spent in their current job

·Gender:Self   reported   gender   (Male,Female,Non-binary)

·Children:The number of children (aged under 16)that the individual has parental rights for

Part 1:Explore the data

a)Load the Salary Gap csv and assign it to an object labelled salarydata [2 marks]

b)Check whether the panel is balanced?Explain the method you have used.[4 marks]

c)Look at the data.What type of data is the gender variable loaded as?[2 marks]

Convert the gender variable to a factor variable and set the base level to Male.[2 marks]

 


d)Using histograms,plot the distribution of salaries for males,females and non-binary individuals in the sample in 2020.Describe the distributions.[10 marks]

Note:functions like ggplot2 don't like panel data frame structures

Part 2:Cross section analysis

a)Set the seed to your candidate number.[1 mark]

Use R to randomly select a year from between 2001 and 2020.Report which year was

selected.

Create a subset of the data called mysubset for the selected year.[3 marks]

Note:You should verifv that the sample has been correctly constructed bv inspecting

In    [  ]:

You want to explore whether there is evidence of a salary gap between people of different

genders.Given the distributions of salaries in the sample you decide to estimate the following model:

log(salary)=o+β₁Age;+β₂Duration;+β₃Female;+β₄Nonbinary;+uj,

where Female;is an indicator variable equal to 1 if the individual self reported as female and

0 otherwise,and Nonbinary is an indicator variable equal to  1 if the individual self reported

as nonbinary and 0 otherwise.

b)Explain why an indicator variable for Male is not included in the model [3 marks]

Answer

c)Using the data set mysubset,estimate the model.[3 marks]

In   [ ]:

d)How do you interpret the coefficient on duration and its significance?[4 marks]

Answer

e)Do you find any evidence of a difference in the mean salaries for people of different

genders?[4 marks]

Answer

f)The variable children was not included in the model.Explain how this might affect your results?Does your data provide any information about this?[6 marks]

Answer

g)Re-estimate the model with the addition of children as a regressor.Explain whether your

interpretation of the results has changed [5 marks]

In  [  ]:

Answer

Part 3:Panel data analysis [21 marks]

a)Explain the advantage of using the full panel of data from 2001 to 2020 for your analysis [2 marks]

Type Markdown and LaTeX:a²

b)Why would you want to include entity and time fixed effects?[3 marks]

Type Markdown and LaTeX:a²

c)Write down a panel linear model with entity and time fixed effects.The model should

express the log of salary as a function of age,duration,children and an interaction between gender and children.[4 marks]

Type Markdown and LaTeX:a²

d)Explain how the interaction between gender and children influences the expected change in salary for individuals with one additional child.[3 marks]

Type Markdown and LaTeX:a²

e)Estimate the model using the full salarydata dataset and interpret the coefficients on regressors related to gender and children.[2 marks]

In  [  ]:

Answer

f)Explain how you would test the null hypothesis that there is no gender based salary gap. Clearly explain your null and alternative hypothesis,the test statistic,significance level and

rejection rule.[5 marks]

Type Markdown and LaTeX:q2

g)Conduct the hypothesis test and discuss your conclusions.[2 marks]

In    [  ]:                                                                                        

Answer