<jupyter_start><jupyter_text>Heart attacks Among Navajo Indians**Date:** 2021-12-01**Reference:** M249, Book 1, Part 2<jupyter_code>suppressPackageStartupMessages(library(tidyverse))
library(R249)
library(DescTools)<jupyter_output><empty_output><jupyter_text>Summary  Get the data<jupyter_code>(dat <- as_tibble(read.csv(file = "..\\..\\data\\navajoindians.csv")))<jupyter_output><empty_output><jupyter_text>Prepare the dataCast the `cases`, `controls` columns to factors.<jupyter_code>labexp <- c("no diabetes", "diabetes")
(sorteddat <- dat %>%
    mutate(cases = factor(dat$cases, labexp)) %>%
    mutate(controls = factor(dat$controls, labexp)) %>%
    arrange(cases, controls))<jupyter_output><empty_output><jupyter_text>Pull the `count` column as a vector and initilise a matrix.<jupyter_code>datmat <- sorteddat$count %>%
    matrix(nrow = 2, ncol = 2, dimnames = list(labexp, labexp))
print(datmat)<jupyter_output>no diabetes diabetes
no diabetes          82       37
diabetes             16        9<jupyter_text>Mantel-Haenszel odds ratioCalculate the odds ratio.<jupyter_code>oddsratio_matched(datmat)<jupyter_output><empty_output><jupyter_text>McNemar's test for no association<jupyter_code>mcnemar.test(datmat)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1332801276935355, 'fraction_numerical': 0.019952114924181964, 'mean_word_length': 6.646341463414634, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '505024', 'license': 'MIT', 'n_tokens_mistral': 472, 'n_tokens_neox': 436, 'n_words': 76, 'path': 'jupyter/1_medical_statistics/1_06_matched_casecon.ipynb', 'repo_name': 'ljk233/R249', 'size': '1253'}