library(ggplot2)
library('DATA606') # Load the package
##
## 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.
##
## Attaching package: 'DATA606'
## The following object is masked from 'package:utils':
##
## demo
library(knitr)
#vignette(package='DATA606') # Lists vignettes in the DATA606 package
#vignette('os3') # Loads a PDF of the OpenIntro Statistics book
#data(package='DATA606') # Lists data available in the package
#getLabs() # Returns a list of the available labs
#viewLab('Lab0') # Opens Lab0 in the default web browser
#startLab('Lab0') # Starts Lab0 (copies to getwd()), opens the Rmd file
#shiny_demo() # Lists available Shiny apps
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.
Answer:
Mean: 171.1
Median: 170.3
Answer:
SD: 9.4
IQR: IQR = Q3 - Q1
Q3 <- 177.8
Q1 <- 163.8
IQR <- Q3 - Q1
IQR
## [1] 14
(c)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.
Answer:
For 180:
x <- 180
mu <- 171.1
sigma <- 9.4
z <- (x - mu)/sigma
z
## [1] 0.9468085
z = 0.9468085 i.e less than 2, the person is not unusually tall.
For 155:
x <- 155
mu <- 171.1
sigma <- 9.4
z <- (x - mu)/sigma
z
## [1] -1.712766
z = -1.712766 i.e not beyond -2 the person is not unusually short.
Answer:
Expert would not obtain the same values as the ones in the chart. The new sample would be similar but not necessarily the same because if samples vary, their point estimates may also vary.
Answer:
sd <- 9.4
n <- sqrt (507)
sd/n
## [1] 0.4174687
4.14 Thanksgiving spending, Part I. The 2009 holiday retail season, which kicked o??? 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.
Answer:
FALSE. The confidence interval looks at the population not the sample size.
Answer:
FALSE. The sample is sufficiently large (n = 436) to account for the skew.
Answer:
FALSE. Confidence interval for the mean of a sample is not about other sample means.
Answer:
TRUE. Its estimated by the point estimate and the confidence interval.
Answer:
TRUE. With a 90% confidence interval we do not need such a wide interval to catch the values, so the interval would be narrower.
Answer:
FALSE. We will need 3 times large samples.
Answer:
x1 <- 80.31
x2 <- 89.11
(x2 - x1)/2
## [1] 4.4
TRUE. The margin of error is half the confidence interval.
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.
Answer:
Yes, The sample is random and 36 children of a large city is most likely under 10% of the population. The sample size is over 30. There doesn’t appear to be any strong skew in the population.
Answer:
x <- 32
n <- 36
avg <- 30.69
sd <- 4.31
SE <- sd/sqrt(n)
z = (avg - x)/SE
p = pnorm(z)
p
## [1] 0.0341013
0.0341013<0.10, we reject the null hypethesis H0 in favor of HA
Answer:
If the null hypothesis is true, then the probability of observing a sample mean lower than 30.69 for a sample of 36 children is only 0.0344 (p-value).
Answer:
x1 <- avg - 1.65 * SE
x2 <- avg + 1.65 * SE
x1
## [1] 29.50475
x2
## [1] 31.87525
Answer:
We are 90% confident that the average age at which gifted children first count to 10 is between 29.5 and 31.9 months.
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.
x <- 100
n <- 36
avg <- 118.2
sd <- 6.5
SE <- sd/sqrt(n)
z = (avg - x)/SE
z
## [1] 16.8
x1 <- avg - 1.65 * SE
x2 <- avg + 1.65 * SE
x1
## [1] 116.4125
x2
## [1] 119.9875
Answer:
Yes, We are 90% confident that the average IQ of mothers of gifted children is between 116.4125 and 119.9875. This is significantly above population average of 100.
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.
Answer:
A sampling distribution is a probability distribution of a statistic obtained through a large number of samples drawn from a specific population. The sampling distribution of the mean takes the mean of each sample. As the sample size gets larger, the shape becomes on a more ‘normal’ and has a smaller spread.
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.
Answer:
p <- 1 - pnorm(10500, 9000, 1000)
p
## [1] 0.0668072
Answer:
The distribution of the mean lifespan of 15 light bulbs would be nearly normal.
Answer:
Z <- (10500 - 9000)/258
p <- 1 - pnorm(Z)
p
## [1] 3.050719e-09
The probability is 0%.
Answer:
normalPlot(9000, 1000)
For 15 bulbs:
normalPlot(9000, 1000/sqrt(15))
Answer:
No, We could not estimate parts (a) and (c) without a nearly normal distribution. For part (c) the sample size is too small.
4.48 Same observation, di???erent 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.
Answer:
P-value will decrease as the sample size increases. With a smaller sd the Z-score will increase causing the p-value to decrease.