Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please use R language C] 13 14 15' 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32

Please use R language

image text in transcribed
C] 13 14 15' 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 @ lab03_inference.Rmd* ,: @ 05_inference.rmd x = D A (1 El \"5"Q so'Knit - {3. ea 9 3 EN"... 43,- *If you collaborated with anyone, you must include \"Collaborated with: FIRSTNAME LASTNAME" at the top of your lab!* ## Part 1. t-test (10 points) Write a function 'my_t.test()' that performs a one sample t-test in R. Your code should not use the 't.test' function in it. Don't forget to follow the function style guide! Your function should have the following parameters: * 'x' a numeric vector of data. * 'alternative' a character string specifying the alternative hypothesis. This should only accept '"two.sided\"', '"less"', or '"greater"'. Otherwise, your function should throw an informative error. * 'mu' a number indicating the null hypothesis value of the mean. Your function should return a 'list' with elements: 'test_stat': the numeric test statistic. 'df': the degrees of freedom. 'alternative': the value of the parameter 'alternative'. 'p_val': the numeric p-value. **** You should use the following information: * To get the standard error in a one sample t-test, take the standard deviation ('sd()') of your input and divide it by the square root of the sample size. * Use 'pt()' to get the area under the curve for a t-distribution. Be sure to use the parameter 'lower.tail'! * The degrees of freedom for this test ('df' within 'pt()') is equal to the sample size - 1. * The pvalue should never be less than 0 or greater than 1. (*Hint: Be careful about whether you use 'lower.tail = TRUE' or 'lower.tail = FALSE' in the twosided test! One safe option is to use 'lower.tail = FALSE' with the absolute value ('absC)') of your test statistic.*)

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

Measure And Integral

Authors: Martin Brokate, Götz Kersting

1st Edition

331915365X, 9783319153650

More Books

Students also viewed these Mathematics questions