Chi-Square Practice

Instructions

Complete the following questions about testing for independence between 2 categorical variables. When completed, Render the qmd file and submit the html.

Aussie Alcohol

A small study in Western Australia was done to determine the association between daily alcohol intake and hypertension (high blood pressure). The data contains a hypertension indicator (0=no, 1=yes), and the number of alcoholic drinks per day. Researchers wanted to determine if hypertension and daily alcohol intake are independent with a level of significance of 0.05.

Run the following commands to read the data into R:

# This script will flip the summary data table to be easily used with geom_col()
library(rio)
library(tidyverse)
library(mosaic)
library(car)

bp_alcohol <- import("https://byuistats.github.io/M221R/Data/quiz/R/bp_alcohol.csv") 

## Note:  the following code transforms a table into a tidy dataset

bp_alcohol_graph <- bp_alcohol %>% 
  pivot_longer(cols = c( "zero", "one_two", "three_four_five", "six_or_more" ), values_to = "Counts", names_to = "Frequency_of_Drink") %>%
  mutate(Frequency_of_Drink = factor(Frequency_of_Drink, levels=c("zero", "one_two","three_four_five", "six_or_more"))) %>%
  rename("Hypertension"=V1)

Create a side-by-side bar chart (ggplot()) to illustrate the counts.

Question: Which group appears to be most likely to have hypertension?
Answer:

State the Null and Alternative Hypotheses:

H0:
Ha:

Hypothesis Test

Perform the Chi-square test for independence:

HINT: The way the data were imported into bp_alcohol, it contains a columns, V1, which is a categorical variable. You only want to include the counts from the table. Run chisq.test() dropping the first column. Also, remember to name the output so you can easily extract information needed to check the requirements.

Question: Are the requirements satisfied for the \(\chi\)-square test for independence?
Answer:

Question: How many degrees of freedom does this \(\chi\)-square test have?
Answer:

Question: What is the value of the test statistic?
Answer:

Question: What is the P-value?
Answer:

State your conclusion in context of thise problem: