Graded: 4.4, 4.14, 4.24, 4.26, 4.34, 4.40, 4.48
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.
##
## Attaching package: 'DATA606'
## The following object is masked from 'package:utils':
##
## demo
Heights of adults. 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? Point Estimate is the sample mean which is 171.1, Median is 170.3
What is the point estimate for the standard deviation of the heights of active individuals? Ans: 9.4 What about the IQR? Q3- Q1 = 177.8 - 163.8 = 14
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.
Lets calculate the confidence interval range. \[ S.d = \frac{9.4}{\sqrt{1}} = 9.4 \] \[ 171.1 \pm 2 * 9.4 = (152.3,189.9)\]
A person who is 1m 80cm (180 cm) tall is not considered unusually tall because it is below the max range of the confidence interval (189.9) while the person 155cm is not considered unusually short because it is above the min range of the confidence interval (152.3)
I expect them to a bit different because it is just the nature of random sampling, however, they will be somewhat close to the orginal values
\[ Standard Error = \frac{9.4}{\sqrt{507}} = 0.417 \] \[ Margin of Error = 2 * 0.417 = 0.834 \]
Thanksgiving spending, Part I. The 2009 holiday retail season, which kicked o??? 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.
False because the confidence interval is used to infer the mean range for the population not the sample. We are 95% confident that the average spending of American adults is between $80.31 and $89.11
False, the confidence interval is valid because the n >30 so it makes the sample size large enough to compensate for skew
False, because the random samples can have any mean that might be representative of the true population. However, it should be that 95% of the intervals generated from random sampling will contain the true mean of the population
True, this is the correct definition of confidence interval
True, the 90% interval is the range under the normal distribution that is less than 2 Standard deviations. It tries to narrow down or pin point the most likely true population mean, risking the fact that we might miss it completely 10% of the time
False, we need to use a sample that is 9 times larger because the square root of n x 9 will be 3 sqrt(n). this decreases the margin of error by 3 folders
True, because Point estimate + Margin of error = High interval mark Margin of error = 89.11-84.71 = 4.4
Gifted children, Part I. 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.43
Yes, because random sampling was used, and since the distribution is skewed n had to be greater than 30
Set Hypothesis
Ho : Average age that Children first count to 10 successfully is 32 months (Mu = 32)
Ha : Average age that Children first count to 10 successfully is less than 32 months (Mu < 32)
Point Estimate
Sample mean = 30.69
Check that we can make inference Yes, because random sampling was used, and since the distribution is skewed n had to be greater than 30
Draw the sampling distribution
x <- seq(27,37,length=1000)
y <- dnorm(x,mean=32, sd=4.31/sqrt(36))
plot(x,y, type="l", lwd=1)
x=seq(27,30.69,length=100)
y=dnorm(x,mean=32, sd=4.31/sqrt(36))
polygon(c(27,x,30.69),c(0,y,0),col="red")
Test Statistics
Z = (Point_estimate - Hypthosis_Mean)/Standard_Error = (30.69 -32)/0.7183333
(30.69 -32)/0.7183333
## [1] -1.823666
Probabily (Z <-1.82) = 0.0344 p values = 0.0344 is less than 0.10 which is the 90% confidence interval
With this result we Reject the null Hypothesis in favor of the alternative.
These data provide convincing evidence that Average age that Children first count to 10 successfully is less than 32 months (Mu < 32)
These data provide convincing evidence that Average age that Children first count to 10 successfully is less than 32 months (Mu < 32)
the Standard deviation that corresponds to 90 percentile is Z = 1.65
\[90% confidence interval = 30.69 \pm 1.65 * 0.7183 \] (29.5, 31.875)
Yes because they agree because the Hypothetical mean is outside the 90% confidence interval so is the p value is less than significance level
Gifted children, Part II. 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.
Set Hypothesis
Ho : Average IQ of Mothers of gifted children is the same as the average IQ for the population (Mu_gifted = 100)
Ha : Average IQ of Mothers of gifted children is greater than the average IQ for the population (Mu_gifted > 100 )
Point Estimate
Sample mean = 118.2
Check that we can make inference
Yes, because random sampling was used, and the distribution is normal with n greater than 30
Draw the sampling distribution
x <- seq(80,120,length=1000)
y <- dnorm(x,mean=100, sd=6.5/sqrt(36))
plot(x,y, type="l", lwd=1)
x=seq(118.2,120,length=100)
y=dnorm(x,mean=100, sd=6.5/sqrt(36))
polygon(c(118.2,x,120),c(0,y,0),col="red")
Test Statistics
Z = (Point_estimate - Hypthosis_Mean)/Standard_Error = (118.2 -100)/1.083333
(118.2 -100)/1.083333
## [1] 16.80001
Probabily (Z > 16.8) = 1-1 =0 p values = 0.000 is less than 0.10 which is the 90% confidence interval
With this result we Reject the null Hypothesis in favor of the alternative.
These data provide convincing evidence that Average IQ of Mothers of gifted children is greater than the average IQ for the population (Mu > 100)
the Standard deviation that corresponds to 90 percentile is Z = 1.65
\[90% confidence interval = 118.2 \pm 1.65 * 1.0833 \] (116.4, 119.98)
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.
“sampling distribution” of the mean is the distribution of random sample of the population to get the true population mean.
As the sample size increases, the distribution is nearly normal centered and symmetric.
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. (a) What is the probability that a randomly chosen light bulb lasts more than 10,500 hours?
Normal distribution for Light bulbs is \[ N ( \mu = 9000, \sigma = 1000 ) \]
Probability of randomly chosen a light bulb that last mORE THAN 10500 \[ Zscore = \frac{(Obs - \mu)}{\sigma} \]
(10500-9000)/1000
## [1] 1.5
normalPlot(mean = 9000, sd = 1000, bounds=c(10500,14000), tails = FALSE)
p(Z>1.5) = 1- P(Z=1.5)
1-pnorm(1.5)
## [1] 0.0668072
Probability is 0.0668
The population SD is known and the data are nearly normal, so the sample mean will be nearly normal with distribution N(??, !/pn), \[ N ( \mu = 9000, \sigma = \frac{1000}{\sqrt{15}} ) \] \[ N ( \mu = 9000, \sigma = 258.2 ) \]
\[ P(Z> \frac{X - \mu}{SE}) \] \[ P(Z> \frac{10500 - 9000}{258.2}) \] \[ P(Z> 5.81) = 0 \]
mean_v <- 9000
sd_v <-1000
x <- seq(mean_v - 3*sd_v,mean_v + 3*sd_v,length=1000)
y <- dnorm(x,mean=mean_v, sd=sd_v)
y2 <- dnorm(x, mean=9000,sd=258.2)
plot(x,y, type="l", lwd=1,ylim = c(0,0.002))
lines(x,y2, col = "red")
legend(10000,0.002, c("Population","Sampling (n=15)") , lty=c(1,1), lwd=c(2.5,2.5),col=c("black","red"))
We could not estimate a) because the probability we used is based on Z score table that tells us the probability for a normally distributed population We could also not estimate c) because our sample population distribution must be nearly normal and random to justify the use of the Z score table. The sample size in this case is very small so we can’t afford to approximate it to be a normal distribution
Same observation, di???erent 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
p=value will decrease because based on the formula, the increase n will lead to decrease in p-value.