Practice: 4.3, 4.13, 4.23, 4.25, 4.39, 4.47 Graded: 4.4, 4.14, 4.24, 4.26, 4.34, 4.40, 4.48

4.4 Heights of adults. 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.

  1. What is the point estimate for the average height of active individuals? What about the median?
adult.mean <- 171.1
adult.median <- 170.3
paste0("Point estimate for the average height of active individuals: ", adult.mean)
## [1] "Point estimate for the average height of active individuals: 171.1"
paste0("Point estimate for the mean height of active individuals: ", adult.median)
## [1] "Point estimate for the mean height of active individuals: 170.3"
  1. What is the point estimate for the standard deviation of the heights of active individuals? What about the IQR?
adult.sd <- 9.4
adult.IQR <- 177.8 - 163.8 # Q3 - Q1
paste0("SD: ", adult.sd)
## [1] "SD: 9.4"
paste0("IQR: ", adult.IQR)
## [1] "IQR: 14"
  1. Is a person who is 1m 80cm (180 cm) tall considered unusually tall? And is a person who is 1m 55cm (155cm) considered unusually short? Explain your reasoning.
# To be considered unusually tall would be if the adult is greater than 2 standard deviations above the norm.
# In this case, if the Z value is greater than 2

Z.adult <- (180 - adult.mean)/(adult.sd)
paste0("The Z score is: ", round(Z.adult, 2), ". This is less than 2, and considered not unusual.")
## [1] "The Z score is: 0.95. This is less than 2, and considered not unusual."
# Similarly, an adult would be considered unusually short if the Z value is less than -2
Z.adult2 <- (155 - adult.mean)/(adult.sd)
paste0("The Z score is: ", round(Z.adult2, 2), ". This is greater than -2, and considered not unusual.")
## [1] "The Z score is: -1.71. This is greater than -2, and considered not unusual."
  1. The researchers take another random sample of physically active individuals. Would you expect the mean and the standard deviation of this new sample to be the ones given above? Explain your reasoning.
# I do not expect the mean and standard deviation to be exactly the same, as this was a random sampling. I suspect that they would be similar but not exact, as it is unlikely that the same exact 507 values would be picked again.
  1. The sample means obtained are point estimates for the mean height of all active individuals, if the sample of individuals is equivalent to a simple random sample. What measure do we use to quantify the variability of such an estimate (Hint: recall that SDx ̄ = pn )? Compute this quantity using the data from the original sample under the condition that the data are a simple random sample.
# Given that we do not know the true population standard deviation, we use the sample standard deviation in lieu of the population standard deviation as it is likely close to the true value. We will need to calculate the standard error to measure the variability for all the point estimates for all the mean heights we sample.

SE <- adult.sd/sqrt(507)
paste0("Standard error: ", round(SE,2))
## [1] "Standard error: 0.42"

4.14 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 dollars. 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.

  1. We are 95% confident that the average spending of these 436 American adults is between $80.31 and $89.11.
# False. We know 100% for certain that the average spending costs of these 436 American adults is between $80.31 and $89.11. The point estimate is always in the confidence interval.
  1. This confidence interval is not valid since the distribution of spending in the sample is right skewed.
# False. The N = 436, and the right skew can be overlooked.
  1. 95% of random samples have a sample mean between $80.31 and $89.11.
# False. The confidence interval is not about a sample mean.
  1. We are 95% confident that the average spending of all American adults is between $80.31 and $89.11.
# True. This is the definition of a 95% Confidence Interval.
  1. A 90% confidence interval would be narrower than the 95% confidence interval since we don’t need to be as sure about our estimate.
# True. If we do not need to be as sure, then we can use a lower number for confidence interval. The range would also be smaller vs. a 95% confidence interval.
  1. In order to decrease the margin of error of a 95% confidence interval to a third of what it is now, we would need to use a sample 3 times larger.
# False. In the calculation of the standard error, we divide the standard deviation by the square root of the sample size. To cut the SE (or margin of error) to a third, we would need to sample 3^2 = 9 times the number of people in the initial sample.
  1. The margin of error is 4.4.
# Margin of Error = Z * standard of error
# If the 95% confidence intervals = 89.11 - 80.31 = 8.80
# Divide this number (8.80) by two = 4.40
# Therefore, the mean is 84.71 and the margin of error is 4.40.
# Therefore, this is true.

4.24 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 dis- tribution of the ages (in months) at which these children first counted to 10 successfully. Also provided are some sample statistics.

  1. Are conditions for inference satisfied?
