Tuesday, September 29, 2015
Notes for September 29 and October 1
Here are links to posts about how to get average and both standard deviations on the TI-30XIIs.
Here is a link to a post about t-scores and their use in confidence intervals.
Here is a link to the posts about Confidence of Victory.
A list of what the major things that can go wrong with samples.
Too small a sample size. A very small sample will have huge confidence intervals for the values of proportions for categorical variables, which should be a red flag for anyone reading it. But often, people only mention n and the confidence intervals as afterthoughts and many papers have been published and quoted in much larger publication before anyone notices how small the samples were.
Convenience sampling: Our class could be considered a sample of students at Laney, but is it representative? It's convenient for me to get information from the students, but groups of students who would be ignored include:
1. Students whose majors do not require statistics
2. Students who primarily take night classes or distance learning classes
3. Students who primarily take Monday and Wednesday classes
It's not inevitable that excluding these groups would change the proportions of males and females, for example, but a convenience sample is always suspect.
Self-selection. Internet polls on websites might ask you about politics or sports or entertainment. You are under no compulsion to answer the questions and you do so only because the topic interests you. Instead of being convenient for the researcher, self selection polls are convenient for the responders. Almost every such poll will have a disclaimer stating "not a scientific poll" and the numbers aren't a good place to start using statistical methods to find out about the underlying population.
Leading questions. In polling data for opinions, leading questions can create bias.
Under-sampling and oversampling of demographic groups. I have been following polls for several elections now and in nearly every poll, someone will complain that some group is under-represented. Too many conservatives or too many liberals, too many men or too many women, not enough people from outside of major cities or too many from outside major cities, some age group is under or over represented.
No sample is completely perfect, but honest sampling companies do work at using acceptable methods.
Thursday, September 24, 2015
Tuesday, September 15, 2015
Notes for September 15th and 17th
Link to a post about the shared birthday problem.
Link to a post about the Game Show problem, a.k.a. the Monty Hall problem. (many topics discussed, this topic at the bottom of the post.)
Probability of r successes in n dependent trials using sampling without replacement, which is like drawing cards from a deck.
A new use for independent probability: Missing a rare side effect. Let us consider a drug company running tests on a new drug. The tests are designed to check the drug's effectiveness in comparison to other drugs on the market, but they are also designed to see if the subjects experience side effects. If you've ever listened to a drug commerical on TV, you know that some side effects can be quite dangerous. If the probability of a side effect is p and the size of the sample is n, the expected value for the frequency is np.
Example: Let's say the drug company is testing a new drug on 500 subjects. Let's also stipulate there is a fairly rare side effect that we should see in 1% of the population, so p = .01. 500 * .01 = 5, so the expected value of people with the side effect in the sample is 5. Since the expected value is a whole number, this means the most likely number people with the side effect is 5. Let's do the binomial distribution for 4, 5 and 6, rounding to four places after the decimal.
Probability of exactly 4 people out of 500 having the side effect:
500 nCr 4 * .01 ^ 4 * .99 * 496 = .1760 or 17.6%
Probability of exactly 5 people out of 500 having the side effect:
500 nCr 5 * .01 ^ 5 * .99 * 495 = .1764 or 17.64%
Probability of exactly 6 people out of 500 having the side effect:
500 nCr 6 * .01 ^6 * .99 * 494 = .1470 or 14.70%
As we can see, the odds of 5 out of 500 are slightly greater than 4 out of 500, and about 3% more than 6 out of 500. No other outcome is more likely than 5 out of 500.
Here's a different question: what are the chances of 0 out of 500? The reason to ask this is if the trial misses the side effect completely and drug goes to market, the company could face a lot of lawsuits they didn't expect when the side effect starts showing up in the much larger sample of patients taking the drug.
Probability of 0 people out of 500 having the side effect:
500 nCr 0 * .01 ^0 * .99 * 500 = .0066 or 00.66%
(Note: when we have "n choose 0" the answer is always 1, and likewise any non zero number raised to the power of 0 is one. For this problem only, we can just type in the last term (1 - p)^n
Because the sample was large enough and the side effect was not all that rare, the odds of a sample missing this side effect are relatively low. But what if the side effect were rarer, say 1 in 400, which is the decimal .0025. This changes the numbers, of course. The expected value is now 500 * .025 = 1.25, which means the most likely event should be either 1 person or maybe 2 people showing the side effect. Let's look at 0, 1 and 2 people having the side effect.
Probability of exactly 0 people out of 500 having the side effect:
500 nCr 0 * .0025 ^ 0 * .9975 * 500 = .2861 or 28.61%
Probability of exactly 1 person out of 500 having the side effect:
500 nCr 1 * .0025 ^ 1 * .9975 * 499 = .3585 or 35.85%
Probability of exactly 2 people out of 500 having the side effect:
500 nCr 2 * .0025 ^ 2 * .9975 * 498 = .2242 or 22.42%
So the most likely event is to have one person showing the side effect, which will happen about 36% of the time. But the next most likely event is not 2 out of 500 but 0 out of 500, which happens over 28% of the time. 1 in 400 people showing a side effect might not seem that high, but a successful drug can be given to hundreds of thousands of patients, possibly more, and having 1 in every 400 showing a very bad side effect could get very expensive for the company.
Here are some practice problems. Assume the sample size is n = 1000 and we are interested in 0 people showing the side effect. Round the answers to the nearest tenth of a percent.
a) the side effect shows up in 1 in 500 patients
b) the side effect shows up in 1 in 1,000 patients
c) the side effect shows up in 1 in 1,500 patients
Answers in the comments.
Link to a post about the Game Show problem, a.k.a. the Monty Hall problem. (many topics discussed, this topic at the bottom of the post.)
Probability of r successes in n dependent trials using sampling without replacement, which is like drawing cards from a deck.
A new use for independent probability: Missing a rare side effect. Let us consider a drug company running tests on a new drug. The tests are designed to check the drug's effectiveness in comparison to other drugs on the market, but they are also designed to see if the subjects experience side effects. If you've ever listened to a drug commerical on TV, you know that some side effects can be quite dangerous. If the probability of a side effect is p and the size of the sample is n, the expected value for the frequency is np.
Example: Let's say the drug company is testing a new drug on 500 subjects. Let's also stipulate there is a fairly rare side effect that we should see in 1% of the population, so p = .01. 500 * .01 = 5, so the expected value of people with the side effect in the sample is 5. Since the expected value is a whole number, this means the most likely number people with the side effect is 5. Let's do the binomial distribution for 4, 5 and 6, rounding to four places after the decimal.
Probability of exactly 4 people out of 500 having the side effect:
500 nCr 4 * .01 ^ 4 * .99 * 496 = .1760 or 17.6%
Probability of exactly 5 people out of 500 having the side effect:
500 nCr 5 * .01 ^ 5 * .99 * 495 = .1764 or 17.64%
Probability of exactly 6 people out of 500 having the side effect:
500 nCr 6 * .01 ^6 * .99 * 494 = .1470 or 14.70%
As we can see, the odds of 5 out of 500 are slightly greater than 4 out of 500, and about 3% more than 6 out of 500. No other outcome is more likely than 5 out of 500.
Here's a different question: what are the chances of 0 out of 500? The reason to ask this is if the trial misses the side effect completely and drug goes to market, the company could face a lot of lawsuits they didn't expect when the side effect starts showing up in the much larger sample of patients taking the drug.
Probability of 0 people out of 500 having the side effect:
500 nCr 0 * .01 ^0 * .99 * 500 = .0066 or 00.66%
(Note: when we have "n choose 0" the answer is always 1, and likewise any non zero number raised to the power of 0 is one. For this problem only, we can just type in the last term (1 - p)^n
Because the sample was large enough and the side effect was not all that rare, the odds of a sample missing this side effect are relatively low. But what if the side effect were rarer, say 1 in 400, which is the decimal .0025. This changes the numbers, of course. The expected value is now 500 * .025 = 1.25, which means the most likely event should be either 1 person or maybe 2 people showing the side effect. Let's look at 0, 1 and 2 people having the side effect.
Probability of exactly 0 people out of 500 having the side effect:
500 nCr 0 * .0025 ^ 0 * .9975 * 500 = .2861 or 28.61%
Probability of exactly 1 person out of 500 having the side effect:
500 nCr 1 * .0025 ^ 1 * .9975 * 499 = .3585 or 35.85%
Probability of exactly 2 people out of 500 having the side effect:
500 nCr 2 * .0025 ^ 2 * .9975 * 498 = .2242 or 22.42%
So the most likely event is to have one person showing the side effect, which will happen about 36% of the time. But the next most likely event is not 2 out of 500 but 0 out of 500, which happens over 28% of the time. 1 in 400 people showing a side effect might not seem that high, but a successful drug can be given to hundreds of thousands of patients, possibly more, and having 1 in every 400 showing a very bad side effect could get very expensive for the company.
Here are some practice problems. Assume the sample size is n = 1000 and we are interested in 0 people showing the side effect. Round the answers to the nearest tenth of a percent.
a) the side effect shows up in 1 in 500 patients
b) the side effect shows up in 1 in 1,000 patients
c) the side effect shows up in 1 in 1,500 patients
Answers in the comments.
Thursday, September 10, 2015
Notes for the week of September 8 and 10, 2015
Here is a link to a discussion of probabilities from a contingency table.
Here is a link to a discussion of Pascal's triangle and the binomial coefficients, used when looking at the probabilities of events from series of independent trials - like flipping coins or rolling dice - and some dependent trials - like drawing cards from a deck.
Thursday, September 3, 2015
Homework 2 (due September 8)
Last four points of homework and older posts about z-score and lookup tables.
4 points for Homework 2
Here is the list of wins for the 30 NBA wins in the 2014-15 season, including playoff wins. Find the z-score for the highest number of wins and lowest number of wins (note: list not in order) and determine if these two numbers of wins count as outliers by the following method.
If z >= 3, the value is very unusually high.
If z >= 2, the value is unusually high.
If z <= -2, the value is unusually low.
If z <= -3, the value is very unusually low.
List
68 76 56 49 52 43 40 40 38 37 33 32 25 18 17 83 65 62 52 61 58 51 45 45 39 38 30 29 21 16
Average = 43.97
Standard deviation = 16.99
Round z-score to the nearest hundredth.
z(high value) = ______________
Is this any kind of outlier, and of so, which one? ____________
z(low value) = ______________
Is this any kind of outlier, and of so, which one? ____________
===============
If you are looking for more information on look-up tables, follow this link to a previous post.
Here is a link to some practice problems for raw scores to z-scores to proportions and vice versa.
Tuesday, August 25, 2015
Links to all posts about the Homework 1 topics
The five number summary and outliers
Stem and leaf plots
Scales other than percent
Here is one link to several posts about the five number summary and the outlier test involved.
The post at the very end is the explanation, the posts at the top have practice problems.
Here is the link for the posts about stem and leaf plots.
Here is the link for the posts about scales other than percent.
Sunday, May 11, 2014
Notes for May 6th and 8th
Bayesian probability
If a trait is very rare, only a very accurate test gives us useful information. For example, if a trait shows up in only 1 in 10,000 people but the test for the trait has an error rate of 1 in 1,000, we should expect about 10 false positives for every true positive. Here is the completed table for that situation.
________don't___have____row total
test + ____9,999__999______10,998__
test - _9,989,001___1_____9,989,002__
col.___9,999,000_1,000______10,000,000 grand total
In a situation such as this, testing positive twice could give us useful information, as testing positive once has an error rate of about 90.9%. We have to assume the errors are random and not deterministic. For example, if a test for a chemical compound in opium also catches a similar compound found in poppy seed bagels, testing twice won't get rid of the errors. Assuming just random errors here is what we do.
Step 1: The top row of the first contingency table is the column total/grand total row of the second contingency table. What this does is takes the numbers from the people who tested positive the first time and makes them the totals for those who will be tested twice.
________don't___have____row total
test + __________________________
test - __________________________
col._______9,999__999_____10,998 grand total
Step 2: Multiply error rate by have column total to find the number who have that test negative. Round to the nearest whole number. (We didn't have to round before, but now we do.)
999*1/1000 = .999 ~= 1, this means test positive and have is 998.
________don't___have____row total
test + ___________998____________
test - _____________1____________
col._______9,999__999_____10,998 grand total
Step 3: Multiply error rate by don't have column total to find the errors. 9,999*1/1000 = 9.999 ~= 10. That means the test negative in that column is 9,999 - 10 = 9,989.
________don't___have____row total
test + _______10__998____________
test - _____9,989____1____________
col._______9,999__999_____10,998 grand total
Step 4: row totals
________don't___have____row total
test + _______10__998_____1,008___
test - _____9,989____1_____9,990___
col._______9,999__999_____10,998 grand total
Step 5: Find the error rate for testing positive twice. 10/1,008 = .0099... or about 1%.
Of the ten million people tested, we would send letters to 1,008 telling them they tested positive twice. Of those people, ten don't have the trait and are getting false information, but 998 are getting the right information. In the first test, there was someone with the trait who tested negative, and the same is true in the second test, so there are two people with the trait who did not get two positive test results. While this isn't a perfect situation, it's much better than the over 90% error rate we got for positive tests the first time through.
Relative frequency charts and ogives
Relative frequencies are also known as proportions and can sometimes be considered probabilities. If the proportions correspond to ordered categories, a line chart can be a clear way to present the data.
Here is the data for the Los Angeles Angels scoring by inning, given as percentages. The first number is the percentage scored in that inning and the second number in brackets is the percentage of entire runs scored in a game up through that inning.
1st: 13.5% [13.5%]
2nd: 10.0% [23.5%]
3rd: 10.4% [33.9%]
4th: 11.0% [45.0%]
5th: 11.7% [56.6%]
6th: 11.7% [68.3%]
7th: 8.8% [77.1%]
8th: 12.3% [89.4%]
9th: 9.4% [98.8%]
extra innings: 1.2% [100.0%]
The Angels are fairly consistent, except for the big bump in the first inning and the drop-off in the 7th. Unsurprisingly, they score very few extra inning runs, though some teams like the Giants score four times as many.
In a line graph, we have two possible options. The first is the line in blue, which shows the production inning by inning. The red line shows the cumulative numbers and that graph is called the ogive, pronounced "oh-jive". If they were completely consistent, the ogive would be a completely straight line, but instead we see the slight bends in the red line when run production increased and decreases per inning.
If a trait is very rare, only a very accurate test gives us useful information. For example, if a trait shows up in only 1 in 10,000 people but the test for the trait has an error rate of 1 in 1,000, we should expect about 10 false positives for every true positive. Here is the completed table for that situation.
________don't___have____row total
test + ____9,999__999______10,998__
test - _9,989,001___1_____9,989,002__
col.___9,999,000_1,000______10,000,000 grand total
In a situation such as this, testing positive twice could give us useful information, as testing positive once has an error rate of about 90.9%. We have to assume the errors are random and not deterministic. For example, if a test for a chemical compound in opium also catches a similar compound found in poppy seed bagels, testing twice won't get rid of the errors. Assuming just random errors here is what we do.
Step 1: The top row of the first contingency table is the column total/grand total row of the second contingency table. What this does is takes the numbers from the people who tested positive the first time and makes them the totals for those who will be tested twice.
________don't___have____row total
test + __________________________
test - __________________________
col._______9,999__999_____10,998 grand total
Step 2: Multiply error rate by have column total to find the number who have that test negative. Round to the nearest whole number. (We didn't have to round before, but now we do.)
999*1/1000 = .999 ~= 1, this means test positive and have is 998.
________don't___have____row total
test + ___________998____________
test - _____________1____________
col._______9,999__999_____10,998 grand total
Step 3: Multiply error rate by don't have column total to find the errors. 9,999*1/1000 = 9.999 ~= 10. That means the test negative in that column is 9,999 - 10 = 9,989.
________don't___have____row total
test + _______10__998____________
test - _____9,989____1____________
col._______9,999__999_____10,998 grand total
Step 4: row totals
________don't___have____row total
test + _______10__998_____1,008___
test - _____9,989____1_____9,990___
col._______9,999__999_____10,998 grand total
Step 5: Find the error rate for testing positive twice. 10/1,008 = .0099... or about 1%.
Of the ten million people tested, we would send letters to 1,008 telling them they tested positive twice. Of those people, ten don't have the trait and are getting false information, but 998 are getting the right information. In the first test, there was someone with the trait who tested negative, and the same is true in the second test, so there are two people with the trait who did not get two positive test results. While this isn't a perfect situation, it's much better than the over 90% error rate we got for positive tests the first time through.
Relative frequency charts and ogives
Relative frequencies are also known as proportions and can sometimes be considered probabilities. If the proportions correspond to ordered categories, a line chart can be a clear way to present the data.
Here is the data for the Los Angeles Angels scoring by inning, given as percentages. The first number is the percentage scored in that inning and the second number in brackets is the percentage of entire runs scored in a game up through that inning.
1st: 13.5% [13.5%]
2nd: 10.0% [23.5%]
3rd: 10.4% [33.9%]
4th: 11.0% [45.0%]
5th: 11.7% [56.6%]
6th: 11.7% [68.3%]
7th: 8.8% [77.1%]
8th: 12.3% [89.4%]
9th: 9.4% [98.8%]
extra innings: 1.2% [100.0%]
The Angels are fairly consistent, except for the big bump in the first inning and the drop-off in the 7th. Unsurprisingly, they score very few extra inning runs, though some teams like the Giants score four times as many.
In a line graph, we have two possible options. The first is the line in blue, which shows the production inning by inning. The red line shows the cumulative numbers and that graph is called the ogive, pronounced "oh-jive". If they were completely consistent, the ogive would be a completely straight line, but instead we see the slight bends in the red line when run production increased and decreases per inning.
Subscribe to:
Posts (Atom)

