title: “Chapter 5 - Foundations for Inference” author: “Sufian” output: html_document: df_print: paged pdf_document: extra_dependencies: - geometry - multicol - multirow word_document: default
Rpubs Link:
http://rpubs.com/ssufian/533680
Githut Link:
https://github.com/ssufian/Data_606
Heights of adults. (7.7, p. 260) 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.
ans:
mean = 171.1438
median = 170.3
head(bdims$hgt)
## [1] 174.0 175.3 193.5 186.5 187.2 181.5
meanhgt <- mean(bdims$hgt)
meanhgt
## [1] 171.1438
medianhgt <- median((bdims$hgt))
medianhgt
## [1] 170.3
ans:
sdhgt = 9.407
IQR = 14
sdhgt <- sd(bdims$hgt)
sdhgt
## [1] 9.407205
IQR(bdims$hgt, na.rm = T)
## [1] 14
# to confirm only
Q3 <- quantile(bdims$hgt, 0.75)
Q1 <- quantile(bdims$hgt, 0.25)
print (Q3 - Q1)
## 75%
## 14
ans:
No, not really on the tall guy as he is still falls within the 95% confidence interval. HOwever, the
short guy falls outside the lower interval, so he/she is considered short
# data looks normal
#95% confidence interval
twoSDpos <- meanhgt + 2*sdhgt
twoSDneg <- meanhgt - 2*sdhgt
# the high end of the confidence interval
twoSDpos
## [1] 189.9582
# the low end of the confidence interval
twoSDneg
## [1] 152.3294
#68% confidence interval
twoSDpos1 <- meanhgt + 1*sdhgt
twoSDneg1 <- meanhgt - 1*sdhgt
# the high end of the confidence interval
twoSDpos1
## [1] 180.551
# the low end of the confidence interval
twoSDneg1
## [1] 161.7366
ans:
The theoretical normal plot showed that they are all quite normal; the more closely the bars fill the blue
curve, the more normal the distribution. So I would expect that the means and std devs. of the
other samplings should be very similar to the ones from the original set.
hist(bdims$hgt, probability = TRUE)
x <- 140:200
y <- dnorm(x = x, mean = meanhgt, sd = sdhgt)
lines(x = x, y = y, col = "blue")
(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_x = \frac{\sigma}{\sqrt{n}}$)? Compute this quantity using the data from the original sample under the condition that the data are a simple random sample.
sd_x <- sdhgt/sqrt(nrow(bdims))
sd_x
## [1] 0.4177887
ans:
std error = 0.417
Thanksgiving spending, Part I. 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.
## spending
## 1 52.84612
## 2 187.55311
## 3 63.87256
## 4 195.56842
## 5 120.78929
## 6 63.26765
ans:
FALSE - We are 95% confident that the average spending of the population (not the sample itself) is
between $80.31 and $89.11.
ans:
FALSE - With 436 observations in the sample > 30, the sample size is large enough to offset the skew
in the data.
ans:
FALSE - the confidence interval refers to the population mean, not the sample mean.
ans:
True
ans:
True
False
The margin of error is the difference between the upper bound of the confidence interval and the mean:
89.11−84.71=4.4
From the margin of error, the standard error:
4.4=84.71+1.96SE
SE=2.24
standard error to find the standard deviation of the sample: SE=\(s/sqrt(n)\)
s = 47
In order to reduce the margin of error by 1/3:
1/3(2.24) = 0.747
needed sample size is therefore:
0.747 = 46.77/sqrt(n)
solving for n:
n = 3920, which is about 9 times
True
Gifted children, Part I. Researchers investigating characteristics of gifted children col- lected 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 dis- tribution of the ages (in months) at which these children first counted to 10 successfully. Also provided are some sample statistics.
ans:
Yes the sampling was random, sample size > 30 and the distribution nearly normal without any skewness
ans:
Performed a one-sided hyptothesis test:
H0 : \(\mu\) = 32
HA : \(\mu\) < 32
Calculating the SE:
given std. Dev. (sd) = 4.31
given n = 36
SE = sd/sqrt(n) = 4.31/sqrt(36) = 0.7183
To calculate Z-score:
$Z_{30.69} $= (30.69-32)/0.7183 = -1.82
P(Z<-1.82) = 0.034, see R code below
normalPlot(0,1,c(-Inf,-1.82))
ans:
\(\alpha\) = 0.1 but since the calculated p-value < 0.1 whch is 0.034, we reject the null hypothesis of Ho
therefore, we can with 90% confidence believe there’s evidence that gifted kids start reading before 32
months old
ans:
CIupper=30.69+1.645(0.7183)≈31.87
CIlower=30.69−1.645(0.7183)≈29.51
ans:
Yes, because the interval does Not contain 32 months old
Gifted children, Part II. Exercise above 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.
ans:
Perfom a two-sided test:
H0 : \(\mu\) = 100
HA : \(\mu\) != 100
Calculating the SE:
given std. Dev. (sd) = 6.5
given n = 36
SE = sd/sqrt(n) = 6.5/sqrt(36) = 1.083
To calculate Z-score:
$Z_{118.2} $= (118.2-100)/1.083 = 16.80
P(Z!=16.80) = 0 , see R code below
normalPlot(0,1,c(16.8,Inf))
normalPlot(0,1,-Inf, 16.8)
ans:
CIupper =118.2+1.645(1.083)≈119.98
CIlower=118.2−1.645(1.083)≈116.42
ans:
\(\alpha\) = 0.1, based on calculated p-value of 0.0 , we reject the null hypothesis and beleive that there
are enough evidience at the 90% confidence level the IQ is Not 100. The CLT do not contain 100 IQ.
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.
ans:
Sampling distribution means taking n samples from the population and measuring the means of these samples
These samples’ means which in itself has a distribution; therefore the term sampling distribution. The
shape, center and spread of the mean changes as sample size increase. The greater the sample size, the
more “bell-shape” the distribution becomes or in other words, the shape becomes more normal, the center
approaches the true population mean, and the spread decreases..
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.
ans:
\(Z_{10500}\) = (10500-9000)/1000 = 1.5
P(X>10500) = 0.0668, see below
normalPlot(0,1,c(1.5,Inf))
ans:
The distribution of the sample mean of 15 light bulbs is
N(9000,1000/sqrt(15))=
=N(9000,258.20)
ans:
\(Z_{10500}\) = (10500-9000)/258.2 = 5.81
P(Z>5.81) = 0, see below
normalPlot(0,1,c(5.81,Inf))
ans:
x <- 5000:13000
y1 <- dnorm(x, 9000, 1000)
y2 <- dnorm(x, 9000, 258)
plot(x,y1,type="l",col="blue")
lines(x,y2,col="yellow")
ans:
A normal distribution is required to use the Z-score. For part (c), the sample size needs to be greater
use the z-score (parametric studies); a normal distribution.
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.
ans:
The SE decreases as n increases. If SE decreases, the Z score increases and the rejection region becomes
smaller; when the area of rejection gets smaller, the p-value also decreases