0% found this document useful (0 votes)
8 views

assignment --2

Uploaded by

Rimsha pervaiz
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

assignment --2

Uploaded by

Rimsha pervaiz
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

MA185-4-AU 2024-25 Coursework 2 Page 1 of 6

MA185 Coursework 2
2403208
Not your reg number? Download another file!

General brief

▶ This coursework is designed to test your understanding of computational methods and basic data analysis
using R. The main emphasis of this coursework is on your practical skills. This coursework tests your
ability to solve problems numerically with R, test and debug your code, to apply it to solve a given problem,
to analyse data, and to interpret results of modelling.
▶ There are two questions. Please answer on the question paper writing your answers in the spaces provided.
You can print the question paper, write on it and scan it back. Alternatively, you can use annotate the pdf
with your writing, as long as it is legible. In addition to answering questions you are asked to prepare and
submit files with your R code.
▶ Where visualisation is required, you can copy–paste R figures in your pdf, or sketch them by hand. Your
sketches should be a faithful representation of the figures, capturing important features of visualisation, but
not showing every data point precisely. Please label axis and show scales.
▶ Each student has their own set of questions and their own data file to process. You need to download and
complete your own version of the coursework.
Check now that the registration number shown at the top of this page is the same as in your records.
▶ You can discuss topics of the module, including the topic of the coursework with other students.
You can use examples of code provided for you in this module, and you can use examples of code online.
However, you are ultimately responsible for making sure the code you submit meets the assessment criteria.
Make sure you understand your code fully, including the fragments you get from your tutors or online. Test
your code thoroughly and do not assume it’s working simply because you obtained it from a reliable source.
▶ It is not permitted to share your code with other students, neither to use a code shared with you by
another student, even if you modify it.
▶ You need to complete answers on this coursework, scan or take a picture of it, save the result as 2403208.pdf,
and submit it through FASER.
Please ensure that the pages are oriented appropriately — it is very hard to read text upside–down.
Please submit your answers as pdf, not as a sequence of pictures, and neither as a word file.
Failure to comply with the submission format will result in lost marks.
▶ Along with the 2403208.pdf file, submit your R code files: q1_2403208.R and q2_2403208.R.
As a part of the marking process we will download your R code files and attempt to run them.
Please ensure your code is saved as a plain–text file, not as pdf, image, and nor as a word file.
Failure to comply with the submission format will result in lost marks.
Please see the assessment criteria for the code on the next page.
▶ The coursework must be submitted via FASER before the deadline on Thursday 12th December 2024.

2403208 University of Essex 28th November 2024 → 12th December 2024 12noon
MA185-4-AU 2024-25 Coursework 2 Page 2 of 6

Assessment criteria

(a) Correctness — the code should correctly solve the stated problem.
▶ The code should solve the problem, i.e. produce and output the correct answer for the input data
stated in the question.
▶ The program should also meet the specific restrictions of each task, e.g. to use or not to use particular
packages.
(b) Effectiveness — the code should be fast, accurate and robust.
▶ The program should be designed to perform in a reasonable (preferably minimal possible) time.
▶ The program should use a reasonable (preferably minimal possible) amount of computer memory.
▶ The program should work correctly on any computer with R/RStudio installed.
(c) Educational value — the code should clearly reflect what you learnt in the module.
▶ The code should be human–readable and clearly written.
▶ The names of all variables should be self–explanatory or clarified with comments to let another user
change the parameters and test the code.
▶ The program must be flexible, easy to modify and able to cope with the change of parameters.
▶ The work should be beautiful and serve as a good example of computational practice.

2403208 University of Essex 28th November 2024 → 12th December 2024 12noon
MA185-4-AU 2024-25 Coursework 2 Page 3 of 6

Question 1 (40 marks). Download the file 2403208.csv from Moodle / MA185-4 / Assignment 2 / Data.
Write the R script q1_2403208.R in response to the following questions.
(a) Load the data from the file 2403208.csv in a data frame called d . Explore the data frame and state the
number of observations and variables.
(i) number of observations = 1074

(ii) number of variables = 2

(5 marks)
(b) Explore the variable x in the data frame d . Write the corresponding code in the R script q1_2403208.R
and state the answers below:
(i) mean value of x µ= 2.590023

(ii) standard deviation of x σ= 0.3610891

(iii) number of observations with x less than µ − 3σ = 13

(iv) number of observations with x more than µ + 3σ = 0

(15 marks)
(c) Produce a box plot for the variable x in the data frame d and sketch or copy–paste it below.

(10 marks)
(d) Select elements of the vector x which are not in the interval [µ − 3σ, µ + 3σ], where µ and σ are
the values obtained in part (b). Save the selected elements in the vector outliers and state the answers
below:
(i) mean value of outliers =

(ii) median of outliers =


(10 marks)

2403208 University of Essex 28th November 2024 → 12th December 2024 12noon
MA185-4-AU 2024-25 Coursework 2 Page 4 of 6

Question 2 (60 marks). Use the same file 2403208.csv from Moodle / MA185-4 / Assignment 2 / Data. Write
the R script q2_2403208.R in response to the following questions.
(a) Explore the dependency of variables x and y in the data frame d .
(i) Produce a scatter plot for the variable y as a function of x and sketch or copy–paste it below.

(ii) Would it be reasonable to approximate the dependency shown above as a linear function? State and
briefly explain your answer below.

(15 marks)

Question 2 continues on the next page ⇛

2403208 University of Essex 28th November 2024 → 12th December 2024 12noon
MA185-4-AU 2024-25 Coursework 2 Page 5 of 6

Question 2 continued...
(b) For this part, assume that dependency of y on x can be described as y = cxp , with some constants
c ∈ R and p ∈ R.
(i) State below how ln(y) would depend on ln(x).

(ii) Select observations in the data frame d for which x is strictly above 1. Save this part of the data
frame as dpart .
(iii) Expand the data frame dpart with variables logx and logy , representing ln(x) and ln(y), respec-
tively. Using data from dpart data frame only, produce a scatter plot for the variable ln(y) as a
function of ln(x) and sketch or copy–paste it below.

(iv) Would it be reasonable to approximate the dependency shown above as a linear function? State and
briefly explain your answer below.

(v) Fit a linear regression between ln(y) and ln(x) based on the data in dpart . Interpret the output
of the function, and state the estimate of the coefficient p below:
p=
(30 marks)

Question 2 continues on the next page ⇛

2403208 University of Essex 28th November 2024 → 12th December 2024 12noon
MA185-4-AU 2024-25 Coursework 2 Page 6 of 6

Question 2 continued...
(c) For this part, we still assume that dependency of y on x can be described as y = cxp , with some
constants c ∈ R and p ∈ R. To estimate c, we return to analysing the full data frame d .
(i) Using the estimate of p from part (b), expand d with the variable xp , representing xp .

(ii) Fit a linear regression between y and xp based on the data in d . Interpret the output of the
function, and state the estimate of the coefficient c below:
c=
(15 marks)

2403208 University of Essex 28th November 2024 → 12th December 2024 12noon

You might also like