Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Provide statistical solution step by step and Rcode 2. Suppose Yu ~ N(p1, of) and Vaj ~ N(#2, ;),i - 1, ..., m,j - 1,...,
Provide statistical solution step by step and Rcode
2. Suppose Yu ~ N(p1, of) and Vaj ~ N(#2, ;),i - 1, ..., m,j - 1,..., n2, where Yu's and Yay's are all independent. In Homework 6, we wrote a function to test Ho : /1 - /42 and construct a 100(1 -a)% confidence interval for # - pg assuming the variances of and of were unknown but equal. In this problem, we modify the function to incorporate the case where the variances are unknown and unequal. Define your notation clearly and answer the following questions. For parts (a) and (b), assume of and of are unknown and unequal. (a) Write the test statistic and its null distribution. Specify the null distribution degrees of freedom using the Satterthwaite approximation discussed in class. (b) Construct a 100(1 - a)% confidence interval for # - #2. You do not need to consider a one-sided confidence bound. (c) Modify the two-sample t-test function you wrote in Homework 6 so that the function works whether or not the unknown variances are equal. No credit will be given if any built-in function related to the t-test is used. You may use the four Base R functions for a given distribution (e.g., d/p/q/rt()). Your function should perform as follows. i. The function takes the arguments: yl, y2, alt = "two-sided", lev = 0.95, where the equality indicates the default value. . The arguments y1 and y2 are the two samples. . The argument alt is the alternative hypothesis whose two other possible values are "less" and "greater". . The argument lev is the confidence level 1 - o. ii. The function first conducts a variance test using the function you wrote in Problem 1. If the variance test p-value is greater than 0.05, the function assumes of - o?; otherwise, it assumes of / o?. Based on that assumption, the function tests Ho : #1 - #2 and constructs a 100(1 - a)% confidence interval for /4 - /2- ili. The function returns an R list containing the test name, test statistic, p-value, and confidence interval, where the test name takes one of the following two values A. "two-sample t-test with unknown but equal variances"; B. "two-sample t-test with unknown and unequal variances". iv. The function does not return the variance test result. (d) Use your new f-test function above to repeat part (g) of Problem 6 in Homework 6. Are the results same as before? Why or why notStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started