Heights of adults. (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.
library(openintro)
data(bdims)
par(mar=c(3.7,2.5,0.5,0.5), las=1, mgp=c(2.5,0.7,0), cex.lab = 1.5)
histPlot(bdims$hgt, col = COL[1], xlab = "Height", ylab = "")
head(bdims$hgt)
## [1] 174.0 175.3 193.5 186.5 187.2 181.5
mean_h <- mean(bdims$hgt)
mean_h
## [1] 171.1438
median_h <- median((bdims$hgt))
median_h
## [1] 170.3
sd_h <- sd(bdims$hgt)
sd_h
## [1] 9.407205
IQR(bdims$hgt, na.rm = T)
## [1] 14
pos <- mean_h + 2*sd_h
neg <- mean_h - 2*sd_h
pos
## [1] 189.9582
neg
## [1] 152.3294
pos2 <- mean_h + 1*sd_h
neg2 <- mean_h - 1*sd_h
pos2
## [1] 180.551
neg2
## [1] 161.7366
hist(bdims$hgt, probability = TRUE)
x <- 140:200
y <- dnorm(x = x, mean = mean_h, sd = sd_h)
lines(x = x, y = y, col = "blue")
I would expect the mean and the standard deviation of the new sample to be similar to the ones given above, because the bars are distributed the curve steadly and the normal plot shows regularity between , nothing unusual.
x <- sd_h/sqrt(nrow(bdims))
x
## [1] 0.4177887
std error is 0.417
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.
library(openintro)
data(data(thanksgiving_spend))
par(mar=c(3.7,2.2,0.5,0.5), las=1, mgp=c(2.5,0.7,0), cex.lab = 1.5)
histPlot(thanksgiving_spend$spending, col = COL[1], xlab = "Spending", ylab = "")
True. We are 95% confident that the stated range contains the mean for the population at large and also for the sampled population.
False. The confidence interval is not affected by this. The data is skewed beyond what looks to be within normal parameters required for our confidence interval.
False. This is not what the confidence interval shows.
True
TRue
True
True
Gifted children, Part I. Researchers investigating characteristics of gifted children col- lected 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 dis- tribution of the ages (in months) at which these children first counted to 10 successfully. Also provided are some sample statistics.
library(openintro)
data(gifted)
par(mar=c(3.7,2.2,0.5,0.5), las=1, mgp=c(2.5,0.7,0), cex.lab = 1.5)
histPlot(gifted$count, col = COL[1],
xlab = "Age child first counted to 10 (in months)", ylab = "",
axes = FALSE)
axis(1)
axis(2, at = c(0,3,6))
Sample observations are independent because it is a random sample and number of children, 36, is very likely to be less than 10 percent of the population.
HN: mean = 32 HA: mean < 32
mean <- 30.69
sd <- 4.31
n <- 36
se <- sd/sqrt(n)
Z_s <- (mean-32)/se
pvalue <- pnorm(Z_s)
pvalue
## [1] 0.0341013
We reject the null hypothesis since there is sufficient evidence to reject HNULL in favor of HAlternative.
l <- 30.69 - (qnorm(0.95) * (4.31 / sqrt(36)))
u <- 30.69 + (qnorm(0.95) * (4.31 / sqrt(36)))
c(l, u)
## [1] 29.50845 31.87155
While the hypothesis test rejected the null hypothesis, the average of 32 months is also not within the confidence interval. It means that results from the hypothesis test and the confidence interval agree.
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.
library(openintro)
data(gifted)
par(mar=c(3.7,2.2,0.5,0.5), las=1, mgp=c(2.5,0.7,0), cex.lab = 1.5)
histPlot(gifted$motheriq, col = COL[1],
xlab = "Mother's IQ", ylab = "", axes = FALSE)
axis(1)
axis(2, at = c(0,4,8,12))
Z_s <- (118.2 - 100) / (6.5 / sqrt(36))
Z_s
## [1] 16.8
pvalue <- 2 * (pnorm(Z_s, 0, 1, lower.tail = FALSE))
pvalue
## [1] 2.44044e-63
l <- 118.2 - (qnorm(0.95) * (6.5 / sqrt(36)))
u <- 118.2 + (qnorm(0.95) * (6.5 / sqrt(36)))
c(l,u)
## [1] 116.4181 119.9819
Yes, the interval is well above the mean of HNULL. The analyses agree.
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.
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.
z <- (10500 - 9000) / 1000
p <- 1 - pnorm(z)
p
## [1] 0.0668072
sd<-1000
mean<-9000
n<-15
s <- sd / sqrt(n)
z_b <-(10500-mean)/s
pro <- pnorm(z_b, mean, sd)
pro
## [1] 1.189897e-19
ns <- seq(mean - (4 * sd), mean + (4 * sd), length=15)
rs<- seq(mean - (4 * s), mean + (4 * s), length=15)
hn <- dnorm(ns,mean,sd)
hr<- dnorm(rs,mean,s)
plot(ns, hn, type="l",col="green",
xlab="Population vs Sampling",
ylab="",main="Distribution", ylim=c(0,0.002))
lines(rs, hr, col="orange")
A normal distribution is required to use the Z-score, also the sample size needs to be greater use the z-score.
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.
The p value should decrease as the sample size increases. The standard error decreases, the z-score increases, and therefore the p value will decrease.