Instructions

  1. Update the author line at the top to have your name in it.
  2. You must knit this document to an html file and publish it to RPubs. Once you have published your project to the web, you must copy the web url link into the appropriate Course Project assignment in Blackboard before 11:59pm on the due date.
  3. Answer all the following questions completely. Some may ask for written responses.
  4. Use R chunks for code to be evaluated where needed and always comment all of your code so the reader can understand what your code aims to accomplish.
  5. Proofread your knitted document before publishing it to ensure it looks the way you want it to. Tip: Use double spaces at the end of a line to create a line break and make sure text does not have a header label that isn’t supposed to.
  6. DELETE ALL THESE INSTRUCTIONS BEFORE PUBLISHING YOUR DOCUMENT.

Purpose

In this project, students will demonstrate their understanding of the normal distribution, sampling distributions, and confidence intervals and hypothesis tests.


Question 1

Assume IQ scores are normally distributed with a mean of 100 and a standard deviation of 15. If a person is randomly selected, find each of the requested probabilities, using r chunks below. Here, x, denotes the IQ of the randomly selected person.

  1. P(x > 120)
pnorm(120, mean = 100, sd = 15, lower.tail = FALSE)
## [1] 0.09121122
  1. P(x < 120)
pnorm(120, mean = 100, sd = 15, lower.tail = TRUE)
## [1] 0.9087888

Question 2

  1. What is the probability that a random selected student will have an IQ between 80 and 120? (We haven’t explicitly learned this. Think about it though.)
1 - (pnorm(80,100,15,lower.tail = TRUE)+pnorm(120,100,15,lower.tail = FALSE))
## [1] 0.8175776
  1. Suppose that a random sample of 12 students is selected. What is the probability that their mean IQ is greater than 120?
pnorm(120,100,15,lower.tail = FALSE)
## [1] 0.09121122

Question 3

Load and store the sample NSCC Student Dataset using the read.csv() function. Find the mean and sample size of the PulseRate variable in this dataset and answer the question that follows below.

# Store the NSCC student dataset in environment
nsccstudents <- read.csv("nscc_student_data.csv")
# Find the mean pulse rate of this sample
mnpulse <- mean(nsccstudents$PulseRate,na.rm=TRUE)

#mean is 73.47368421

# Find the sample size of pulse rates (hint: its how many non-NA values are there)
sum(!is.na(nsccstudents$PulseRate))
## [1] 38
#sample size is 38 people excluding NA values

Do you think it is likely or unlikely that the population mean pulse rate for all NSCC students is exactly equal to that sample mean found?

it is extremely unlikely to get a mean that is exact to the sample, but it is likely that the population mean is similar to the sample mean.

Question 4

If we assume the mean pulse rate for all NSCC students is \(\sigma = 14\), construct a 95% confidence interval for the mean pulse rate of all NSCC students and conclude in a complete sentence below.
(Note: we can create a valid confidence interval here since n > 30)

# Store mean

    # I stored the mean for pulserate in question 3  

# Calculate lower bound of 95% CI
qnorm(0.025,mean = mnpulse, sd = 14)
## [1] 46.03419
# Calculate upper bound of 95% CI
qnorm(1-0.025,mean = mnpulse, sd = 14)
## [1] 100.9132
#we used the qnorm function to determine the upper and lower bounds of the confidence intervals. 

I am 95% confident that…
the average pulse rate among all NSCC students is between 46.03bpm and 100.91bpm.

Question 5

Construct a 99% confidence interval for the mean pulse rate of all NSCC students and conclude your result in a complete sentence below the R chunk.

# Calculate lower bound of 99% CI
qnorm(0.005,mean = mnpulse, sd = 14)
## [1] 37.41207
# Calculate upper bound of 99% CI
qnorm(1-0.005,mean = mnpulse, sd = 14)
## [1] 109.5353
#using the same function as in question 4, we have changed the p value to 0.005 to make a confidence level of 99%.

I am 99% confident that… the pulse rate of all NSCC students is between 37.41bpm and 109.54bpm.

Question 6

Describe and explain the difference you observe in your confidence interval results for questions 5 and 6.

With a larger confidence interval, we see a larger distance between the upper and lower bounds. it also makes sense that the differences between the bounds is roughly 9 bpm.

Question 7

In the Fall 2019 semester of the 2019-20 academic year, the average NSCC student took 12.3 credits with \(\sigma = 3.4\). I’m curious if that average differs among NSCC students last year (a sample of which is in the NSCC student dataset). Conduct a hypothesis test by a confidence interval to determine if the average credits differs last year from Fall 2019.

  1. Write the hypotheses (Try to emulate the “latex” format I used in lecture notes. Otherwise, just give your best effort.)

Ho: 12.3 = mu of nsccstudents

Ha: 12.3 != mu of nsccstudents

  1. Create confidence interval
# Calculate mean of Credits variable

mncredits <- mean(nsccstudents$Credits)
sdcredits <- sd(nsccstudents$Credits)

# Calculate sample size of Credits variable

sum(!is.na(nsccstudents$Credits))
## [1] 40
# Lower bound of 95% CI

qnorm(0.025,mncredits,sdcredits)
## [1] 5.169505
# Upper bound of 95% CI
qnorm(1-0.025,mncredits,sdcredits)
## [1] 18.3805
  1. Make decision to reject H0 or fail to reject H0 based on confidence interval

We fail to reject Ho due to the fact that the average credits taken was well within the confidence interval of the current data.

  1. Write a concluding statement

the amount of credits taken is very similar to how it was in 2019-2020. with there being little difference.

Question 8

NSCC is investigating whether NSCC students have a higher than average stress level which can be identified by a higher than average standing pulse rate. Conduct a hypothesis test by the p-value method to determine if NSCC students have a higher pulse rate than the national average of 72 bpm for adults. Recall the assumption that \(\sigma = 14\) for NSCC student pulse rates.

  1. Write the hypotheses (You may try to emulate the LaTex format I used in lecture notes. Otherwise, just give your best effort.)

HO: mu = 72bpm HA: mu != 72 bpm

  1. Calculate p-value of getting sample data by chance
# Calculate mean of PulseRate variable

    #mean was calculated in question 3 as mnpulse value
# Probability of getting that sample data by random chance if pop mean was indeed 72bpm
pnorm(mnpulse,72,14)
## [1] 0.5419165
  1. Make decision to reject H0 or fail to reject H0 at a significance level of 0.05 based on p-value.

fail to reject HO

  1. Write a concluding statement

The stress levels of NSCC students, as recorded by pulse rate, is very similar to the national average of 72bpm.