HYPOTHESIS TESTING IN R

NULL & ALTERNATE HYPOTHESIS, ERROR TYPES, T-TEST
1

R

MEDIUM

last hacked on Jan 24, 2019

Null and Alternate Hypothesis

Null Hypothesis: `Ho`

This is your default assumption or belief.

Alternate Hypothesis: `H1`

Notion that is rival to our default assumption or belief.

We attempt to test, statistically, whether `Ho` is `True`, or `False`.

From our data analysis, we then proceed to either not reject or reject our `Ho`. If we reject `Ho`, we do so in favor of `H1`; and vice-versa.

Type I and II Errors

We can make mistakes while choosing to reject or not reject, however; and this is why we have `Type I` and `Type II` errors.

When `Ho` is `True`

• If we do not reject `Ho`, then we are making the correct decision.

• If we reject the null hypothesis, then we are making the `Type I` error.

When `Ho` is `False`

• If we reject `Ho`, then we are making the correct decision.

• If we do not reject `Ho`, then we are making the `Type II` error.

Implementation

We will employ the Student's t-Test to determine whether we should either reject or not reject `Ho`.

Specifically, we will use the `t.test()` function. Before diving in, let's take a look at a preview of docs:

``````?t.test
``````
``````t.test {stats}  R Documentation
Student's t-Test

Description

Performs one and two sample t-tests on vectors of data.

Usage

t.test(x, ...)

## Default S3 method:
t.test(x, y = NULL,
alternative = c("two.sided", "less", "greater"),
mu = 0, paired = FALSE, var.equal = FALSE,
conf.level = 0.95, ...)

...

``````

Now let's mock a data set, called `test_data1`. Next, we will compute its `t.test`.

``````test_data1 <- c(55, 60, 62, 63, 65, 66, 68, 69, 70, 71, 75, 80)
t.test(test_data1)
``````
``````One Sample t-test

data:  test_data1
t = 34.357, df = 11, p-value = 1.522e-12
alternative hypothesis: true mean is not equal to 0
95 percent confidence interval:
62.70778 71.29222
sample estimates:
mean of x
67
``````

Here, (having provided no further arguments) our `alternative hypothesis` is such that the `true mean is not equal to 0`. More elegantly:

• `H1` (alternative hypothesis) : `true mean is not equal to 0`, therefore:
• `Ho` (null hypothesis) : `true mean is equal to zero`.

Since our p-value is less than `.05`, we reject `Ho`.

Therefore we are accepting our alternate hypothesis, which is that our true mean is not equal to 0.