Chapter 4: Foundations for Inference

## 
## 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, 3rd Edition. You can read this by typing 
## vignette('os3') 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.

Graded: 4.04, 4.14, 4.24, 4.26, 4.34, 4.40, 4.48

4.04 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?
    • The point estimate (mean) height is 171.1 cm and the median is 170.3 for the sampled active individuals.
  2. What is the point estimate for the standard deviation of the heights of active individuals? What about the IQR?
    • The point estimate is 9.4 for sd and 14 for IQR.
q3 <- 177.8
q1 <- 163.8
q3-q1
## [1] 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.
    • A person who is 180 cm would fall within 1 sd of the mean, and would not be considered abnormally tall.
    • A person who is 155 cm would fall within 2 sd of the mean, which would consist of a smaller proportion of the sampled population. If normally distributed, 68% of the population should fall within 1 sd of the mean, and 95% would fall within 2 sd. Thus, this height would be less common than 180 cm, but not unsual.
m <- 171.1
sd <- 9.4

sd1 <- range(c(m+sd, m-sd))
sd2 <- range(c(m+sd*2, m-sd*2))
sd3 <- range(c(m+sd*3, m-sd*3))

rbind(sd1, sd2, sd3)
##      [,1]  [,2]
## sd1 161.7 180.5
## sd2 152.3 189.9
## sd3 142.9 199.3
  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.
    • A new random sample should produce different, but similar results given a sample size of 507 persons.
  2. 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 ¯ = p !n)? / Compute this quantity using the data from the original sample under the condition that the data are a simple random sample.
    • We want to use the standard error (se) to quantify the variability of this estimate.
se<-sd/sqrt(507)
se
## [1] 0.4174687

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. 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.
    • True. We can be 95% confident that the stated range contains the true mean for the population.
  2. This confidence interval is not valid since the distribution of spending in the sample is right skewed.
    • False. The confidence interval must not significantly skewed in order for to be valid.
    • The data shown is skewed to the right, but not significantly enough to affect the normal distribution.
  3. 95% of random samples have a sample mean between $80.31 and $89.11.
    • False. The CI is for the population mean, not the sample.
  4. We are 95% confident that the average spending of all American adults is between $80.31 and $89.11.
    • True. We can be 95% confident that the true mean of this population is within this range.
  5. 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. The bounds of 90% CI would be more narrow than a 95% CI.
  6. 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. The margin of error is calculated by multiplying the critical value by the standard error. To calculate se, we divide sd by the square root of the sample size. Thus, we would need to multiply the sample size by 9 in order to decrease the me by 1/3rd.
  7. The margin of error is 4.4.
    • False. See below calculations:
n <- 436
sd<-(89.11-80.31)/2
se<-sd/sqrt(n)
z<-1.96

me <- z * se
me
## [1] 0.4130147

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 distribution 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?
    • Conditions for inference: The sample must be random, independent, consider less than 10% of the population, be subjectively large, and not be significantly skewed.
    • These conditions are satisfied in this example.
  2. 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.
    • H0: mean = 32
    • HA: mean < 32
m<-30.69
sd<-4.31
h<-32
n<-36

se<-sd/sqrt(n)

z = (m-h)/se
p = pnorm(z,lower.tail = TRUE)
p
## [1] 0.0341013
  1. Interpret the p-value in context of the hypothesis test and the data.
    • The small p-value and significance level would lead us to reject the H0 in favor of HA.
  2. Calculate a 90% confidence interval for the average age at which gifted children first count to 10 successfully.
z=1.65

lowerCI <- m - (z * se)
upperCI <- m + (z * se)
rbind(lowerCI, upperCI)
##             [,1]
## lowerCI 29.50475
## upperCI 31.87525
  1. Do your results from the hypothesis test and the confidence interval agree? Explain.
    • The hypothesis testing and CI appear to be in agreement.
    • We rejected the null in favor of the alternative hypothesis, that the mean value will be less than 32 months.
    • Our CI tells us that we can be 90% confident the true mean of the population falls within 29.5 and 31.9.

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.
    • H0: mean = 100
    • HA: mean <> 100
m<-118.2
sd<-6.5
h<-100
n<-36

se<-sd/sqrt(n)

z = (m-h)/se
p = 1-pnorm(z)
p
## [1] 0

We interpret can interpret the significantly small p value to mean that the H0 mean would be highly uncommon, if not impossible. The value and significance level would lead us to reject the H0 in favor of HA.

  1. Calculate a 90% confidence interval for the average IQ of mothers of gifted children.
z=1.65

lowerCI <- m - (z * se)
upperCI <- m + (z * se)
rbind(lowerCI, upperCI)
##             [,1]
## lowerCI 116.4125
## upperCI 119.9875
  1. Do your results from the hypothesis test and the confidence interval agree? Explain.
    • The hypothesis testing and CI agree. The CI is greater than 100, which is the mean value rejected by the null hypothesis.

4.34 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. + The sampling distribution of the mean contains the distribution of all sample means of a selected number of samples. + The central limit theory allows these sample means to be approximated as a normal distribtion. + As the sample size increases, this approximation becomes closer to the population mean.

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?
    • 6.7% probability that the selected light buld lasts more than 10,500 hours.
m <- 9000
sd <- 1000
h <- 10500

z <- (h - m) / sd

p = 1-pnorm(z)
p
## [1] 0.0668072
  1. Describe the distribution of the mean lifespan of 15 light bulbs.
    • CLT requires 30 observations to approximate normal distribution.
    • While we approximate, this should be near normal.
  2. What is the probability that the mean lifespan of 15 randomly chosen light bulbs is more than 10,500 hours?
    • 0.4% probability that the selected light buld lasts more than 10,500 hours.
pnorm(h - m)/(sd/sqrt(15))
## [1] 0.003872983

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. + The p-value should decrease, because it is dependent on the square root and sample size.