# 1. Given that this is random children from a large city, the sample is likely independent.
# 2. N is > 30, which satisfies the minimum N needed.
# 3. There doesn't appear to be an obvious skew to the histogram.
# So yes, the conditions for inference are satisfied.
  1. Suppose you read online that children first count to 10 successfully when they are 32 months old, on average. Perform a hypothesis test to evaluate if these data provide convincing evidence that the average age at which gifted children fist count to 10 successfully is less than the general average of 32 months. Use a significance level of 0.10.
# Will assign variables with data from the histogram and its legend.
giftedchild.n <- 36
giftedchild.min <- 21
giftedchild.mean <- 30.69
giftedchild.sd <- 4.31
giftedchild.max <- 39

# Null hypothesis (H0) is that 32 months is average for an average developing child.
# Alternate hypothesis (HA) states that the average does NOT equal 32 months.
# This is a two-tailed T test, with the alpha value = 0.10, as designated in the question.

# Calculate the Standard of Error.
child.SOE <- 4.31/sqrt(giftedchild.n)
child.Z <- (giftedchild.mean - 32)/(child.SOE)
p.value <- pnorm(child.Z, mean = 0, sd = 1) * 2 # To make it two-tailed
paste0("The two tailed T test p-value is: ", round(p.value,3), ", which is < 0.10, therefore, we reject the null hypothesis.")
## [1] "The two tailed T test p-value is: 0.068, which is < 0.10, therefore, we reject the null hypothesis."
  1. Interpret the p-value in context of the hypothesis test and the data.
paste0("With the p value < 0.10, this suggests that the gifted children count to 10 on average statistically faster than the normal child.")
## [1] "With the p value < 0.10, this suggests that the gifted children count to 10 on average statistically faster than the normal child."
  1. Calculate a 90% confidence interval for the average age at which gifted children first count to 10 successfully.
child.lowerCI90 <- giftedchild.mean - 1.29 * child.SOE
child.upperCI90 <- giftedchild.mean + 1.29 * child.SOE
paste0("The lower CI90 to upper CI90 ranges from: ", child.lowerCI90, " to ", child.upperCI90)
## [1] "The lower CI90 to upper CI90 ranges from: 29.76335 to 31.61665"
  1. Do your results from the hypothesis test and the confidence interval agree? Explain.
# They do agree. The upper limit in the 90% confidence intervals is 31.62, whereas, the average child who can count to 10 was 32 months. With a confidence intervals of 90%, this is equivalent of alpha = 0.10. 

4.26 Gifted children, Part II. Exercise 4.24 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.

  1. Perform a hypothesis test to evaluate if these data provide convincing evidence that the average IQ of mothers of gifted children is different than the average IQ for the population at large, which is 100. Use a significance level of 0.10.
# Assign values from the histogram
n <- 36
child.gift.min <- 101
child.gift.mean <- 118.2
child.gift.sd <- 6.5
child.gift.max <- 131

# The null hypothesis is that the average of IQ mothers of gifted children = average IQ of the population at large.
# The alternate hypothesis: average of IQ mothers of gifted children != average IQ of the population at large.
# We will use the two tailed p value test to determine if there is any statistical difference
# Again, given that we do not have the information about the population at large, we will need to use the information i.e. standard deviation from the sample as assumptions when we calculate for the standard of error.
# This can occur because the histogram appears near normal distribution and the N size is greater than 30.
# We will make the assumption that the mothers are independent of each other (and they are not family members, etc.)

child.gift.SOE <- (child.gift.sd)/sqrt(n)
child.gift.Z <- (child.gift.mean - 100)/(child.gift.SOE)
paste("The Z score is: ", child.gift.Z)
## [1] "The Z score is:  16.8"
child.gift.twotailP <- (1 - pnorm(child.gift.Z, mean = 0, sd = 1)) * 2
paste("The Two Tail P value is: ", child.gift.twotailP)
## [1] "The Two Tail P value is:  0"
# With a P value of essentially zero. This is obviously less than alpha = .10, we can reject the null hypothesis and accept the alternate hypothesis.
  1. Calculate a 90% confidence interval for the average IQ of mothers of gifted children.
# To make a 90% confidence interval, looking at the Z table. Z should equal 1.29
CI.upper90 <- child.gift.mean + 1.29 * child.gift.SOE
CI.lower90 <- child.gift.mean - 1.29 * child.gift.SOE
paste("Upper 90% CI: ", CI.upper90)
## [1] "Upper 90% CI:  119.5975"
paste("Lower 90% CI: ", CI.lower90)
## [1] "Lower 90% CI:  116.8025"
  1. Do your results from the hypothesis test and the confidence interval agree? Explain.
# They do agree. The P value was = 0, which is less than alpha = 0.10. With the confidence interval, these values are no where near 100, thus agreeing with our alternate hypothesis.

