if (Sys.info()["sysname"] == "Windows") {
setwd("~/Masters/DATA606/Week4/Homework")
} else {
setwd("~/Documents/Masters/DATA606/Week4/Homework")
}
require(ggplot2)
## Loading required package: ggplot2
Answer:
\[Mean: 171.1\\Median: 170.3\]
Answer:
\[SD: 9.4\\IQR = Q3 - Q1 = 177.8 - 163.8 = 14\]
IQR:
Answer:
(180 - 171.1)/9.4
## [1] 0.9468085
A person who is 180 cm is not considered unusually tall since it is only 0.94 standard deviations from the sample mean, which is less than two standard deviations.
(155 - 171.1)/9.4
## [1] -1.712766
A person who is 155 cm tall is not unusal either since it is also within two standard deviations from the mean.
Answer:
No, the point estimates are based on sampling data and only approximate the population; therefore, it is not expected that the values would be the same each time a new sample is taken.
Answer:
The measure we use is the standard error which is calculated as:
\[\frac { s }{ \sqrt { n } } =\frac { 9.4 }{ \sqrt { 507 } } =\quad 0.417\]
Answer:
False, this statement refers to the surveyed 436 American adults mean spending. The confidence interval makes inference on the population. The point estimate is always within the confidence interval.
Answer:
The question did not state that the distribution was skewed, and we cannot tell if that is the case from the data provided to us. However, as long as the distribution is not strongly skewed, we can be lenient as long as we have a large number of samples, which appears to be the case (n = 436).
Answer:
False, the confidence interval does not make inferences on sample means.
Answer:
True
Answer:
True
Answer:
The 95% confidence interval changes based on two parameters, standard deviation and number of samples. Assuming that the standard deviation would remain the same if more samples were taken, we would need a sample 9 times larger since a square root is applied to the value.
se = 9.4/sqrt(507)
new_se = se/3
n = (9.4/new_se)^2
n
## [1] 4563
n/507
## [1] 9
Answer:
True, the margin of error is half the interval.
(89.11 - 80.31)/2
## [1] 4.4
Answer:
The conditions for inference are:
The question indicates that a random sample was taken and we can assume that 36 samples is less than 10% of the population (children within the large city schools, possibly all children if there is no selection bias).
The sample is greater than 30, which is rule of thumb for determining a large sample size.
The population does not appear to be strongly skewed since the minimum and maximum values reported are both approximately 9 months from the mean and the data appears to be roughly normally distributed. It seems like there is a bi-modal peak around 35 months but this might be due to the bin width selected.
Additionally, I made a simulated set of data from a normal distribution and plotted the histogram. This plot does not appear to show any better shape, or less skew, than the sample results.
set.seed(4)
sim_norm <- rnorm(n = 36, mean = 30.69, sd = 4.31)
hist(sim_norm)
Answer:
The question is seeking whether the data provide evidence that the average age gifted children count to ten is less than the 32 months. This is one sided test which can be summed up with the following formulas:
\[{ H }_{ O }:\quad \mu \quad =\quad 32\\ { H }_{ A }:\quad \mu \quad <\quad 32\\\alpha = 0.10\]
sig_level <- qnorm(p = 0.1, mean = 0, sd = 1)
se <- 4.31/sqrt(36)
z_value <- round(x = (30.69 - 32)/se, 2)
lb <- -4
ub <- 4
z1 <- z_value
z2 <- z_value
pick_line1 <- z1
pick_line2 <- z1
ggplot(data.frame(x = c(lb, ub)), aes(x)) + stat_function(fun = dnorm) +
stat_function(fun = dnorm, xlim = c(lb, sig_level), geom = "area",
alpha = 0.5) + geom_vline(xintercept = pick_line1, color = "black",
alpha = 0.75) + geom_text(aes(x = pick_line1, y = 0.25, label = sprintf("Z = %s\n",
pick_line1)), color = "black", angle = 90) + geom_vline(xintercept = pick_line2,
color = "black", alpha = 0.75) + geom_text(aes(x = pick_line2,
y = 0.25, label = sprintf("Z = %s\n", pick_line2)), color = "black",
angle = 90) + labs(x = "Z - Value")
The grey shaded area represents the z_value scores which would cause us to reject the null hypothesis based on a significance level (\(\alpha\)) of 0.10. Our results return a Z-value of -1.82; therefore, we reject the null hypothesis that the true population mean is equal to 32 months. The data provide convnincing evidence that the average age at which gifted children fist count to 10 successfully is less than 32 months, using a significance level of 0.10.
Answer:
pnorm(q = 30.69, mean = 32, sd = se)
## [1] 0.0341013
The p-value of the data is 0.034. The chance of observing that the average age at which gifted children fist count to 10 successfully is 30.69 months or less, given that that the true mean is 32 months, is 3.4%.
Answer:
pnorm(q = 1.65, mean = 0, sd = 1) - pnorm(q = -1.65, mean = 0,
sd = 1)
## [1] 0.9010571
error_margin <- 1.65 * se
30.69 - error_margin
## [1] 29.50475
30.69 + error_margin
## [1] 31.87525
We are 90% confident that the true average age at which gifted children fist count to 10 successfully is between 29.50 and 31.88 months.
Yes, the hypothesis test rejected the null hypothesis and the average of 32 months is not within the confidence interval. However, it is possible that these two tests could disagree under different circumstances since a one-sided test will reject the null hypothesis if the probability of obtaining a sample mean is 10% or less, given that the null hypothesis mean is true; however, the 90% confidence interval has two sides which means that the lower and upper tail areas that are excluded by the interval represent 5% probability each.
Answer:
\[{ H }_{ O }:\quad \mu \quad =\quad 100\\{ H }_{ A }:\quad \mu \quad \neq \quad 100\\\alpha = 0.10\]
l_sig_level <- qnorm(p = 0.05, mean = 0, sd = 1)
u_sig_level <- qnorm(p = 0.95, mean = 0, sd = 1)
se <- 6.5/sqrt(36)
z_value <- round(x = (118.2 - 100)/se, 2)
lb <- -4
ub <- 4
z1 <- z_value
z2 <- z_value
pick_line1 <- z1
pick_line2 <- z1
ggplot(data.frame(x = c(lb, ub)), aes(x)) + stat_function(fun = dnorm) +
stat_function(fun = dnorm, xlim = c(lb, l_sig_level), geom = "area",
alpha = 0.5) + stat_function(fun = dnorm) + stat_function(fun = dnorm,
xlim = c(u_sig_level, ub), geom = "area", alpha = 0.5) +
geom_vline(xintercept = pick_line1, color = "black", alpha = 0.75) +
geom_text(aes(x = pick_line1, y = 0.25, label = sprintf("Z = %s\n",
pick_line1)), color = "black", angle = 90) + geom_vline(xintercept = pick_line2,
color = "black", alpha = 0.75) + geom_text(aes(x = pick_line2,
y = 0.25, label = sprintf("Z = %s\n", pick_line2)), color = "black",
angle = 90) + labs(x = "Z - Value")
Since we are only questioning whether the average IQ of the mothers is different than the average, we use a two sided test. The hypothesis test resulted in an extremely high z-value which results in a p-value of almost zero. Therefore we reject the null hypothesis that the true mean is equal to 100. The data provide convnincing evidence that the average IQ of mothers of gifted children is not equal to 100, using a significance level of 0.10.
Answer:
pnorm(q = 1.65, mean = 0, sd = 1) - pnorm(q = -1.65, mean = 0,
sd = 1)
## [1] 0.9010571
error_margin <- 1.65 * se
118.2 - error_margin
## [1] 116.4125
118.2 + error_margin
## [1] 119.9875
We are 90% confident that the true average IQ for mothers of gifted children is between 116.4 and 120.0.
Answer:
Yes, the hypothesis test rejected the null hypothesis and the average of a 100 IQ score is not within the confidence interval.
Answer:
The sampling distribution represents the distribution of the point estimates based on samples of a fixed size from a certain population. As the sample size increases, the shape of the distribution becomes more normal, the center is generally closer to the true mean, and the spread of the samples are smaller.
Answer:
Given that the population is normally distributed:
1 - pnorm(q = 10500, mean = 9000, sd = 1000)
## [1] 0.0668072
There is a 6.7% chance that a randomly chosen light bulb will last more than 10,500 hours
Answer:
Since the population is nearly normal the sample will be approximately \[N\left( \mu ,\frac { \sigma }{ \sqrt { n } } \right) =N\left( 9000,\frac { 1000 }{ \sqrt { 15 } } \right) =N\left( 9000,258.20 \right)\]
mean_value <- 9000
se <- 1000/sqrt(15)
mean_value
## [1] 9000
se
## [1] 258.1989
Answer:
z_value <- (10500 - mean_value)/se
z_value
## [1] 5.809475
1 - pnorm(q = z_value, mean = 0, sd = 1)
## [1] 3.133452e-09
There is approximately 0% chance that the mean lifespan of 15 randomly chosen light bulbs is more than 10,500 hours
Answer:
ggplot(data.frame(x = c(6000, 12000)), aes(x)) + stat_function(fun = dnorm,
args = list(mean = 9000, sd = 1000), aes(color = "population")) +
stat_function(fun = dnorm, args = list(mean = 9000, sd = se),
aes(color = "sample")) + scale_color_manual("Distribution",
values = c("red", "blue"))
Answer:
We could not estimate (a) without a nearly normal distribution since the parameters are basd on the population. We also could not estimate (c) since the sample size is not sufficient (less than 30) to yield a nearly normal sampling distribution if the population distribution is significantly skewed.
Answer:
The p-value is based on determining a z-value from the sample distribution. The denominator of the z-value calculation is the standard error. An increase in n would result in a decrease in the standard error which would in turn increase the z-value determined. Therefore, the overall result would be a decrease in the p-value
\[\qquad Z\quad =\quad \frac { \overline { x } -\quad null\quad value }{ { SE }_{ x } } =\quad \frac { \overline { x } -\quad null\quad value }{ \frac { s }{ \sqrt { 50 } } } =\frac { (\overline { x } -\quad null\quad value)\quad *\quad \sqrt { 50 } }{ s } \\ \frac { (\overline { x } -\quad null\quad value)\quad *\quad \sqrt { 50 } }{ s } \quad *\quad \frac { \sqrt { 500 } }{ \sqrt { 50 } } \quad =\quad Z\quad *\quad \frac { \sqrt { 500 } }{ \sqrt { 50 } } \]
z_value <- qnorm(p = 0.08, mean = 0, sd = 1)
z_value
## [1] -1.405072
z_value_new <- z_value * sqrt(500)/sqrt(50)
z_value_new
## [1] -4.443226
p_value_new <- pnorm(q = z_value_new, mean = 0, sd = 1)
p_value_new
## [1] 4.430991e-06