Hypothesis and Correlation Analysis

Unfortunately this week, I wasn’t able to complete my assignment. However, I have taken the time to study the class, and use some of the responses from the professor. Here is the questions and answers.

First Question:

The director of manufacturing at a cookies needs to determine whether a new machine is production a particular type of cookies according to the manufacturer’s specifications, which indicate that cookies should have a mean of 70 and standard deviation of 3.5 pounds. A sample pf 49 of cookies reveals a sample mean breaking strength of 69.1 pounds.
A. State the null and alternative hypothesis _______

H0

The new machine is producing a particular type of cookie according to the manufacturer’s specifications, and the mean breaking strength is 70 pounds (μ >= 70)

HA

The new machine is not producing a particular type of cookie according to the manufacturer’s specifications, and the mean breaking strength is not equal to 70 pounds (μ < 70)


B. Is there evidence that the machine is nor meeting the manufacturer’s specifications for average strength? Use a 0.05 level of significance _______ 

Yes, there is evidence

Given data:

•          Sample size (n) = 49

•          Sample mean (x̄) = 69.1 pounds

•          Population standard deviation (σ) = 3.5 pounds

We will use a z-test because we know the population standard deviation. The test statistic (z) can be calculated as follows:

Z = (x̅ – μ) / (σ /√n)

Let’s calculate in R

#One-Tailed Tests About a Population Mean:s Known in R

# Given data

u0 <- 70      ## μ0 is the hypothesized population mean under the null hypothesis,

sigma <- 3.5  ## σ is the population standard deviation,

n <- 49       ## n is the sample size,

xbar <- 69.1  ## x̅  is the sample mean.

zvalue <- (xbar – u0) / (sigma/sqrt(n))

zvalue

[1] -1.8

#We then compute the critical value at .05 significance level.

alpha <- 0.05

zvalue.alpha = qnorm(1-alpha)   ## calculate the critical value for one-tailed

-zvalue.alpha                                ## critical value

[1] -1.644854

C. Compute the p value and interpret its meaning _______

p_value <-  pnorm(zvalue, lower.tail = TRUE)

p_value

[1] 0.03593032

2 * pnorm(zvalue.alpha) ## using the calculation similar to the solution. Need more info

[1] 1.9

Depending on the correct answer, the p-value 0.036 is less than alpha, then, I will reject  H0.

According to the answer provided by the instructor, I would reject HA.

(I will need more explanation on this one)

D. What would be your answer in (B) if the standard deviation were specified as 1.75 pounds?______
It would have been the same answer. Rejecting the NULL Hypotheses

E. What would be your answer in (B) if the sample mean were 69 pounds and the standard deviation is 3.5 pounds? ______
The same as of D


Second Question:

If x̅ = 85, σ = standard deviation = 8, and n=64, set up 95% confidence interval estimate of the population mean μ.

> # Given values

> xbar <- 85

> sigma <- 8

> n <- 64

> confidence_level <- 0.95  # 95% confidence level

> # Calculate the critical value (Z) for a 95% confidence level

> critical_value <- qnorm((1 + confidence_level) / 2)

> # Calculate the margin of error

> margin_of_error <- critical_value * (sigma / sqrt(n))

>

> # Calculate the confidence interval

> lower_bound <- xbar – margin_of_error

> upper_bound <- xbar + margin_of_error

> # Print the confidence interval

> cat(“95% Confidence Interval for μ: (“, lower_bound, “, “, upper_bound, “)”)

95% Confidence Interval for μ: ( 83.04004 ,  86.95996 )

Thirds Question:

Third Question using Correlation Analysis

The correlation coefficient analysis formula:

(r) =[ nΣxy – (Σx)(Σy) / Sqrt([nΣx2 – (Σx)2][nΣy2 – (Σy)2])]

r: The correlation coefficient is denoted by the letter r.

n: Number of values. If we had five people we were calculating the correlation coefficient for, the value of n would be 5.

x: This is the first data variable.

y: This is the second data variable.

Σ: The Sigma symbol (Greek) tells us to calculate the “sum of” whatever is tagged next to it.


In R 
x < – c(your data)
y<- c(your data) 
z<- c(your data)
df<-data.frame(x,y,z) plot
cor(x,y,z)
cor(df,method=”pearson”) #As pearson correlation
cor(df, method=”spearman”) #As spearman correlation
Use corrgram( ) to plot correlograms .


Your assignment for Correlation Analysis

The accompanying data are: x= girls and y =boys. (goals, time spend on assignment)  
a. Calculate the correlation coefficient for this data set _____
b. Pearson correlation coefficient _____
c. Create plot of the correlation

The answer with the help of the Professor:

mydata <- read_excel(“C:/Users/yuorname/Desktop/USF-FALL2023/LIS4273_R_Scripts/Sources/Module # 5.xls”)

> x <- c(mydata[[2]][5],mydata[[3]][5],mydata[[4]][5])

> x

[1]  92 108 135

>

> y <- c(mydata[[2]][12],mydata[[3]][12],mydata[[4]][12])

>

> y

[1]  95.9 113.0 141.0

>

> z <- c(mydata[[2]][11],mydata[[3]][11],mydata[[4]][11])

> z

[1] 18.9 22.2 27.8

>

> df <- data.frame(x,y,z)

>

> df

    x     y    z

1  92  95.9 18.9

2 108 113.0 22.2

3 135 141.0 27.8

>

> #cor(x,y,z)

> cor(df,method = “pearson”)

          x         y         z

x 1.0000000 0.9999681 0.9999989

y 0.9999681 1.0000000 0.9999552

z 0.9999989 0.9999552 1.0000000

> cor(df,method = “spearman”)

  x y z

x 1 1 1

y 1 1 1

z 1 1 1

>

> df1  <-data.frame(x,y)

> cor(x,y)

[1] 0.9999681

>

> #pearson  method

>

> cor(df1,method = ‘pearson’)

          x         y

x 1.0000000 0.9999681

y 0.9999681 1.0000000

> #library(“corrgram”)

> corrgram(df1)

Leave a comment