I could not download ‘DATA606’ package as it is not compatible with the last version of R. I have manually taken function normalPlot() from the package. source: https://github.com/jbryer/DATA606/blob/master/R/normalPlot.R
normalPlot <- function(mean=0, sd=1, bounds=c(-1,1), tails=FALSE) {
x <- seq(-4,4,length=100)*sd + mean
hx <- dnorm(x,mean,sd)
plot(x, hx, type="n", xlab="x-Axis", ylab="",
main="Normal Distribution", axes=FALSE)
lines(x, hx)
if(tails) {
i.low <- x <= bounds[1]
i.high <- x >= bounds[2]
polygon(c(x[i.low],bounds[1]), c(hx[i.low], 0), col="red")
polygon(c(bounds[2],x[i.high]), c(0,hx[i.high]), col="red")
} else {
i <- x >= bounds[1] & x <= bounds[2]
polygon(c(bounds[1],x[i],bounds[2]), c(0,hx[i],0), col="red")
area <- pnorm(bounds[2], mean, sd) - pnorm(bounds[1], mean, sd)
if(diff(bounds) > 0) {
result <- paste("P(",bounds[1],"< x <",bounds[2],") =",
signif(area, digits=3))
mtext(result,3)
}
}
axis(1)
}
# normalPlot(mean = 0, sd = 1, bounds = c(-1.13, 4))
The point estimate for the average height of active individuals is 171.1.
The median is 170.3.
As data is normally distributed with not many outliers it is better to use mean.
The point estimate for the standard deviation height of active individuals is 9.4.
The point estimate for the IQR height of active individuals is IQR = Q3 - Q1 = 177.8−163.8 = 14.
Person can be considered unusually tall or short if person height would be more than +2 or -2 standard deviations from the mean.
Solution for 180
x <- 180
mu <- 171.1
sd<- 9.4
z <- (x - mu)/sd
z
## [1] 0.9468085
180cm is 0.94 standard deviation away from the mean, this is less than 2 standard deviation. Person with height of 180cm can not be considered as unusually tall.
Another solution:
+2 standard deviation away from mean is 189.9cm. From that height person can be considered unusually tall. 180cm is less than 189.9, that’s why person can not be considered unusually tall.
180>(171.1+ 2*9.4)
## [1] FALSE
Solution for 155
x <- 155
mu <- 171.1
sd<- 9.4
z <-(x - mu)/sd
z
## [1] -1.712766
155cm is |-1.7| standard deviation away from the mean, this is less than |-2| standard deviation. Person with height of 155 cm can not be considered as unusually short.
Another solution:
-2 standard deviation away from mean is 152.3cm. From that height person can be considered unusually short. 155cm is more than 152.3cm, that’s why person can not be considered unusually short.
155<(171.1+ 2*(-9.4))
## [1] FALSE
If the population hight is normally distributed,samples were taken randomly and sample sizes are the same then mean and standard deviation will be similar, not identical. 95.4% probability that samples mean fall within 2 standard deviation from the population mean. The larger sample the smaller standard deviation.
n <- 507
SE <- sd/sqrt(n)
SE
## [1] 0.4174687
4.2%
As confidence interval and confidence level should be applied to the estimation of the population mean, not sample mean. As with the sample mean we are 100% sure about the sample mean as we have all data to calculate it.
The distribution is slightly right skewed so it can be tolerated taking into the account that sample is quite large.
We are 95% confident that the average spending of all American adults is between $80.31 and $89.11.
TRUE - We are 95% confident that the average spending of all American adults is between $80.31 and $89.11.
TRUE - A 90% confidence interval would be narrower than the 95% confidence interval, hence we will be less sure about our estimates.
FALSE - 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.
We need to increse a sample size by 3 times 2 which is 9 (from the margin of error formula).
The margin of error = confidence interval/2
(89.11-80.31)/2
## [1] 4.4
It seems that condition are satisfied because:
H0: μ>=32 months
H1: μ<32 months
x <- 32
n <- 36
mean <- 30.69
sd <- 4.31
se <- sd/sqrt(n)
z = (x-mean)/se
p = 1-pnorm(z)
p
## [1] 0.0341013
We have enough evidence to reject the null hypethesis because p is less than significance level and we accept the alternative hypethesis.
P-value is the probability of finding any result under the test conditions for a given set of data presuming that the null hypothesis were true. The p-value has to be smaller than the significance level because that gives us an indication that the probability of that result happening is very low.
The probability that gifted childred first count to 10 at the age of 32 months and up is so low (less than significance level of 0.1) that we can reject that hypotesis (H0).
LowerTail <- mean - 1.645 * se
UpperTail <- mean + 1.645 * se
LowerTail
## [1] 29.50834
UpperTail
## [1] 31.87166
The 90% confidence interval is between 29.5 and 31.9
We are 90% confident that the average age at which gifted child first count to 10 is between 29.5 and 31.9 months and it is lower than the average age for ordnary children ( 32 months and up). Results agree.
H0: μ<=100 H1: μ>100
x <- 100
n <- 36
mean <- 118.2
sd <- 6.5
se <- sd/sqrt(n)
z = (x-mean)/se
p = pnorm(z)
p
## [1] 1.22022e-63
p < 0.1, we can reject the H0 hypotesis and accept the alternative one. The average IQ of mothers of gifted children is higher than the average IQ of mothers of ordinary children.
LowerTail <- mean - 1.645 * se
UpperTail <- mean + 1.645 * se
LowerTail
## [1] 116.4179
UpperTail
## [1] 119.9821
We are 90% confident that the average IQ of mothers of gifted children is between 116.4 abd 120 which is higher than 100. Results agreed.
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.
“sampling distribution” of the mean means is a theoretical distribution of the values that the mean of a sample takes on in all of the possible samples of a specific size that can be made from a given population. The central limit theorem states that if you have a population with mean μ and standard deviation σ and take sufficiently large random samples from the population with replacement , then the distribution of the sample means will be approximately normally distributed. As the sample size increases the distribution will have better normally distributed shape, spread will be smaller and the center will be closer to the population mean.
1 - pnorm(10500, 9000, 1000)
## [1] 0.0668072
The sample of 15 light bulbs has only one mean. It is not appropriate to talk about the distribution of one mean.
x = 10500
mean = 9000
sd<-1000
SE<-sd/sqrt(15)
Z <- (x - mean)/258
p <- 1 - pnorm(Z)
p
## [1] 3.050719e-09
The probability is close to 0.
par(mfrow = c(1,2))
x <- 6000:12000
mean1 = 9000
sd1 = 1000
mean2 = 9000
sd2 = 1000/sqrt(15)
y1 <- dnorm(x, mean1, sd1)
y2 <- dnorm(x, mean2, sd2)
plot(x,y1,col="red")
plot(x,y2,col="black")
If it is slightly skewed - yes, otherwise we have to have larger sample.
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.
As sample size increase, the standard error decrease. Hence Z score will increase and p-value will decrease. Increasing sample size makes the hypothesis test more sensitive - more likely to reject the null hypothesis when it is, in fact, false. Thus, it increases the power of the test.