4.34 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 of the mean is the probability distribution obtained through a large number of samples drawn from a speciric population. In this case, the means of all the samples are used to create the sample distribution.
# The shape is typically unimodal with no skew (for a normal distribution). As the number N of samples increases, the more normal the distribution appears. Also with a higher N sample, given that the formula standard of error is (standard deviation of population) / (sqrt of N). The larger the N, the smaller the spread or variance. 

4.40 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.

  1. What is the probability that a randomly chosen light bulb lasts more than 10,500 hours?
#Assign values
bulb.mean <- 9000
bulb.sd <- 1000
LastingLonger <- pnorm(10500, mean = bulb.mean, sd = bulb.sd, lower.tail = FALSE)
paste0("The probability that a randomly chose light bulb lasts more than 10,500 hours is: ", round(LastingLonger,2) * 100, "%.")
## [1] "The probability that a randomly chose light bulb lasts more than 10,500 hours is: 7%."
  1. Describe the distribution of the mean lifespan of 15 light bulbs.
fifteen.bulbs <- rnorm(15, mean = bulb.mean, sd = bulb.sd)
par(mfrow = c(1,2))
hist(fifteen.bulbs)
qqnorm(fifteen.bulbs)
qqline(fifteen.bulbs)

mean(fifteen.bulbs)
## [1] 9158.529
# The mean of the fifteen bulbs sample is close (but not exact) to the bulb.mean. This is because the N size is fairly small. If the N size increases in size, the sample mean will start to approach the population mean. Again, with a small N, the variance will be quite large, but as the N size starts to increase, the variance will start to decrease. If you take a large number of samples, the distribution will start to take the shape of a normal distribution curve (unimodal and without skew).
  1. What is the probability that the mean lifespan of 15 randomly chosen light bulbs is more than 10,500 hours?
# Given that these are sample means, we need to use the standard of error.

fifteen.bulbs.SOE <- bulb.sd/sqrt(15)
ans <- pnorm(10500, mean = bulb.mean, sd = fifteen.bulbs.SOE, lower.tail = FALSE) * 100
paste("The probability that the mean lifespan of 15 randomly chosen light bulbs is more than 10,500 hours is: ", round(ans,2), "%.")
## [1] "The probability that the mean lifespan of 15 randomly chosen light bulbs is more than 10,500 hours is:  0 %."
# With an answer of ~0%, it is very highly unlikely that we randomly choose a mean of 15 random light bulbs greater than 10,500 hours.
  1. Sketch the two distributions (population and sampling) on the same scale.
par(mfrow = c(2,1))
bulb.pop <- rnorm(10000, mean = bulb.mean, sd = bulb.sd)
hist(bulb.pop, xlim = c(4000,14000), prob = TRUE)
lines(density(bulb.pop, adjust = 2), lty = "dotted", col = "darkgreen", lwd = 2)
hist(fifteen.bulbs, xlim = c(4000,14000), prob = TRUE)
lines(density(fifteen.bulbs, adjust = 2), lty = "dotted", col = "blue", lwd = 2)

# If we took several thousand samples with N size = 15. The curve would look like below.
samp.bulb <- rep(NA, 5000)

for (i in 1:5000){
  samp <- rnorm(15, mean = bulb.mean, sd = bulb.sd)
  samp.bulb[i] <- mean(samp)
}

par(mfrow = c(2,1))
hist(bulb.pop, xlim = c(4000,14000), prob = TRUE)
lines(density(bulb.pop, adjust = 2), lty = "dotted", col = "darkgreen", lwd = 2)
hist(samp.bulb, xlim = c(4000,14000), prob = TRUE)
lines(density(samp.bulb, adjust = 2), lty = 'dotted', col = "blue", lwd = 2)

  1. Could you estimate the probabilities from parts (a) and (c) if the lifespans of light bulbs had a skewed distribution?
# If you have a skewed distribution, you CANNOT estimate the probabilities as one of the assumptions in order to perform these calculations is that there is no to very minimal skewed distributions.

4.48 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.

# To calculate the p value will depend on the standard of error.
# The formula for the standard of error is (standard deviation of the population) / (square root of N)
# After you calculate the standard of error, you can then calculate the Z score, using the standard of error in place of (point estimate - mean) / (standard of error). 
# To calculate the p-value (two test), you take 1 - probability value from the Z score and multiply it by 2.
# If you were to use N = 500, the denominator in the standard of error would get larger and hence, the standard of error would become small. If the standard of error becomes smaller, then the Z score will get larger (according to the above formula). If the Z score is larger, then (1 - probability value from the Z score) * 2 will get smaller as well. Thus the p-value will decrease.
# Therefore, having a higher N value will allow you to reject the null hypothesis in favor of the alternative hypothesis.