Load OpenIntro dataset library

if (!require("openintro")) install.packages("openintro")
## Loading required package: openintro
## Warning: package 'openintro' was built under R version 4.4.2
## Loading required package: airports
## Warning: package 'airports' was built under R version 4.4.2
## Loading required package: cherryblossom
## Warning: package 'cherryblossom' was built under R version 4.4.2
## Loading required package: usdata
## Warning: package 'usdata' was built under R version 4.4.2
library(openintro)

One Population Mean when Population Standard Deviation (\(\sigma\)) is Known

#Question The average gasoline price of one of the major oil companies has been $1.50 per gallon. Because of cost reduction measures, it is believed that there has been a significant reduction in the average price. To test this belief, we randomly selected a sample of 36 of the company’s gas stations and determined that the average price for the stations in the sample was $1.40. Assume that the standard deviation of the population (\(\sigma\)) is $0.12.

Let \(\alpha = .05\).

#Work Step 1: Prepare H0:mu>=1.50 Ha:mu>1.50 x-bar:1.40

Identify the parameter of interest, list out hypotheses, identify the significance level, and identify \(\bar{x}\), \(\sigma\), and \(n\).

\(H_0:\mu \ge 1.50\); \(H_1:\mu\ < 1.50\)

Step 2: Check

Verify conditions to ensure \(\bar{x}\) is nearly normal.

\(n < 30\): If the sample size n is less than 30 and there are no clear outliers in the data, then we typically assume the data come from a nearly normal distribution to satisfy the condition.

\(n \ge 30\): If the sample size n is at least 30 and there are no particularly extreme outliers, then we typically assume the sampling distribution of \(bar{x}\) is nearly normal, even if the underlying distribution of individual observations is not.

Since for this example, \(n = 36\), we can assume the normality of \(\bar{x}\).

Step 3: Specify the significance level: \(\alpha=0.05\).

Step 4: Calculate

If the conditions hold, compute SE, compute the z-stat ZT, and identify the p-value.

Z stat

#Standard Error
SE = .12/sqrt(36)
#Z statistics
ZT = (1.40-1.50)/SE
ZT
## [1] -5

For a one-tailed test, the p-value is \(p(z \ge 1.50)\)

#The pvalue is
pvalue = pnorm(ZT,0,1,lower.tail=TRUE)
pvalue
## [1] 2.866516e-07

Step 5: Conclude

Evaluate the hypothesis test by comparing the p-value to \(\alpha\), and provide a conclusion in the context of the problem. State the conclusion and interpret the results.

Since p_value (2.8665151879187e-07) < \(\alpha\) (0.05), reject the null hypothesis. At the 5% significance level, we can conclude that average price for gas differs from $1.50 per gallon. The sample data does support the oil companies claim.