Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
A project on confidence intervals and hypothesis tests using r. The project involves creating an r function, z.test, which performs a z-test for the mean and generates a confidence interval. Three populations are considered: normal distribution with mean 10 and standard deviation 2, binomial distribution with n = 5 and p = 0.1, and quebec birth data. The project includes performing hypothesis tests and calculating confidence intervals for each population, as well as comparing observed significance levels to nominal significance levels.
Typology: Study Guides, Projects, Research
1 / 1
Confidence Intervals and Tests of hypotheses
Problem 1. We begin this project by writing an R function which we call z.test that inputs a set of data and performs a z test for the mean and produces a two-sided confidence interval. Specifically, z.test will have the following input and output.
Input: A vector (call it x ) containing the data A string variable (call it alternative ) that inputs the form of the alternative: ‘g’ for , ‘l’ for , and ‘t’ for two sided tests with. [Default: alternative = ‘t’ ] A variable (call it mu ) containing the value of in the null hypothesis. [Default: mu = 0 ] A variable (call it conf.level ) that gives the confidence level of the confidence interval desired. [Default: conf.level = 0.95 ]
Output: Statistic : the value of the z statistic Pvalue: the p-value for the test Lconf: the lower limit of the confidence interval Uconf: the upper limit of the confidence interval A normal quantile plot of the data
Consider the following three (population) sources from which we take samples:
Problem 2: For each of the above populations perform the following steps: a) Obtain the population mean, call it. b) Take a sample of size 5 from the population and test the hypothesis versus. Repeat this 5000 times, and determine the proportion of times that you reject the null hypothesis at 5% level (this is called the observed significance level). Compare this value to the 5% level (called the nominal significance level) and comment, c) Repeat (b) using 10% significance level. d) Compute s 99% confidence interval for and determine what proportion of the intervals contain the population mean Comment on the proportions that you obtain.
Problem 3: Repeat problem 2 with the modification that in part (b), take a sample of size 50 rather than a sample of size 5.