Question: Write your own function in R to perform a t-test (it may not use t.test). The t-test should be unpaired and you may assume that

Write your own function in R to perform a t-test (it may not use t.test). The t-test should be unpaired and

you may assume that the samples have equal variance. This function must have the following properties:

a. It should be able to do either a one-sample of two sample t-test and should be able to tell which is required

by whether the user gives one or two samples. hint: You can do this using an if-then structure and the

missing() function.

b. The user should be able to specify a choice of alternative hypotheses by giving arguments two-sided,

less, or greater. If no such alternative is given, then the default should be two-sided.

c. The user should be able to specify a parameter mu indicating the true value of the mean or difference in

means under the null hypothesis. If unspecified, the default should be mu=0.

d. The result should be a list with the value of the t-statistic and the p-value with a names attribute specifying

which is which.

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 Programming Questions!