Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

a. Write a new version of typeI.tester called typeI.mean. The new function should be able to simulate the Type I error rate for tests of

a. Write a new version of typeI.tester called typeI.mean. The new function should be able to simulate the Type I error rate for tests of a single mean in any direction (in other words, oneor two-sided). The new function should take an additional argument, test, which takes a character string "less", "greater", or "two.sided" depending on the type of desired test. You can achieve this by modifying typeI.tester as follows: Instead of calculating and storing the p-values directly in the for loop, simply store the test statistic. When the loop is complete, set up stacked if-else statements that cater to each of the three types of test, calculating the p-value as appropriate. For the two-sided test, remember that the p-value is defined as twice the area more extreme than the null. Computationally, this means you must use the upper-tail area if the test statistic is positive and the lower-tail area otherwise. If this area is less than half of (since it is subsequently multiplied by 2 in a real hypothesis test), then a rejection of the null should be flagged. If the value of test is not one of the three possibilities, the function should throw an appropriate error using stop. i. Experiment with your function using the first example setting in the text with 0 = 0, = 1, n = 40, and = 0.05. Call typeI.mean three times, using each of the three possible options for test. You should find that all simulated results sit close to 0.05. ii. Repeat (i) using the second example setting in the text with 0 = 4, = 0.3, n = 60, and = 0.01. Again, you should find that all simulated results sit close to the value of . b. Modify typeII.tester in the same way as you did typeI.tester; call the new function typeII.mean. Simulate the Type II error rates for the following hypothesis tests. As per the text, assume A, , , and n denote the true mean, standard deviation of raw observations, significance level, and sample size, respectively. i. H0 : = 3.2; HA : , 3.2 with A = 3.3, = 0.1, = 0.05, and n = 25. ii. H0 : = 8994; HA : < 8994 with A = 5600, = 3888, = 0.01, and n = 9. iii. H0 : = 0.44; HA : > 0.44 with A = 0.4, = 2.4, = 0.05, and n = 68.

The code has to be done in R languge. Thank you

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine M Ricardo, Susan D Urban

3rd Edition

1284056945, 9781284056945

More Books

Students also viewed these Databases questions

Question

How do modern Dashboards differ from earlier implementations?

Answered: 1 week ago