Load necessary libraries -
library(VennDiagram)
library(ggplot2)
library('DATA606')
##
## 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.
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.
(a)What is the point estimate for the average height of active individuals? What about the median?
Ans: The point estimate for average height is 171.1 cm and median is 170.3 cm.
(b)What is the point estimate for the standard deviation of the heights of active individuals? What about the IQR?
Ans: The point estimate for standard deviation is 9.4 cm and IQR = Q3 - Q1 = 177.8 - 163.8 = 14 cm.
(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.
Ans:
\[Z_{ 180 }\quad =\quad (x-\mu )/\sigma = (180 - 171.1)/9.4 \approx\quad0.94 \]
\[Z_{ 155 } = \quad (x-\mu )/\sigma = (155 - 171.1)/9.4 \approx\quad1.71\]
Since both the heights are withing 2 standard deviations of the mean, so none of them are completely unusual.
(d)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.
Ans: If the researchers take another random sample of physically active individuals, the point estimate for the mean and standard deviation for the new sample will probably be different than the ones captured in the previous sample. Estimates generally vary from one sample to another, and this sampling variation suggests our estimate may be close, but it will not be exactly equal to the parameter.
(e)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 \[SD_{ \bar { x } }=\sigma /\sqrt { n }\] )? Compute this quantity using the data from the original sample under the condition that the data are a simple random sample.
Ans: The measure to quantify the variability of point estiates taken through a simple random sample is called Standard Error which is the standard deviation associated with an estimate. It describes the typical error or uncertainty associated with the estimate.
\[SE_{ \bar { x } }=\sigma /\sqrt { n } =\quad 9.4/\sqrt { 507 } \approx\quad0.42\]
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.
(a)We are 95% confident that the average spending of these 436 American adults is between $80.31 and $89.11.
Ans: FALSE. Confidence interval represents a plausible range of values for a population parameter like average spend. This is not related to a point estimate for a parameter corresponding to a specific sample of 436 amarecicans in this example.
(b)This confidence interval is not valid since the distribution of spending in the sample is right skewed.
Ans: FALSE. Even though distribution of right skewed but the size of the population 436 is much larger than 30 to account for the skewedness.
(c)95% of random samples have a sample mean between $80.31 and $89.11.
Ans: FALSE. 95% confidence interval indicates that if we take many random samples and calculate confidence intervals, 95% of those intervals would actually contain the population mean.
(d)We are 95% confident that the average spending of all American adults is between $80.31 and $89.11.
Ans: TRUE. The confidence interval (if properly estimated) should show us that 95% of the time, when a sample of 436 is randomly taken from the population, the true population mean should fall within this interval.
(e)A 90% confidence interval would be narrower than the 95% confidence interval since we don’t need to be as sure about our estimate.
Ans: TRUE. With a 90% confidence interval we do not need such a wide interval to catch the values, so the interval would be narrower.
(f)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.
Ans: FALSE. In order to decrease the margin of error by 3, we need to increase the sample by \[{ 3 }^{ 2 } = 9\] (since n is under the square root in the margin of error formula).
(g)The margin of error is 4.4.
Ans: TRUE. The margin of error is half the confidence interval or (89.11−80.31)/2 = 4.4.
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.
(a)Are conditions for inference satisfied?
Ans: Yes the conditions of inference are satisfied.
1st Condition: The sample observations are independent. Here in this case, a random sample of children has been taken so the each one of them are seemingly independent of each other and the sample size is definitely less tan 10% of the population.
2nd Condition: The sample size 36 is greater than 30, which somewhat satisfies the minimum sample size requirement.
3rd Condition: The population distribution is not strongly skewed.
(b)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.
Ans:
\[H_{ 0 }\quad :\quad \mu \quad =\quad 32\] \[H_{ A }\quad :\quad \mu \quad <\quad 32\] \[\alpha \quad =\quad 0.10\] \[SE\quad =\quad \sigma /\sqrt { n } =\quad 4.31/\sqrt { 36 } \approx \quad 0.72\]
\[Z\quad =\quad (\bar { x } -\quad Null\quad Value)/SE_{ \bar { x } }\quad =\quad (30.69\quad -\quad 32)/0.72\quad \approx \quad -1.82\] Based on the Z score calculated above, from the Normal Probability table the area under the lower shaded area is 0.0344. Hence, p−value = 0.0344 < 0.10 = α (significance level), we reject the null hypethesis H0 in favor of HA.
(c)Interpret the p-value in context of the hypothesis test and the data.
Ans: 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).
(d)Calculate a 90% confidence interval for the average age at which gifted children first count to 10 successfully.
Ans: The 90% confidence interval is 30.69 ± 1.65∗SE = 30.69 ± 1.188 or (29.502,31.878).
(e)Do your results from the hypothesis test and the confidence interval agree? Explain.
Ans: Results from the hypothesis test and the confidence interval seem to agree. We are 90% confident that the average age at which gifted children first count to 10 is between 29.5 and 31.9 months. This is lower than the average age for all children at 32 months.
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.
(a)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.
Ans:
\[H_{ 0 }\quad :\quad \mu \quad =\quad 100\] \[H_{ A }\quad :\quad \mu \quad \neq \quad 100\] \[\alpha \quad =\quad 0.10\] \[SE\quad =\quad \sigma /\sqrt { n } =\quad 6.5/\sqrt { 36 } \approx \quad 1.08\] \[Z\quad =\quad (\bar { x } -\quad Null\quad Value)/SE_{ \bar { x } }\quad =\quad (118.2\quad -\quad 100)/1.08\quad \approx \quad 16.85185\]
With a Z value over 16, the p-value, even with a two-sided test, is close to 0. If the null hypothesis is true, then the probability of observing a sample mean as different as in our sample is lower than the significance level, α, of 0.10. We reject the null hypothesis H0 in favor of HA.
(b)Calculate a 90% confidence interval for the average IQ of mothers of gifted children.
Ans: The 90% confidence interval is 118.2±1.65∗SE=118.2±1.782 or (116.418,119.982).
(c)Do your results from the hypothesis test and the confidence interval agree? Explain.
Ans: Results from the hypothesis test and the confidence interval seem to agree. We are 90% confident that the average IQ of mothers of gifted children is between 116.4 and 120. This is significantly above population average of 100.
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.
Ans: The sampling distribution of the mean is the distribution of sample means of multiple samples. Per the Central Limit Theorem, it can be approximated by a normal model. As sample size increases the normal approximation becomes better and the spread of the sampling distribution of the mean becomes narrower.
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.
(a)What is the probability that a randomly chosen light bulb lasts more than 10,500 hours?
Ans:
\[Z_{ 10,500 } = \quad (x-\mu )/\sigma = (10500 - 9000)/1000 =\quad1.5\]
normalPlot(mean = 0, sd = 1, bounds=c(1.5,4), tails = FALSE)
Probability of x > 10500 is 1-pnorm(1.5) or 0.0668072.
(b)Describe the distribution of the mean lifespan of 15 light bulbs.
Ans: Assuming light bulbs are selected at random, the distribution of the mean lifespan of 15 light bulbs is nearly normal with distribution \[N(\mu ,\sigma /\sqrt { n } )\quad or\quad N(9000,\quad 258.1989)\]
(c)What is the probability that the mean lifespan of 15 randomly chosen light bulbs is more than 10,500 hours?
Ans:
\[Z_{ 10,500 } = \quad (x-\mu )/\sigma = (10500 - 9000)/258.1989 \approx \quad 5.81\]
The probability is 1 - pnorm(5.81) or ≈0.
(d)Sketch the two distributions (population and sampling) on the same scale.
Ans: Population distribution is black, sampling distribution is red.
s <- seq(5000,13000,0.01)
plot(s, dnorm(s,9000, 1000), type="l", ylim = c(0,0.002), ylab = "", xlab = "Lifespan (hours)")
lines(s, dnorm(s,9000, 258.1989), col="red")
(e)Could you estimate the probabilities from parts (a) and (c) if the lifespans of light bulbs had a skewed distribution?
Ans: We could not estimate part a without a nearly normal distribution. We coule not estimate part c since the sample size is not sufficient to yield a nearly normal sampling distribution to account for a skewed distribution.
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.
Ans: Same observation, different sample size.
\[Z\quad =\quad (Point\quad Estimate\quad -\quad Null\quad Value)/SE_{ Point\quad Estimate },\quad where\quad SE_{ Point\quad Estimate }=s/\sqrt { n } \] If n is increased from 50 to 500, then SE will decrease and alternatively Z will increase in case of positive Z and decrease in case of negative Z. As Z is changed, p−value will decreased.