Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Functions Assignment (15 points) Due: 11/17/16 at 11:59 pm Submission: Please submit the .R file of your code and answers on Blackboard. Use comments (#)

Functions Assignment (15 points) Due: 11/17/16 at 11:59 pm Submission: Please submit the .R file of your code and answers on Blackboard. Use comments (#) to state the p-value found in (1) and (2). 1) Write a function called \"t_test\" that outputs the p-value of a right-sided one sample t-test. The only two inputs should be a vector of data and the hypothesized mu (0) that you are testing in your hypothesis. Again, these should be your hypothesizes: H0: = 0 Ha: > 0 In your code, run your function and find the p-value of the following vector of data, tested at 0=30: c(5,34,56,2,4,56,4,2,54) Hint: You can use loops, but they are not necessary to create this function. 2) Write a function called \"t_test_2\" that outputs the p-value of a two-sided one sample t_test. Again, the only two inputs should be a vector of data and the hypothesized mu (0) that you are testing in your hypothesis. These should be your hypothesizes: H0: = 0 Ha: 0 In your code, run your function and find the p-value of the following vector of data, tested at 0=30: c(5,34,56,2,4,56,4,2,54) Hint: Think about the differences of how the p-value (area of the two tails) is calculated when our test statistic is positive vs. negative. Homework 6 (35 points) Due 11/17/16 11:59 pm Load the dataset \"hw6.csv\" into R. This dataset contains patients' heart rate before and after drug treatment. Gender (m/f), side effect (1=yes, 0=no), and age (young, middle, elderly) are also provided. This assignment requires completion by hand and by R. For the by hand part, please show all work (you can use the function \"pt\" or \"pnorm\" if you don't want to look up the critical values in t or z tables). Show your R code used (or submit history file). Show all work for full credit. Paired t test (by hand and R) (10 pts) Researchers want to conclude that this drug lowers these patients heart rate. The average difference for this sample (after - before) is -3.33 and the standard deviation (not standard error!) for this difference is 4.84. The sample size (n) is 30. Complete this paired t test by hand. Set up hypotheses, calculate the test statistic, find the pvalue, and draw a conclusion about this problem. Calculate a 2 sided 95% confidence interval (by hand) for this average difference. Hint: use the R function \"qt\" to calculate the critical value t* or use the t-tables provided in the course documents on Blackboard. Complete the paired t test, and confidence interval using R. Compare your answers to your hand calculations above. Note: R may use different formulas so your answers may not be exactly the same. 2-sample t test (by hand and R) (10 pts) Researchers now want to test whether or not males and females have different heart rates before drug treatment. The average female heart rate before drug treatment in the sample is 75.2 and the average male heart rate is 67.8. The standard deviation for females before heart rate is 12.9 and for males it is 14.3. There are 15 females and 15 males. Complete this 2 sample t-test by hand. Set up hypotheses, calculate the test statistic, find the pvalue, and draw a conclusion about this problem. Calculate a 2-sided 95% confidence interval (by hand) for this average difference. Hint: use the R function \"qt\" to calculate the critical value t* or use the t-tables provided in the course documents on Blackboard. Conduct this two sample t-test using R and compare your results to your by hand calculations. ANOVA (R only) (7.5 pts) Conduct the ANOVA analysis to test for differences in mean heart rate before drug treatment among the three different age groups. Write down the hypotheses, report the p-value for this test from R, and draw a conclusion about your hypothesis. 1-sample proportion (By hand only) (7.5 pts) Researchers want to test the hypothesis that less than 40% of patients will get side effects from this drug. You can find out the proportion of side effects in our sample using the \"table\" function. Complete the one sample proportion test by hand. Set up hypotheses, calculate the test statistic, find the p-value, and draw a conclusion about this problem. Compute the 2-sided 95% confidence interval by hand. Be careful about the differences in formulas for confidence intervals and hypothesis tests (see slide 42 in Lecture 8). qattachments_c9e5217e23254eebfe252a74343a1049be74e52b Before After Gender side_effects Age 60 54 m 1 young 65 65 m 0 young 70 54 f 1 young 83 77 m 0 young 64 68 f 0 young 53 49 f 0 young 55 52 m 1 young 90 87 f 1 young 86 88 m 0 young 74 79 f 1 young 76 70 f 0 young 78 72 f 0 middle 65 65 m 1 middle 45 46 m 0 middle 76 75 f 0 middle 65 60 m 1 middle 76 72 f 0 middle 87 88 f 1 middle 57 50 m 0 middle 42 42 m 0 middle 76 75 m 0 elderly 87 80 f 1 elderly 90 92 m 0 elderly 100 90 f 0 elderly 76 78 m 1 elderly 76 70 m 0 elderly 54 55 f 0 elderly 65 55 f 0 elderly 78 70 f 0 elderly 76 67 m 0 elderly Page 1

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

College Algebra

Authors: Robert F Blitzer

7th Edition

013449492X, 9780134453262

More Books

Students also viewed these Mathematics questions