The University of SydneySchool of Mathematics and StatisticsComputer Exercise Week 8STAT3023: Statistical Inference Semester 2, 2019Web Page: https://sydney.edu.au/science/maths/STAT3023Lecturers: Rachel Wang and Michael StewartSuppose X1, . . . , Xn are iid N(µ, σ2). In the week 7 Tutorial it was noted that the statistic Y =∑ni=1(Xi − X¯)2 (where X¯ = 1n∑ni=1Xi) is sufficient for σ2 and has a σ2χ2n−1 distribution. ConsidertestingH0 : σ2 = 1 against H1 : σ2 6= 1. (1)1. One possible level-α test is the “equal-tailed” test based on Y , where we reject for Y < a or Y > bwhereP0 {Y < a} = P0 {Y > b} = α2.(a) Taking α = 0.05 and n = 5, find appropriate values a and b.(b) Defining sig.sq=(50:150)/100 plot the power of the test against sig.sq. Add a horizontaldotted line to indicate the level.2. In Tutorial week 7 we also found that the UMPU test rejects for small values of the statisticT = (n− 1) log Y − Y .If the test is to have level α, we reject for Y ≤ c or Y ≥ d whereP0(Y ≤ c) + P0(Y ≥ d) = α (2)and(n− 1) log(c)− c = (n− 1) log(d)− d . (3)(a) Write a function of the formfn=function(c,alpha,n) {…}which• computes the appropriate d so that c and d satisfy (2);• then computes and outputs the difference between the left-hand side and right-handside in (3).(b) Use the R function uniroot() to find the root (in c) of the equation fn(c,0.05,5)=0. Inyour code you will need a command along the lines ofuniroot(fn,lower=0,upper=…,alpha=0.05,n=5)Consult the week 7 exercise for some hints as to how to choose the upper=…. When youhave worked out the right commands, wrap it all in a function of the formnorm.var.umpu=function(alpha,n) {…}which returns a list containing elements $c and $d.Copyright c© 2019 The University of Sydney 1(c) Recreate your plot from part (b) of the previous question and add to it the power functionof the UMPU test.3. The GLRT test of (1) above uses the statisticLn = `(X¯, Y/n;X)− `(X¯, 1;X) = −n2log(Yn)− n2+Y2which is an increasing function of Y − n log Y (as opposed to the UMPU which rejects for largeY − (n− 1) log Y ). Adapt your code for the previous question to compute the power of the exactGLRT, recreate your earlier plot and add a power curve to it so it shows all 3 power curves on the1 graph. Add an informative heading, legend, etc.. Comment on the main differences between the3 tests.4. As a final step, recreate your last plot but use an extended range for the parameter: sig.sq=(1:400)/100.2