01February24

Hypothesis Testing

This is a presentation on Hypothesis Testing, using the dataset Trees

Steps of Hypothesis Testing

Step 1:
Determine the Research Question/Hypotheses
    -What is you null hypothesis (Ho), and your alternative hypothesis (Ha)
Step 2:
Preform an appropriate statistical test
Step 3:
Decide whether to reject or fail to reject null hypothesis
Step 4:
Report your conclusion with context to the problem

Step 1: Determine the Hypotheses

    -Ho: There is no correlation between a tree’s girth and volume.

    -Ha: There is a correlation between a tree’s girth and volume.

We test the null hypothesis to determine if there is enough evidence to reject it, and if there is, we favor the alternative hypothesis. Rejecting the null hypothesis suggests the alternative hypothesis may be correct.

Graph of Tree Girth vs Volume

Code of Graph

mod = lm(Volume ~ Girth, data=trees)
x = trees$Girth; y = trees$Volume
xax <- list(
  title ="Girth",
  titlefont = list(family="Modern Computer Roman"))
yax <- list(
  title = "Volume",
  titlefont = list(family="Modern Computer Roman"),
  range = c(0,80))
fig <- plot_ly(x=x, y=y, type="scatter", mode="markers", name="data point",
               width=800, height=430) %>%
               add_lines(x = x, y = fitted(mod), name="line of best fit") %>%
               layout(xaxis = xax, yaxis = yax) %>%
               layout(margin=list(
                 l=150,
                 r=50,
                 b=20,
                 t=40 ))
config(fig, displaylogo=FALSE)

Step 2: Preform an appropriate statistical test

Calculate the correlation coefficient (R) with the following formula

\({r = {{\sum(Xi - \bar{x}) (Yi - \bar{y})} \over \sqrt{\sum(Xi - \bar{x})^2 (Yi - \bar{y})^2}}}\)

Breakdown of the Correlation Coefficient

X Values
\(\sum = 410.7\)
\(\bar{X} = 13.248\)
\(\sum(x-\bar{x})^2 = SSx = 295.437\)

Y Values
\(\sum = 935.3\)
\(\bar{Y} = 30.171\)
\(\sum(y-\bar{y})^2 = SSy = 8106.084\)

X and Y combined
\(N = 31\)
\(\sum(X-\bar{X})(Y-\bar{Y})=1496.644\)

Step 3: Decide whether to reject or fail to reject null hypothesis

Do you accept or reject the Ho?

The value of our correlation coefficient is
\(R = 0.9671\)
This means there is a strong positive correlation between a tree’s girth and its volume.
Thus, we reject the null hypothesis.

GGplot of Tree Data

GGplot of Tree Data

with line of regression and confidence interval

## `geom_smooth()` using formula = 'y ~ x'

Step 4: Report your conclusion with context to the problem

With our R value being so close to one, we can confidently say that there is a strong positive correlation between a tree’s girth and its volume. So we reject our null hypothesis.