Question: Please use the statistical software R in order to answer the following questions. When doing so, please use R-notebooks to segment your code and output

Please use the statistical software R in order to answer the following questions. When doing so, please use R-notebooks to segment your code and output according to the prob- lem. Further please leave ample comments in your R code explaining what you are doing.

2.1 Setting up functions for simulations (20 points) Suppose that we have fixed values of , , and n. We wish to test our null hypothesis of the form: population mean = 0. Write a R function test statistics() that takes for an input a positive integer B (the number of replicates) and returns B (number of) test statistics for population mean obtained by using rnorm() based on the values , , and n. Write three functions p values upper, p values lower, and p values twosided, which input a list of test statistics and output a list of P-values for the respective alternative hy- pothesis. Guidelines: 1. Use the replicate() function along with the rnorm() to create B number of sam- ples drawn from a normal distribution with mean , standard deviation and n observations. 2. Use the appropriate function from the ones you wrote before to compute (B number of) test statistics to be used in hypotheses tests related to whether the population mean is 0for each sample that was generated. 3. Use the sapply() function when writing the functions p values upper, p values lower, and p values twosided. The sapply() will allow you to apply a function written to take in a single value to entries in a vector. This eliminates the need to iterate manually through entries in a vector. We will let B = 10000.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!