Weekend batch
Avijeet is a Senior Research Analyst at Simplilearn. Passionate about Data Analytics, Machine Learning, and Deep Learning, Avijeet is also interested in politics, cricket, and football.
Free eBook: Top Programming Languages For A Data Scientist
Normality Test in Minitab: Minitab with Statistics
Machine Learning Career Guide: A Playbook to Becoming a Machine Learning Engineer
Chapter 15 hypothesis testing: two sample tests, 15.1 two sample t test.
We can also use the t test command to conduct a hypothesis test on data where we have samples from two populations. To introduce this lets consider an example from sports analytics. In particular, let us consider the NBA draft and the value of a lottery pick in the draft. Teams which do make the playoffs are entered into a lottery to determine the order of the top picks in the draft for the following year. These top 14 picks are called lottery picks.
Using historical data we might want to investigate the value of a lottery pick against those players who were selected outside the lottery.
We can now make a boxplot comparing the career scoring averages of the lottery picks between these two pick levels.
From this boxplot we notice that the lottery picks tend to have a higher point per game (PPG) average. However, we certainly see many exceptions to this rule. We can also compute the averages of the PTS column for these two groups:
Lottery.Pick | ppg | NumberPlayers |
---|---|---|
Lottery | 11.236927 | 371 |
Not Lottery | 7.107924 | 366 |
This table once again demonstrates that the lottery picks tend to average more points. However, we might like to test this trend to see if have sufficient evidence to conclude this trend is real (this could also just be a function of sampling error).
Our first technique for looking for a difference between our two categories is linear regression with a categorical explanatory variable. We fit a regression model of the form: \[PTS=\beta \delta_{\text{ not lottery}}+\alpha\] Where \(\delta_{\text{ not lottery}}\) is equal to one if the draft pick fell outside the lottery and zero otherwise.
To see if this relationship is real we can form a confidence interval for the coefficients.
From this we can see that Lottery picks to tend to average more point per game over their careers. The magnitude of this effect is somewhere between 3.5 and 4.7 points more for lottery picks.
For this we can use the two-sample t-test to compare the means of these two distinct populations.
Here the alternative hypothesis is that the lottery players score more points \[H_A: \mu_L > \mu_{NL}\] thus the null hypothesis is \[H_0: \mu_L \leq \mu_{NL}.\] We can now perform the test in R using the same t.test command as before.
Notice that I used the magic tilde ~ to split the PTS column into the lottery/non-lottery pick subdivisions. I could also do this manually and get the same answer:
The very small p-value here indicates that the population mean of the lottery picks is truly greater than the population mean of the non-lottery picks.
The 95% confidence interval also tells us that this difference is rather large (at least 3.85 points).
Conditions for using a two-sample t test:
These are roughly the same as the conditions for using a one sample t test, although we now need to assume that BOTH samples satisfy the conditions.
Must be looking for a difference in the population means (averages)
30 or greater samples in both groups (CLT)
At this point you would probably like to know why we would ever want to do a two sample t test instead of a linear regression?
My answer is that a two sample t test is more robust against a difference in variance between the two groups. Recall, that one of the assumptions of simple linear regression is that the variance of the residuals does not depend on the explanatory variable(s). By default R does a type of t test which does not assume equal variance between the two groups. This is the one advantage of using the t test command.
Lets say we are trying to estimate the effect of a new training regiment on the 40 yard dash times for soccer players. Before implementing the training regime we measure the 40 yard dash times of the 30 players. First lets read this data set into R.
First, we can compare the mean times before and after the training:
Also we could make a side by side boxplot for the soccer players times before and after the training
We could do a simple t test to examine whether mean of the players times after the training regime is implemented decrease (on average). Here we have the alternative hypothesis that \(H_a: \mu_b-\mu_a>0\) and thus the null hypothesis that \(H_0: \mu_b-\mu_a \leq 0\) . Using the two sample t test format in R we have:
Here we cannot reject the null hypothesis that the training had no effect on the players sprinting performance. However, we haven’t used all of the information available to us in this scenario. The t test we have just run doesn’t know that we recorded the before and after for the same players more than once. As far as R knows the before and after times could be entirely different players as if we are comparing the results between one team which received the training and one who didn’t. Therefore, R has to be pretty conservative in its predictions. The differences between the two groups could be due to many reasons other than the training regime implemented. Maybe the second set of players just started off being a little bit faster, etc.
The data we collected is actually more powerful because we know the performance of the same players before and after the test. This greatly reduces the number of variables which need to be accounted for in our statistical test. Luckily, we can easily let R know that our data points are paired .
Setting the paired keyword to true lets R know that the two columns should be paired together during the test. We can see that running the a paired t test gives us a much smaller p value. Moreover, we can now safely conclude that the new training regiment is effective in at least modestly reducing the 40 yard dash times of the soccer players.
This is our first example of the huge subject of experimental design which is the study of methods which can be used to create data sets which have more power to distinguish differences between groups. Where possible it is better to collect data for the same subjects under two conditions as this will allow for more powerful statistical analysis of the data (i.e a paired t test instead of a normal t test).
Whenever the assumptions are met for a paired t test, you will be expected to perform a paired t test in this class.
We can also use statistical hypothesis testing to compare the proportion between two samples. For example, we might conduct a survey of 100 smokers and 50 non-smokers to see whether they buy organic foods. If we find that 30/100 smokers buy organic and only 11/50 non-smokers buy organic then can we conclude that more smokers buy organic foods that smokers? \(H_a: p_s > p_n\) and \(H_0: p_s \leq p_n\) .
In this case we don’t have sufficient evidence to conclude that a larger fraction of smokers buy organic foods. It is common when analyzing survey data to want to compare proportions between populations.
The key assumptions when performing a two-sample proportion test are that we have at least 5 successes and 5 failures in BOTH samples.
For this example we are going to use a data from a study on the risk factors associated with giving birth to a low-weight baby (sometimes defined as less than 2,500 grams). This data set is another one which is build into R . To load this data for analysis type:
You can view all a description of the data by typing ?birthwt once it is loaded. To begin we could look at the raw birth weight of mothers who were smokers versus non-smokers. We can do some EDA on this data using a boxplot:
From the boxplot we can see that the median birth weight of babies whose mothers smoked was smaller. We can test the data for a difference in the means using a t.test command.
Notice we can use the ~ shorthand to split the data into those two groups faster than filtering. Here we get a small p value meaning we have sufficient evidence to reject the null hypothesis that the mean weight of babies of women who smoked is greater than or equal to those of non-smokers.
Within this data set we also have a column low which classifies whether the babies birth weight is considered low using the medical criterion (birth weight less than 2,500 grams):
We can see that smoking gives a higher fraction of low-weight births. However, this could just be due to sampling error so let’s run a proportion test to find out.
Once again we find we have sufficient evidence to reject the null hypothesis that smoking does not increase the risk of a low birth weight.
15.4.1 concept questions.
For each of the scenarios below form the null and alternative hypothesis.
For the below question work out the number of errors in the data set.
Load the drug_use data set from the fivethirtyeight package. Run a hypothesis test to determine if a larger proportion of 22-23 year olds are using marijuana then 24-25 year olds. Interpret your results statistically and practically.
Import the data set Cavaliers_Home_Away_2016 . Form a hypothesis on whether being home or away for the game had an effect on the proportion of games won by the Cavaliers during the 2016-2017 season, test this hypothesis using a hypothesis test.
Load the data set animal_sleep and compare the average total sleep time (sleep_total column) between carnivores and herbivores (using the vore column) to divide the between the two categories. To begin make a boxplot to compare the total sleep time between these two categories. Do we have sufficient evidence to conclude the average total sleep time differs between these groups?
Load the HR_Employee_Attrition data set. We wish to investigate whether the daily rate (pay) has anything to do with whether a employee has quit (the attrition column is “Yes”). To begin make a boxplot of the DailyRate column split into these Attrition categories. Use the boxplot to help form the null hypothesis for your test and decide on an alternative hypothesis. Conduct a statistical hypothesis test to determine if we have sufficient evidence to conclude that those employees who quit tended to be paid less. Report and interpret the p value for your test.
Load the BirdCaptureData data set. Perform a hypothesis test to determine if the proportion of orange-crowned warblers (SpeciesCode==OCWA) caught at the station is truly less than the proportion of Yellow Warblers (SpeciesCode==YWAR). Report your p value and interpret the results statistically and practically.
(All of Statistics Problem) In 1861, 10 essays appeared in the New Orleans Daily Crescent. They were signed “Quintus Curtius Snodgrass” and one hypothesis is that these essays were written by Mark Twain. One way to look for similarity between writing styles is to compare the proportion of three letter words found in two works. For 8 Mark Twain essays we have:
From 10 Snodgrass essays we have that:
Consider the analysis of the kidiq data set again.
IMAGES
COMMENTS
Registered nurses earned an average annual salary of $69,110. For that same year, a survey was conducted of 41 California registered nurses to determine if the annual salary is higher than $69,110 for California nurses. The sample average was $71,121 with a sample standard deviation of $7,489. Conduct a hypothesis test.
In this post I have put together the practice problems (from my academics study notes) to explain how in practical Hypothesis Testing works. This post is written mostly for the learners who want to deep dive into the statistics for data science. Focus will be on problem solving. For concepts please refer my previous posts on testing of hypothesis.
Hypothesis Testing. We have previously focused on estimating population means and variances with sample means and variances. This is termed inferential statistics. Another type of inference procedure is called hypothesis testing. We will be using hypothesis testing to evaluate questions where we need a yes/no answer.
Unit 7 - Hypothesis Testing Practice Problems SOLUTIONS . 1. An independent testing agency was hired prior to the November 2010 election to study ... sol_testing.doc : PubHlth 540 - Fall 2011 Introductory Biostatistics Page 7 of 9 . C. alculations. p-value = Pr t 2.46 [score. ≥] where degrees of freedom = 9 =.018. If you want to use a ...
Use the following information to answer the next 15 exercises: Indicate if the hypothesis test is for. independent group means, population standard deviations, and/or variances known. independent group means, population standard deviations, and/or variances unknown. matched or paired samples. single mean.
If the biologist set her significance level \(\alpha\) at 0.05 and used the critical value approach to conduct her hypothesis test, she would reject the null hypothesis if her test statistic t* were less than -1.6939 (determined using statistical software or a t-table):s-3-3. Since the biologist's test statistic, t* = -4.60, is less than -1.6939, the biologist rejects the null hypothesis.
Set up the Hypothesis Test: Since the problem is about a mean, this is a test of a single population mean. Set the null and alternative hypothesis: In this case there is an implied challenge or claim. This is that the goggles will reduce the swimming time. The effect of this is to set the hypothesis as a one-tailed test.
This statistics video tutorial provides practice problems on hypothesis testing. It explains how to tell if you should accept or reject the null hypothesis....
Present the findings in your results and discussion section. Though the specific details might vary, the procedure you will use when testing a hypothesis will always follow some version of these steps. Table of contents. Step 1: State your null and alternate hypothesis. Step 2: Collect data. Step 3: Perform a statistical test.
The treatment group's mean is 58.70, compared to the control group's mean of 48.12. The mean difference is 10.67 points. Use the test's p-value and significance level to determine whether this difference is likely a product of random fluctuation in the sample or a genuine population effect.. Because the p-value (0.000) is less than the standard significance level of 0.05, the results are ...
If this problem persists, tell us. Our mission is to provide a free, world-class education to anyone, anywhere. Khan Academy is a 501(c)(3) nonprofit organization. Donate or volunteer today! Site Navigation. About. News; Impact; Our team; Our interns; Our content specialists; Our leadership; Our supporters; Our contributors; Our finances;
Study with Quizlet and memorize flashcards containing terms like A method for testing a claim or hypothesis about a parameter in a population, using data measured in a sample, is called: A) the central limit theorem B) hypothesis testing C) significance testing D) both b and c, The _____ hypothesis is a statement about a population parameter, such as the population mean, that is assumed to be ...
In statistics, we use hypothesis tests to determine whether some claim about a population parameter is true or not. Whenever we perform a hypothesis test, we always write a null hypothesis and an alternative hypothesis, which take the following forms: ... Check out the following example problems to gain a better understanding of one-tailed ...
Two-Tailed Hypothesis Tests: 3 Example Problems. In statistics, we use hypothesis tests to determine whether some claim about a population parameter is true or not. Whenever we perform a hypothesis test, we always write a null hypothesis and an alternative hypothesis, which take the following forms: H0 (Null Hypothesis): Population parameter ...
This statistics video tutorial provides practice problems on hypothesis testing. It explains how to tell if you should Reject the Null Hypothesis or Fail to...
View Solution to Question 1. Question 2. A professor wants to know if her introductory statistics class has a good grasp of basic math. Six students are chosen at random from the class and given a math proficiency test. The professor wants the class to be able to score above 70 on the test. The six students get the following scores:62, 92, 75 ...
9 Hypothesis Tests. (Ch 9.1-9.3, 9.5-9.9) Statistical hypothesis: a claim about the value of a parameter or population characteristic. Examples: H: μ = 75 cents, where μ is the true population average of daily per-student candy+soda expenses in US high schools. H: p < .10, where p is the population proportion of defective helmets for a given ...
a. Test the null hypothesis H0: =950 against a two-sided alternative hypothesis. Use a .05 level of significance. The two critical values of the test are 927.38 and 972.62. We reject the null hypothesis because the test statistic is in the rejection region on the right hand side of the distribution. b.
Khan Academy
Statistical Inference : Hypothesis Testing: Solved Example Problems. Example 8.14. An auto company decided to introduce a new six cylinder car whose mean petrol consumption is claimed to be lower than that of the existing auto engine. It was found that the mean petrol consumption for the 50 cars was 10 km per litre with a standard deviation of ...
To put this company's claim to the test, create a null and alternate hypothesis. H0 (Null Hypothesis): Average = 95%. Alternative Hypothesis (H1): The average is less than 95%. Another straightforward example to understand this concept is determining whether or not a coin is fair and balanced.
15.1.2 Two Sample t test approach. For this we can use the two-sample t-test to compare the means of these two distinct populations. Here the alternative hypothesis is that the lottery players score more points H A: μL > μN L H A: μ L > μ N L thus the null hypothesis is H 0: μL ≤ μN L. H 0: μ L ≤ μ N L. We can now perform the test ...
Statistics notes with practice problems and answers (visual aids) hypothesis testing new kind of inference mars, inc. claimed in 2008 that the proportion of. ... Hypothesis and Hypothesis Test o Hypothesis In statistics, a hypothesis is a claim or a statement about a parameter. Hypotheses are always considered in pairs. (More about this later ...
A one-tailed test checks whether there is a relationship or effect in a single direction. For example, after running an ad, you can use a one-tailed test to check for a positive impact, i.e. an increase in sales. This is a right-tailed test. A two-tailed test examines the possibility of a relationship in both directions.