0% found this document useful (0 votes)
15 views5 pages

R Lab Test Marking Scheme Guide

Uploaded by

9
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views5 pages

R Lab Test Marking Scheme Guide

Uploaded by

9
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

AQ077-3-2-PSMOD Lab Test Marking Scheme Page 1 of 5

Answer ALL questions.

Before you begin answering the questions, you are required to install 1 package by using the
following:
[Link](“moments”)
library(“moments”)

The questions below are based on the given dataset in CSV format, TestQ1_Q2_Data.csv.
Answer all the questions by using R programming language whenever necessary. Show the
main R code used and display the R results, in each relevant part of the questions.

QUESTION 1 (25 marks)

(a) (i) R code: hist(v1)

Level 2 Asia Pacific University of Technology & Innovation YYYY


AQ077-3-2-PSMOD Lab Test Marking Scheme Page 2 of 5

(ii) Majority of the values lie on the left and only a handful of extreme high values
lie on the right. This is a right or positively skewed distribution.

(b) (i) R code: boxplot(w)

(ii) Variable w has near symmetrical distribution. It might have a small positive
skewness because the upper portion of the box is slightly bigger than the lower
portion

(c) (i) R code: quantile(v3)

Minimum = 1.6; Q1 = 3.4; Median = 3.9; Q3 = 4.425; Q4 =5.5

(ii) Q1 = 3.4: 25% of the scores lie below 3.4


Median = 3.9 50% of the scores lie below 3.9
Q3 = 4.425 75% of the scores lie below 4.425
Q4 = 5.5 100% (all) of the scores lie below 5.5

(iii) R code: skewness(v3)

(d) (i) R code: plot(v1,v2)

Level 2 Asia Pacific University of Technology & Innovation YYYY


AQ077-3-2-PSMOD Lab Test Marking Scheme Page 3 of 5

(ii) If the points are aligned closely to form a clear straight line, we can conclude
that v1 and v2 are strongly correlated. Since the formation of straight line
pattern is not clear, we can conclude that the correlation between v1 and v2 is
weak.

(iii) R code: cor(v1,v2)

QUESTION 2 (25 marks)

(a) (i) R code: plot(TestQ1_Q2_Data[3:5])

(ii) Correlation between v4 and w is the highest. They have the clearest straight line
formation pattern.

(b) (i) R code: A=lm(w~v4)

Level 2 Asia Pacific University of Technology & Innovation YYYY


AQ077-3-2-PSMOD Lab Test Marking Scheme Page 4 of 5

(ii) w = 3.74077 + 0.57419v4

(iii) a = 3.74077 means that the predicted value of w will be 3.74077 if v4 = 0,


b = 0.57419 means that w will increase by 0.57419 when v4 increases by 1.

(iv) R2 = 0.5344 (53.44%)


53.44% of variance in w is explained by v4

(v) H0 : v4 does not affect w significantly


H1 : v4 does affect w significantly

(vi) Since p-value is < 0.05, we can reject H0, meaning v4 is a significant factor.

(c) (i) R code: A=lm(w~v4)


B=[Link](v4=8)
Predict(A,B,response=TRUE)

(d) (i) R code: plot(v4,w)

(ii)) R code: B=lm(w~v4)


Abline(B)

Level 2 Asia Pacific University of Technology & Innovation YYYY


AQ077-3-2-PSMOD Lab Test Marking Scheme Page 5 of 5

Level 2 Asia Pacific University of Technology & Innovation YYYY

You might also like