(7.7, p. 260) Researchers studying anthropometry collected body girth measurements and skeletal diameter measurements, as well as age, weight, height and gender, for 507 physically active individuals. The histogram below shows the sample distribution of heights in centimeters.
What is the point estimate for the average height of active individuals? What about the median?
summary(bdims$hgt)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 147.2 163.8 170.3 171.1 177.8 198.1
mean(bdims$hgt)
## [1] 171.1438
median(bdims$hgt)
## [1] 170.3
sd(bdims$hgt)
## [1] 9.407205
IQR(bdims$hgt)
## [1] 14
The point estimate for the average is the mean, which is 171.14 cm. The median is 170.3 cm.
The standard deviation is 9.407 cm and the IQR is 14 cm.
# 95th percentile is 1.96 standard deviations above the mean
big <- 1.96*9.407205
tallupper <- big + 171.1438
talllower <- 171.1438 - big
tallupper - 180
## [1] 9.581922
155 - talllower
## [1] 2.294322
The person who is 180 cm tall is tall, but not unusually tall. The person who is 155 cm tall is short, but also not unusually short. Both the taller person and the shorter person fall within the 95% of individuals. While both are outside the third and first quartiles respectively, they still fall within the 95% rule.
I would not expect the standard deviation or the mean to be the same. There will almost certainly be a different distribution in the new sample, even if only a few heights are different. The only way to receive identical results would be to take an identical sample.
We use standard error to quantify the variability of the point estimates.
#sigma/sqrt(n)
sd(bdims$hgt)/sqrt(507)
## [1] 0.4177887
Thanksgiving spending, Part I. The 2009 holiday retail season, which kicked off on November 27, 2009 (the day after Thanksgiving), had been marked by somewhat lower self-reported consumer spending than was seen during the comparable period in 2008. To get an estimate of consumer spending, 436 randomly sampled American adults were surveyed. Daily consumer spending for the six-day period after Thanksgiving, spanning the Black Friday weekend and Cyber Monday, averaged $84.71. A 95% confidence interval based on this sample is ($80.31, $89.11). Determine whether the following statements are true or false, and explain your reasoning.
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 5.719 49.177 75.792 84.707 112.255 282.803
False, the 95% confidence interval is only valid for providing an interval for the entire population, not individual samples. Additionally, from the histogram, it is easy to see that in this sample, plenty of people spent more than $100, showing a significant right skew.
False, the confidence interval still offers value even with the right skew. Statement a is invalid, but the confidence interval can still be valid.
False, the confidence interval does not apply to samples.
True, by the definition of confidence intervals.
True, from the z-score, 95% confidence is +-1.96 deviations from the mean, while 90% confidence is only +-1.645 deviations from the mean.
False, because the margin of error involves a denominator of the square root of the sample size, we need a sample 3^2 times larger, or 9 times larger.
Using z = 1.96 for 95% confidence interval:
std_err <- sd(thanksgiving_spend$spending)/(sqrt(436))
margin <- 1.96*std_err
margin
## [1] 4.405038
True, the margin of error is approximately 4.4.
Gifted children, Part I. Researchers investigating characteristics of gifted children collected data from schools in a large city on a random sample of thirty-six children who were identified as gifted children soon after they reached the age of four. The following histogram shows the distribution of the ages (in months) at which these children first counted to 10 successfully. Also provided are some sample statistics.
The conditions for inference are satisfied because there is not a significant skew in either direction. The sample size is possibly large and random enough to establish conditions for independence in the distribution. The independence and lack of skewness satisfy the conditions for inference.
The null hypothesis is 32 in this case, and the alternative hypothesis would be the mean. The mean is 30.69 months, which is less than 32. The null hypothesis can be rejected here and the test shows that there is convincing evidence that gifted children count to ten successfully before the general average.
summary(gifted$count)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 21.00 28.00 31.00 30.69 34.25 39.00
mean(gifted$count)
## [1] 30.69444
null <- 32
n <- 36
min <- 21
avg <- 30.69
max <- 39
stdev <- sd(gifted$count)
siglvl <- 0.10
stderr <- stdev/sqrt(n)
Z <- (avg - null)/(stderr)
p <- pnorm(Z)
p < (siglvl)/2
## [1] TRUE
Because p is less than the significance level, it can be concluded that the null hypothesis is rejected and that the data does provide convincing evidence that the average age of gifted students’ first count to ten is below 32. Whether this is two tailed or one tailed, the null hypothesis can be rejected in both cases.
The p-value would be found on the left side of the normal curve and it is less than 0.05, which would be the cutoff for the critical region. The p-value falls within the critical region, which leads to a rejection of the null hypothesis.
z for 90% confidence is 1.645 The 90% confidence interval for average age at which gifted children first count to ten successfully is 29.045 - 32.335.
low <- avg - (1.645*stderr)
up <- avg + (1.645*stderr)
interval <- c(low, up)
interval
## [1] 29.507 31.873
The hypothesis test and the confidence interval agree because the mean from the hypothesis test falls within the confidence interval, which is below 32.
Gifted children, Part II. Exercise above describes a study on gifted children. In this study, along with variables on the children, the researchers also collected data on the mother’s and father’s IQ of the 36 randomly sampled gifted children. The histogram below shows the distribution of mother’s IQ. Also provided are some sample statistics.
avgiq <- 100
n <- 36
min <- min(gifted$motheriq)
max <- max(gifted$motheriq)
avg <- mean(gifted$motheriq)
stdev <- sd(gifted$motheriq)
siglvl <- 0.10
stderr <- stdev/sqrt(n)
z <- (avgiq - avg)/stderr
p <- 1 - pnorm(z)
1 - p < siglvl/2
## [1] TRUE
The p-value is measurably 1, which is found above the significance level, so the null hypothesis is rejected. Note: We are seeking a value that is on the right tail of the distribution, so for the p value we need 1 - pnorm(z) The data provides significant evidence that the average IQ of mothers of gifted children is higher than that of the mothers of average children.
z for 90% confidence is 1.645 The 90% confidence interval is 116.3832 - 119.9501.
low <- avg - (1.645*stderr)
up <- avg + (1.645*stderr)
interval <- c(low, up)
interval
## [1] 116.3832 119.9501
The results agree for the same reasons as the previous exercise. The mean falls within the confidence interval, which is wholly above the mean for parents of average students.
CLT. Define the term “sampling distribution” of the mean, and describe how the shape, center, and spread of the sampling distribution of the mean change as sample size increases.
Sampling Distribution: A distribution of samples that are more or less representative of the population. The sampling distribution of the mean would be largely based on the mean of the population. As sample size increases, the shape will become more normalized. The center will be centered around the mean. The spread will decrease as the distribution becomes more normal.
CFLBs. A manufacturer of compact fluorescent light bulbs advertises that the distribution of the lifespans of these light bulbs is nearly normal with a mean of 9,000 hours and a standard deviation of 1,000 hours.
mean <- 9000
stdev <- 1000
The probability that a random bulb lasts more than 10,500 hours is shown below to be 0.0668, or 6.68%
library(DATA606)
## Loading required package: shiny
## Loading required package: ggplot2
## Loading required package: markdown
##
## Welcome to CUNY DATA606 Statistics and Probability for Data Analytics
## This package is designed to support this course. The text book used
## is OpenIntro Statistics, 4th Edition. You can read this by typing
## vignette('os4') or visit www.OpenIntro.org.
##
## The getLabs() function will return a list of the labs available.
##
## The demo(package='DATA606') will list the demos that are available.
##
## Attaching package: 'DATA606'
## The following objects are masked from 'package:openintro':
##
## calc_streak, present, qqnormsim
## The following object is masked from 'package:utils':
##
## demo
z <- (10500 - mean)/stdev
p <- 1 - pnorm(z)
DATA606::normal_plot(mean = 0, sd = 1, cv = c(z, 4))
The distribution is mostly normal. In different attempts, there is occassionally a right or left skew, but the distribution is typically near normal.
library(ggplot2)
n <- 15
stderr <- stdev/sqrt(n)
mean
## [1] 9000
stderr
## [1] 258.1989
sampleraw <- rnorm(n, mean = mean, sd = stdev)
sample <- data.frame(sampleraw)
colnames(sample) <- c('x')
#hist(sample)
sample
ggplot(sample)+
geom_histogram( aes(x=x), binwidth = 325, col = "green", fill = "blue")+
ggtitle("Histogram for Sample")+
xlab("Lifespan")+
theme(plot.title = element_text(hjust = 0.5))
ggplot(sample, aes(x = x))+
geom_histogram(aes(y=..density..), col = "green", fill = "blue", breaks = seq(7000, 11000, by = 325))+
ggtitle("Histogram for Sample")+
xlab("Lifespan")+
geom_density(alpha=.2, fill = 'red')+
theme(plot.title = element_text(hjust = 0.5))
Using standard error for the sample as the standard deviation to get the probability of the mean being above 10,500 and not the probability of an individual measurement being above 10,500.
We want the probability of z being greater than the goal mean minus the original mean, divided by the original standard error. Assuming the distribution is normal:
stderr <- sd(sampleraw)/sqrt(n)
z <- (10500 - 9000)/(1000/(sqrt(n)))
1 - pnorm(z)
## [1] 3.133452e-09
The probability is measurably 0.
The population distribution is so cleanly normal that I genuinely became excited. You can see how the sample distribution appears somewhat normal, but when you plot the population of 100,000 bulbs, the distribution is nearly perfectly normal.
populationraw <- rnorm(100000, mean = 9000, sd = 1000)
population <- data.frame(populationraw)
colnames(population) <- c('x')
population$x <- unlist(population$x)
ggplot(population, aes(x = x))+
geom_histogram(aes(y=..density..), col = "pink", fill = "red", breaks = seq(6000, 12000, by = 325))+
ggtitle("Histogram for Population")+
xlab("Lifespan")+
geom_density(alpha=.2, fill = 'red')+
theme(plot.title = element_text(hjust = 0.5))
ggplot(sample, aes(x = x))+
geom_histogram(aes(y=..density..), col = "green", fill = "blue", breaks = seq(6000, 12000, by = 325))+
ggtitle("Histogram for Sample")+
xlab("Lifespan")+
geom_density(alpha=.2, fill = 'red')+
theme(plot.title = element_text(hjust = 0.5))
Parts A and C only work because normal distribution is assumed. The only way to gather the probability for a skewed distribution would be to test it empirically. We could not estimate the probabilities with a skewed distribution.
Same observation, different sample size. Suppose you conduct a hypothesis test based on a sample where the sample size is n = 50, and arrive at a p-value of 0.08. You then refer back to your notes and discover that you made a careless mistake, the sample size should have been n = 500. Will your p-value increase, decrease, or stay the same? Explain.
p-value is inversely related with n. As n increases, the p-value will decrease.