See https://data606.net/assignments/homework/ for more information. Chapter 4 Foundations for Inference 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
Refer to “Getting Started with R” in https://data606.net/post/
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.
hist(bdims$hgt)(See the next page for parts (b)-(e).)
paste("Average height of active individuals:",mean(bdims$hgt),"centimeters.")## [1] "Average height of active individuals: 171.143786982249 centimeters."
paste("Median height of active individuals:",median(bdims$hgt),"centimeters.")## [1] "Median height of active individuals: 170.3 centimeters."
summary(bdims$hgt)## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 147.2 163.8 170.3 171.1 177.8 198.1
paste("Standard deviation of the heights of active individuals:",sd(bdims$hgt),"centimeters.")## [1] "Standard deviation of the heights of active individuals: 9.40720520351794 centimeters."
paste("InterQuartile Range (IQR) of the heights of active individuals:",summary(bdims$hgt)[2],"-",quantile(bdims$hgt, 0.75),"centimeters.")## [1] "InterQuartile Range (IQR) of the heights of active individuals: 163.8 - 177.8 centimeters."
Explain your reasoning.
Z <- (x-u)/sdZ180 <- (180 - 171.1) / 9.4; Z180## [1] 0.9468085
Z155 <- (155 - 171.1) / 9.4; Z155## [1] -1.712766
According 68-95-99.7 rule, 95% percentile z score is ±1.96. Also Z score range are within 2 stardard deviations from mean is (152.3, 189.9). Since both observations fall within 2 standard deviations, both heights of 180cm and 155cm are not considered as unusual.
Explain your reasoning.
The new sample is a different sample population with different estimates and will have different values than the given sample. In such a case, the new values will have a slightly different mean and standard deviation values but close enough to the given.
What measure do we use to quantify the variability of such an estimate (Hint: recall that SD¯x = ! pn )? Compute this quantity using the data from the original sample under the condition that the data are a simple random sample.
n <- 507
SE <- sigma/sqrt(n)paste("Compute Standard Error for sample mean:",sd(bdims$hgt)/sqrt(507))## [1] "Compute Standard Error for sample mean: 0.417788650505626"
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.
hist(tgSpending$spending)#Confidence intervals
sample_mean <- mean(tgSpending$spending)
se <- sd(tgSpending$spending) / sqrt(436)
lower <- sample_mean - 1.96 * se
upper <- sample_mean + 1.96 * se
c(lower, upper)## [1] 80.30173 89.11180
FALSE - as per above we are 95% confident that the average spending of ALL (not just limited to 436) American adults is between $80.31 and $89.11.
There are a few conditions that must be met for this interval to be valid What conditions must be met for this to be true? - The sample observations are indenpendent. : True - The sample size is larger that 30 : True - The population distribution is not strongly skewed : True
FALSE - As per the histogram although graph is right skewed but it is not strongly right skewed and the distribtion is normal for the mean and already n (436) > 30
FALSE - It only provides a guide for how large we should make the confidence interval. We can’t say that 95% of samples will fall in this interval. Confidence interval is used to determine population parameter and has no relation with samples and sample means.
paste0("The population mean of ", mean(tgSpending$spending),"falls in the 95% confidence interval [80.31 89.11]")## [1] "The population mean of 84.7067651338864falls in the 95% confidence interval [80.31 89.11]"
TRUE - It’s estimated by the point estimate and the confidence interval.
Confidence level depends on three components. - Point estimate - z-score and - standard error.
In the case of 95%, z-score is 1.98, that means point estimate is within ±1.98 times standard error. For 90% z-score point estimate would be 1.65 which is in the range of ±1.30 times standard error.
TRUE - Hence when confidence level is reduced, there is a chance population parameter may not be captured. This will include less accurate population mean than before however we don’t need to be as certain so we can have a narrower CI.
paste0("The standaed error : ", sd(tgSpending$spending) / sqrt(436))## [1] "The standaed error : 2.24746812614075"
FALSE - If n is multiplied by 3, the standard error will be reduced by sqrt(3) instead sample size needs to be increased by 9 times ( since sqrt(9)=3 )
paste0("TRUE - The margin of error : ", (upper <- sample_mean + 1.96 * se) -(mean(tgSpending$spending)))## [1] "TRUE - The margin of error : 4.40503752723588"
paste0("Another way to calculate the margin of error : ", (upper - lower)/2)## [1] "Another way to calculate the margin of error : 4.40503752723588"
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.
hist(gifted$count)Use this information to determine if the heights approximately follow the 68-95-99.7% Rule.
TRUE - Because, - the random sample of 36 must be much less than 10% of all children in a large city, we may assume the sample observations are independent - the sample size is larger that 30 - the population distribution is not strongly skewed.
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. Explain your reasoning using the graphs provided below.
Assuming, Ho = Average age gifted children count to 10 successfully when they are 32 months old Ha = Average age gifted children count to 10 successfully < 32 months Significance level = 0.10
x <- 32
n <- 36
mean <- mean(gifted$count)
sd <- sd(gifted$count)
SE <- sd/sqrt(n)
z = (mean - x)/SE
p = pnorm(z)
paste0 ("Since, ",p,"< 0.10, we can reject the null hypothesis Ho in favor of alternative Ha")## [1] "Since, 0.0347296895177584< 0.10, we can reject the null hypothesis Ho in favor of alternative Ha"
normalPlot(mean = 0, sd = 1, bounds = c(-Inf,z), tails = FALSE)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). The p-value of 0.034 is less than 0.1 significance level so we can reject the null hypothesis that the gifted students can counted to 10 to 32 and there is no difference between the groups. As can be seen from the plot above, p-value falls in the left tail area of the normal curve. p-value is less than significance level(??) = 0.0344 < 0.10.
lower_interval <- mean - (qnorm(0.90) * SE)
upper_interval <- mean + (qnorm(0.90) * SE)
c(lower_interval,upper_interval)## [1] 29.77282 31.61607
Explain.
Yes, the hypothesis testing and confidence interval agree as we see the range of confidence interval is less than 32. The upper bound for the 90% confidence interval of the average age at which gifted children first count to 10 successfully is 31.61 months, which is still less than 32 months. 32 months is the average age for the general population. Both support the alternative hypothesis in providing convincing evidence that the average age at which gifted children first count to 10 successfully can be less than the general average of 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.
hist(gifted$motheriq)Ho: Null hypothesis - The average IQ of mothers of gifted children is the same as that of the general population, ??g=100 months. Ha: Alternative hypothesis - The average IQ of mothers of gifted children is different than that of the general population, ??g???100 32 months.
x <- 100
n <- 36
mean <- mean(gifted$motheriq); mean## [1] 118.1667
sd <- sd(gifted$motheriq); sd## [1] 6.504943
SE <- sd/sqrt(n); SE## [1] 1.084157
z <- (mean - x)/SE; z## [1] 16.75649
p <- 2 * (pnorm(z, 0, 1, lower.tail = FALSE)); p## [1] 5.077477e-63
normalPlot(mean = 0, sd = 1, bounds = c(-z,z), tails = TRUE)A P value is less than our significance level of .1, so we can reject the null hypothesis in favor of the alternative hypothesis. There is statistical evidence that the IQ of the mothers of gifted children is different than that of the general population.
lower_value <- mean - (qnorm(0.90) * SE)
upper_value <- mean + (qnorm(0.90) * SE)
c(lower_value,upper_value)## [1] 116.7773 119.5561
Explain.
TRUE - 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.
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.
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. These means are used as the data, rather than individual scores.
Ideally, a sample to be considered random it should be less than 10% of actual individual scores and at least 30 such samples form good sampling distribution. If the sample size(sample of means) increases,
Along with the above, sample means will fit into normal bell curve, 68-95-99.7 rule.
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.
pnorm(10500, 9000, 1000, lower.tail = F)## [1] 0.0668072
sd = 1000
n = 15
b15 <- sd/sqrt(n); b15## [1] 258.1989
pnorm(10500, mean=9000, sd=b15, lower.tail = FALSE)## [1] 3.133452e-09
SN <- seq(9000 - (4 * sd), 9000 + (4 * sd), length=15)
SR <- seq(9000 - (4 * b15), 9000 + (4 * b15), length=15)
nd1 <- dnorm(SN,9000,1000)
nd2 <- dnorm(SR,9000,b15)
plot(SN, nd1, type="l",col="blue",
xlab=" Population vs Sampling",
main=" Compact Fluorescent Light Bulbs",
ylim=c(0,0.002))
lines(SR, nd2, col="red")z <- (10500-9000)/1000
normalPlot(mean = 0, sd = 1, bounds = c(-Inf,z), tails = FALSE)It would be difficult because - the sample size is too small (n<30) - without normal population distribution we would not be able to resolve. Sample could not generate normal distribution if population distribution is not normal.
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.
This can be explained using the example. Lets assume (SD=10), for as sample size (n) = 50
z-score(50) = 1.41421356237309, then z-score will be used to calculate p-value, and p-value effects hypothesis testing.
z-score(500) = 0.447213595499958, in this case z-score decresed, this will impact p-value, and hypothesis testing
As the sample size(n) increases, p-value decreases. - If it’s a negative z-score, then this would cause the z-score to decrease which would make the p-value would decrease as well (left tail). - If it’s a positive z-score, then this would cause the z-score to increase which would make the p-value would decrease (right tail).