Question

How to do the following in R code: Write your own function my.t.test which can perform...

How to do the following in R code:

Write your own function my.t.test which can perform both one and two sample t-test. For two sample t-test, it can perform both equal and unequal variance version. Your my.t.test will take the following argument (1) the vector x, (2) optional vector y if it is two sample t-test, (3) type of alternative hypothesis alternative, (4) the mean or mean difference that you are testing mu. Your function my.t.test should contain a routine to check for equal variance assumption using the F test. If the p-value of the F test is ≤ 0.05, then it will perform two sample t-test with unequal variance assumption. Your function my.t.test should return the test statistic stat, degrees of freedom df and p-value p.value.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:

Default is 0.

Default is FALSE.

# m1, m2: the sample means

# s1, s2: the sample standard deviations

Add a comment
Know the answer?
Add Answer to:
How to do the following in R code: Write your own function my.t.test which can perform...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • How do I write the results of this t-test out in a statsically way ? $120,000...

    How do I write the results of this t-test out in a statsically way ? $120,000 $75,000 t-Test: Two-Sample Assuming Unequal Variances Mean College Degree 131233.3333 1795633333 30 High School Degree (Only) 60966.66667 582171264.4 Variance Observations Hypothesized Mean Difference df 46 t Stat P(T<=t) one-tail t Critical one-tail PIT<=t) two-tail t Critical two-tail 7.892632799 2.1299E-10 1.678660414 4.2598E-10 2.012895599

  • Please help me, I wasn't sure which test to use so I did both of them on excel. Please let me know which is correct and answer A-C. I will give the answer a thumbs up if you can get back to me asa...

    Please help me, I wasn't sure which test to use so I did both of them on excel. Please let me know which is correct and answer A-C. I will give the answer a thumbs up if you can get back to me asap. The physicians also believe that people who are obese are more likely to die earlier than those who are not. Again use the data in the Framingham sample to test this theory by comparing the mean...

  • e. Using Data Analysis in Excel, you obtain the following table. Make a conclusion. Your conclusion...

    e. Using Data Analysis in Excel, you obtain the following table. Make a conclusion. Your conclusion should have two parts. 1) Do you reject or fail to reject the null hypothesis based on your decision rule? 2) Answer the question (Is there a difference in the average number of patients being seen in the emergency room between 2015 and 2016?) based on your decision. t-Test: Two-Sample Assuming Unequal Variances 2016 2015 Mean 5693.75 5155.583333 Variance 59352.205 63610.44697 Observations 12 12...

  • Suppose you want to determine whether there is a significant difference in mean test scores for...

    Suppose you want to determine whether there is a significant difference in mean test scores for females and males. The test is out of 600 points. Using the following hypotheses: Ho: U1 - U2 = 0 HA: U1 - U2 (not equal) 0 And alpha of 0.05 you obtain the following results t-test Two-sample assuming unequal variances Females   Males Mean 525 487 Variance 3530.8 2677.818182 Observations 16 12 Hypothesized Mean Difference 0 df 25 t stat 1.803753 P (T<=t) one...

  • t-Test: Two-Sample Assuming Equal Variances Variable 1 Variable 2 Mean 12.89795918 17.66666667 Variance 161.2185374 567.8266667 Observations...

    t-Test: Two-Sample Assuming Equal Variances Variable 1 Variable 2 Mean 12.89795918 17.66666667 Variance 161.2185374 567.8266667 Observations 49 51 Pooled Variance 368.6716646 Hypothesized Mean Difference 0 Df 98 t Stat -1.241549191 P(T<=t) one-tail 0.108683158 t Critical one-tail 1.660551217 P(T<=t) two-tail 0.217366316 t Critical two-tail 1.984467455 Is there a significant difference between the two sample means?  If you answer, “yes,” what is your reasoning?  If you answer, “no,” what is your reasoning? Please state the conclusion, or your interpretation of the results in terms...

  • F-Test Two-Sample for Variances Subject ID Height Mean 9.9 68.85 Variance 39.04210526 35.0815789 Observations 20 20...

    F-Test Two-Sample for Variances Subject ID Height Mean 9.9 68.85 Variance 39.04210526 35.0815789 Observations 20 20 df 19 19 F 1.112894757 P(F<=f) one-tail 0.40903666 F Critical one-tail 2.168251601 Based on your results: If your f-value is < critical value, choose t-test assuming equal variances If your f-value is > critical value, choose t-test assuming unequal variances

  • A researcher wanted to see if students will learn more effectively with a constant background sound,...

    A researcher wanted to see if students will learn more effectively with a constant background sound, as opposed to an unpredictable sound or no sound at all. She randomly divides twenty-four students into three groups of eight. All students study a passage of text for 30 minutes. Those in group 1 study with background sound at a constant volume in the background. Those in group 2 study with noise that changes volume periodically. Those in group 3 study with no...

  • Please use this information to answer the next questions An investigation was launched to address the...

    Please use this information to answer the next questions An investigation was launched to address the effectiveness of an antibacterial soup in reducing operating room contamination. The new soup was fosted in a sample of eight operating rooms in the greater Seattle res Data was collected on the level of operating room contamination her values indicate greater contaminar on in these light operating rooms before the new soap was used and after the new soap was used Output are based...

  • A movie theater company wants to see if there is a difference in the average price...

    A movie theater company wants to see if there is a difference in the average price of movie tickets in Memphis and Minneapolis. They sample 25 ticket stubs from Memphis and 20 from Minneapolis. Test the claim using a 10% level of significance. Assume the population variances are unequal and that movie ticket prices are normally distributed. Give answer to at least 4 decimal places. Minneapolis Memphis 8 9 10 12 9 13 10 11 10 10 10 11 9...

  • A consumer agency has compiled grocery bills (in dollars) from random samples of supermarket customers in...

    A consumer agency has compiled grocery bills (in dollars) from random samples of supermarket customers in Florida and Georgia. Assuming the population variances are not equal, use the Excel output below to identify whether each of the following conclusions is correct. You must make a selection for each option. Click once to place a check mark for correct answers and click twice to place an "x" for the wrong answers. At the 2.5% significance level, conclude that the average grocery...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT