Description
- A total of 30 Masters students in a Statistics course were asked to state how long they take to finish their weekly homework.
The following is the reported time in hours:
2,3,1.5,3.5,4,3,1,3,2,3.5,4,3,2.5,2.5,2,2,1.5,2,2,3,3,
3,1,1,1,1.5,2,2.5,2.5,3
(a) Write your own R code (function) to calculate the sample mean without using the mean() R function then confirm
your answer using the mean() function
1 Xn
x¯ =  xi n i=1
(b) Write your own R code (function) to calculate the sample variance without using the sd() and var() R functions. You can use the mean() and sum() functions, then confirm your answer using the var() function
1  n                            
2Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â X 2Â Â Â Â Â Â Â Â Â 2
s =Â Â Â Â ï£ xi − nx¯  n − 1 i=1
- Caleb wishes to take P = $10,000 loan from a bank. The bank offers the loan at a monthly interest rate r = 3% for a period of n = 24 months. Calculate the monthly instalments m that Caleb will have to remit to the bank given that the principal is calculated as
1 − (1 + r)−n
P = mï£Â  
r
(Hint: First, make m the subject of the formula. That is, re-write the expression to obtain m = (.) then solve for m)
r
m = P ∗
1 − (1 + r)−n
Proof: Not reqired
2                                 1 Xn                        2 S                     =Â Â Â Â Â Â Â Â ï£ (xi − x¯)  n − 1 i=1 1 Xn         2                            2  = ï£ (xi − 2xix¯ + ¯x ) n − 1 i=1 1 Xn        2               Xn                    2 = ï£ xi − 2x¯ xi + nx¯  n − 1 i=1 i=1 Notice that   ¯        =              1 Xn Xi ⇒ Xn Xi = nX¯ X n i=1               i=1 1  n                                               ∴ S2 =       ï£X x                                 n − 1 i=1 1 Xn                                              =Â Â Â Â Â Â Â Â ï£ x      n − 1 i=1  =         n − 1 i=1 |