Hypothesis Testing and Correlation Analysis Using R



Welcome!

Today we will be Hypothesis Testing and Correlation Analysis using R programming 

1. 

A.

State the null and alternative hypothesis:

  • Null Hypothesis (H0H_0): μ=70\mu = 70
  • Alternative Hypothesis (H1H_1): μ70\mu \neq 70


  • B.

    Given Data:

    • Population mean a=70a = 70
    • Sample mean xbar=69.1xbar = 69.1
    • Standard deviation s=3.5s = 3.5
    • Sample size n=49n = 49
    R Code to Calculate the Test Statistic and p-value:
    INPUT:
    OUTPUT:



    • Calculated z-score:
      • From running the above R code, you'll find that the Z-score is -1.8
    • Calculated p-value:
      • From running the above R code, you'll find that the p-value is approximately 0.07
    Since p-value≈0.0718>0.05 , we fail to reject the null hypothesis. There is not enough evidence to conclude that the machine is not meeting specifications.

    C.
    Explanation:

    The p-value of approximately 0.0718 indicates that there is a 7.18% probability of observing a sample mean as extreme as 69.1 pounds (or more extreme) if the null hypothesis is true. Since this is greater than the significance level (0.05), we do not have enough evidence to reject the null hypothesis.

    D.

    What if the standard deviation were specified as 1.75 pounds?

    Update the standard deviation in R code:

    s <- 1.75  

    INPUT:

    OUTPUT:



    • Calculated z-score:−3.6

    • p-value: The p-value will be much lower than 0.05.

    Since z=3.6<1.96z = -3.6 < -1.96, we reject the null hypothesis. There is evidence that the machine is not meeting specifications.

    E.

    What if the sample mean were 69 pounds and the standard deviation is 3.5 pounds?

    Update the sample mean in R code:

    xbar <- 69   
    INPUT:

    OUTPUT:

  • Calculated z-score−2

  • Calculated p-value: 0.0455

  • Since z=2<1.96, we reject the null hypothesis. There is evidence that the machine is not meeting the manufacturer's specifications.

    2. 

    Set up a 95% confidence interval estimate of the population mean μ\mu

    Given Data:

    • Sample mean x̅ = 85
    • Standard deviation σ=8\sigma = 8
    • Sample size n=64n = 64

    R Code to Calculate the Confidence Interval:

    INPUT:

    OUTPUT:

    • Lower limit: 83.04
    • Upper limit: 86.96


    • Confidence Interval: 
    (83.04,86.96)

    3. 

    Our Data Set:

    Let's perform a Correlation Analysis on this data set:


    Results:

    Now let's calculate the correlation coefficient for this data set:
    Results : 





    Correlation Coefficient (Pearson's r):

    • Girls: 0.982
    • Boys: 0.989





    Comments