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

STATS 331, Assignment 2

Semester 2, 2022

Instructions

● All answers should be written with corresponding question numbers.

● Working must be shown.

● If any of above is unsatisfied, a penalty will be applied.

● Exact numbers (full digits) are used for calculation and report Values in 3 decimal places.

1. A call center surveyed on numbers of calls during the peak time, 2pm-   5pm. In the last week (Mon-Sun), numbers of calls during the peak time   for each day were 41, 40, 35, 31, 38, 45, 27 and, these daily records are   assumed to be independent. Let λ be the mean number of calls during the   peak time. Here λ is a discrete random variable and seq(1,70,length=1e3) generates 1000 possible values for λ . A log-uniform prior is assigned.

(a) Write R-code computing the posterior distribution for λ . [2]

(b) Find the expected value and the 0.9 credible interval for a mean number of calls during the peak time given the data. [3]

(c) The staf allocation system is optimized for 23-38 calls during the peak time.  If there are more than 38 calls, it is understafed and if there are less than 23 calls, it is overstafed. How likely a call center is not overstafed and understafed on the next day given 7 days of record? [2]

(d) Given the record, what will be the 0.5 quantile of number of calls during the peak time on the next day? [2]

Hint:  The theoretical 0.5 quantile is not available and you need to find the closest integer to the 0.5 quantile.

2. A university wants to know what proportion of students are regular bike riders so that they can install an appropriate number of bike racks.  Let N be a number of students participated this survey and n, a number of regular bike riders. The survey result for four classes follows.

Class

1      2      3      4

N

n

61    86    37    40

19    22    13    12

Let θ be a probability that a random student is a regular bike rider. The R- code seq(0 .01,1,length=100) generates 100 possible values for θ . The university suspects that 0.65 ≤ θ ≤ 0.85 with the probability of 0.7. This prior belief partitions 100 possible values into either group of more or less likely values.  We assume that θ values within the group are uniformly distributed. For example, θ values in [0.65,0.85] are equally likely.

(a) Write R-code computing the posterior distribution for θ and plot the posterior probability mass. [3]

(b) Find the posterior mean and standard deviation. [3]

(c) One more survey is conducted for the new class of 73 students. Given the existing survey result, find the expected value and the variance for a number of regular bike riders in the new class. [2]

(d) You are told that some surveys were conducted sequentially.   A survey conductor went to a class and surveyed one by one until n regular bike riders were found.  N is a number of participated students till n regular riders are found. For this scenario, a negative Binomial distribution is appropriate and it assigns a probability at n with a regular bike rider probability of θ .  dnbinom computes a negative Binomial PMF and the three input arguments are n, N – n and θ as it is shown below.

dnbinom(N-n,n,theta)

The same prior is assigned for θ .  Compare this new model to the Binomial model using the Bayes Factor. [4]

3. A university wants to know what proportion of students are regular bike riders so that they can install an appropriate number of bike racks. The spreadsheet bike .csv contains the result of survey conducted in 20 classes. Here N is a class size and n is a number of regular bike riders in

the class. The below code reads the spreadsheet.

bike=read .csv(’bike .csv’)

Let θ be a probability that a student is a regular bike rider. The university thinks that a Beta distribution Beta(30, 10) is a sensible distribution for θ based on their previous study.

(a) Find a posterior distribution for θ given the survey result. [2] (b) Find the posterior mean and the 0.9 credible interval for θ . [2]

(c) Describe how the degrees of belief about θ is updated from the prior belief by information in the survey result. [2]

(d) One more survey is conducted for the new class of 73.  Given the existing survey result, find the expected value and the variance for a number of regular bike riders in the new class. [3]