please do assignment Part Bwith R programming
ECON 327 Assignment 1 Winter Term 1, 2021-2022 Instructions This Assignment 1 has two parts. For Part A, write down your answers on answer sheets. Take pictures of your answer sheets and convert them into a single PDF file (suggest using CamSanner, see the instruction on Canvas in the Welcome module). You can also write down your answers in a software like Microsoft Word, Pages, and LATEX, then generate a single PDF file. Upload this PDF file to Canvas. For Part B, it should be completed with R. Write down your answers and codes in a R Markdown file (.rmd) using the RStudio, then generate a PDF file. Upload the R Markdown file and the PDF file to Canvas. Please upload all files to Canvas by Sunday, October 10th (11:59 pm Vancouver Time). 1 Part A [20 points] Question 1 [5 points] Suppose you were interested in determining the average monthly expenditures of college students on video games in Canada. (a) How would you define the population for this problem? (b) How would you obtain sample data for this study? (c) Why would you want to ensure that you survey a random sample of college students? Question 2 [5 points] In a recent survey, 12 students at the UBCO were asked approximately how many hours per week they spend on the Internet. Their responses were: 13, 0, 5, 8, 22, 7, 3, 0, 15, 12, 13, and 17. (a) What are the mean and median for this data? Show your calculation steps. (b) Is the distribution of these numbers skewed to the right, skewed to the left or symmetric? Why? (c) What is the standard deviation for this data? Show your calculation steps. (d) What is the coefficient of variation for this data? Show your calculation steps. 2 Question 3 [5 points] Consider the following (x, y) sample data: x 24 19 21 10 22 13 21 23 20 21 y 24 33 31 36 30 36 32 26 26 31 (a) Calculate the variances s2x and s 2 y and the covariance sxy. Show your calculation steps. (b) Compute and interpret the sample correlation coefficient. Show your calculation steps. Question 4 [5 points] Firms are increasingly asking applicants to submit to drug tests. Suppose that drug tests can identify a drug user 98% of the time. However, 1% of the time the test indicates a positive result although the applicant is not a drug user. If 10% of all applicants are drug users, what is the probability that a person who has tested positive for drug use is not really a drug user? [Hint: Define event D = Drug User, event P = Test is positive; Apply the Bayes’ Theorem] Next Page Continued... 3 Part B [30 points] Use the file “BC Covid data.csv” in the “Assignment 1” module on Canvas to complete this part in R. This data set contains the number of daily reported COVID-19 cases in the BC by region, including Fraser, Interior, Northern, Vancouver Coastal, and Vancouver Island, from Jan 1, 2021 to Aug 31, 2021. (a) Read the file and print the first seven and last seven observations. (b) Create a new variable named “BC” to show the number of daily reported cases in the whole BC each day. Print first seven and last seven observations. (c) Calculate the mean and standard deviation for each region and the whole BC. (d) Create two Pie Chart diagrams to show each regions’ percentages in Jan 1 and Aug 31. (e) Create a Line Chart diagram to show each region’s number of daily reported cases during the sample period. [Hint: five lines in one diagram] (f) Calculate the total number of reported cases for each region and the whole BC during the sample period. (g) Create a Bar Chart to show each region’s total number of reported cases during the sample period. (h) Create a Scatter Diagram with Fraser on the vertical axis and Vancouver Coastal on the horizontal axis. (i) Calculate the coefficient of correlation between Fraser and Vancouver Coastal. (j) What can you conclude from the result in (i) and the diagram in (h)? 4 Date,Fraser,Interior,Northern,Vancouver Coastal,Vancouver Island 2021-01-01,340,60,89,89,19 2021-01-02,231,46,35,86,13 2021-01-03,275,84,27,134,16 2021-01-04,290,50,49,114,13 2021-01-05,290,72,33,138,32 2021-01-06,332,93,67,102,12 2021-01-07,305,61,48,103,29 2021-01-08,272,93,38,113,10 2021-01-09,276,46,80,97,30 2021-01-10,212,79,57,82,18 2021-01-11,183,67,46,98,13 2021-01-12,231,81,43,116,32 2021-01-13,242,118,52,93,17 2021-01-14,248,88,41,106,13 2021-01-15,231,125,77,105,34 2021-01-16,209,70,63,101,17 2021-01-17,137,58,34,70,16 2021-01-18,202,58,23,72,24 2021-01-19,217,94,39,136,25 2021-01-20,242,92,72,107,45 2021-01-21,256,73,57,122,13 2021-01-22,199,103,39,115,28 2021-01-23,204,87,42,138,23 2021-01-24,188,52,32,68,19 2021-01-25,139,51,19,107,18 2021-01-26,198,104,35,155,45 2021-01-27,229,55,53,133,30 2021-01-28,216,66,53,157,30 2021-01-29,191,59,36,112,20 2021-01-30,193,96,36,122,31 2021-01-31,132,43,32,58,30 2021-02-01,187,48,29,104,29 2021-02-02,182,61,31,105,23 2021-02-03,226,60,60,97,29 2021-02-04,207,59,70,111,28 2021-02-05,196,85,27,98,38 2021-02-06,235,51,75,98,23 2021-02-07,191,23,34,73,25 2021-02-08,216,46,28,79,24 2021-02-09,247,47,52,103,25 2021-02-10,238,52,41,100,16 2021-02-11,224,40,23,131,15 2021-02-12,232,42,63,97,17 2021-02-13,238,35,47,112,15 2021-02-14,209,12,27,99,13 2021-02-15,196,15,10,81,20 2021-02-16,196,39,15,121,20 2021-02-17,342,18,95,140,21 2021-02-18,289,61,37,125,19 2021-02-19,283,21,49,130,46 2021-02-20,276,19,33,133,30 2021-02-21,278,28,26,97,25 2021-02-22,245,40,54,121,38 2021-02-23,287,33,28,136,35 2021-02-24,262,24,40,137,43 2021-02-25,346,50,31,135,31 2021-02-26,287,30,57,105,37 2021-02-27,299,25,38,104,27 2021-02-28,269,23,22,112,24 2021-03-01,260,15,20,139,23 2021-03-02,298,47,49,135,28 2021-03-03,289,28,43,167,36 2021-03-04,355,37,57,151,26 2021-03-05,280,34,61,144,28 2021-03-06,309,31,34,153,29 2021-03-07,265,18,5,98,13 2021-03-08,266,30,52,141,8 2021-03-09,293,39,31,146,19 2021-03-10,322,24,61,131,42 2021-03-11,369,45,58,153,34 2021-03-12,299,28,44,141,38 2021-03-13,311,28,35,132,19 2021-03-14,262,22,58,121,20 2021-03-15,281,15,25,138,23 2021-03-16,306,30,34,128,13 2021-03-17,303,30,56,175,33 2021-03-18,425,33,67,174,36 2021-03-19,294,23,60,172,28 2021-03-20,356,29,58,151,19 2021-03-21,408,36,30,152,33 2021-03-22,294,34,20,216,19 2021-03-23,377,35,45,237,26 2021-03-24,391,48,62,263,40 2021-03-25,487,48,92,304,57 2021-03-26,430,67,47,279,62 2021-03-27,443,43,34,278,28 2021-03-28,414,52,39,247,50 2021-03-29,383,58,32,266,45 2021-03-30,475,64,52,378,53 2021-03-31,403,60,50,310,57 2021-04-01,480,86,66,365,76 2021-04-02,581,80,40,338,66 2021-04-03,526,71,61,312,57 2021-04-04,477,63,39,285,48 2021-04-05,451,91,33,300,53 2021-04-06,470,100,34,367,65 2021-04-07,669,101,55,423,66 2021-04-08,623,109,67,367,52 2021-04-09,765,99,62,294,80 2021-04-10,617,125,24,251,46 2021-04-11,650,93,36,210,51 2021-04-12,523,86,30,261,40 2021-04-13,544,89,46,274,51 2021-04-14,733,91,57,300,43 2021-04-15,518,93,35,238,45 2021-04-16,667,102,19,269,29 2021-04-17,604,63,37,220,42 2021-04-18,627,68,46,243,35 2021-04-19,421,40,31,226,28 2021-04-20,591,90,23,199,26 2021-04-21,575,74,49,221,41 2021-04-22,653,71,37,227,24 2021-04-23,563,81,32,179,36 2021-04-24,611,80,17,133,31 2021-04-25,484,59,48,156,17 2021-04-26,515,68,12,153,27 2021-04-27,512,69,23,158,35 2021-04-28,585,51,23,182,30 2021-04-29,457,73,26,159,31 2021-04-30,606,63,15,182,26 2021-05-01,490,33,22,123,21 2021-05-02,434,35,22,139,15 2021-05-03,372,36,11,132,17 2021-05-04,410,61,13,126,20 2021-05-05,474,45,29,147,16 2021-05-06,452,41,19,121,17 2021-05-07,430,48,18,98,23 2021-05-08,408,58,25,115,17 2021-05-09,410,39,10,97,13 2021-05-10,300,60,17,127,12 2021-05-11,372,42,6,144,10 2021-05-12,376,61,18,129,19 2021-05-13,309,32,22,109,8 2021-05-14,282,41,15,96,18 2021-05-15,307,52,13,105,8 2021-05-16,301,40,18,69,13 2021-05-17,249,55,8,74,11 2021-05-18,336,67,30,73,17 2021-05-19,226,35,23,79,11 2021-05-20,248,59,32,87,7 2021-05-21,207,43,20,68,16 2021-05-22,210,37,17,66,4 2021-05-23,190,37,8,60,7 2021-05-24,156,30,4,57,5 2021-05-25,126,41,10,68,9 2021-05-26,196,71,18,94,13 2021-05-27,163,62,16,71,3 2021-05-28,130,38,16,56,11 2021-05-29,159,37,13,31,5 2021-05-30,110,38,10,59,1 2021-05-31,100,11,2,41,0 2021-06-01,119,34,4,39,2 2021-06-02,96,33,6,62,2 2021-06-03,100,29,7,39,3 2021-06-04,125,59,7,35,1 2021-06-05,83,30,1,19,5 2021-06-06,87,17,9,18,3 2021-06-07,71,36,7,29,11 2021-06-08,86,32,7,31,13 2021-06-09,75,41,9,20,11 2021-06-10,69,31,10,27,8 2021-06-11,45,29,15,16,4 2021-06-12,66,25,3,19,5 2021-06-13,41,16,0,12,2 2021-06-14,49,23,1,29,4 2021-06-15,56,32,0,16,5 2021-06-16,52,38,4,26,4 2021-06-17,65,24,6,16,4 2021-06-18,37,20,9,23,1 2021-06-19,43,29,2,14,2 2021-06-20,16,14,1,12,2 2021-06-21,15,23,4,11,4 2021-06-22,50,16,0,13,4 2021-06-23,43,11,2,14,4 2021-06-24,34,10,1,14,4 2021-06-25,30,13,0,9,2 2021-06-26,25,14,0,13,0 2021-06-27,19,12,0,7,1 2021-06-28,9,13,1,6,3 2021-06-29,22,12,1,10,1 2021-06-30,18,24,2,4,0 2021-07-01,16,6,0,10,0 2021-07-02,11,14,2,3,1 2021-07-03,13,21,0,3,0 2021-07-04,13,9,0,1,1 2021-07-05,17,13,2,12,0 2021-07-06,13,15,0,15,2 2021-07-07,22,22,1,8,7 2021-07-08,16,16,1,12,6 2021-07-09,16,14,0,16,5 2021-07-10,17,15,0,6,0 2021-07-11,6,10,0,13,0 2021-07-12,15,13,0,13,1 2021-07-13,11,13,1,5,1 2021-07-14,22,18,1,9,6 2021-07-15,14,22,1,8,2 2021-07-16,19,21,0,12,2 2021-07-17,26,27,3,7,1 2021-07-18,24,12,0,11,1 2021-07-19,14,33,2,12,4 2021-07-20,24,32,0,22,1 2021-07-21,34,39,1,19,4 2021-07-22,25,69,4,9,6 2021-07-23,15,46,1,23,5 2021-07-24,12,57