janitor, dplyr, gtsummary, rstatix, and base
Evans <- read_csv("Evans.csv")
Evans <- read_csv("Evans.csv")
Evans$chd = as.character(Evans$chd)
Evans$chd = factor(Evans$chd)
Evans$chd = if_else(Evans$chd == "1", "y", "n")
shapiro.test(Evans$age)
##
## Shapiro-Wilk normality test
##
## data: Evans$age
## W = 0.94475, p-value = 2.765e-14
shapiro.test(Evans$chl)
##
## Shapiro-Wilk normality test
##
## data: Evans$chl
## W = 0.98575, p-value = 1.153e-05
shapiro.test(Evans$sbp)
##
## Shapiro-Wilk normality test
##
## data: Evans$sbp
## W = 0.91819, p-value < 2.2e-16
shapiro.test(Evans$dbp)
##
## Shapiro-Wilk normality test
##
## data: Evans$dbp
## W = 0.95458, p-value = 9.367e-13
shapiro.test(Evans$dbp)
##
## Shapiro-Wilk normality test
##
## data: Evans$dbp
## W = 0.95458, p-value = 9.367e-13
shapiro.test(Evans$sbp)
##
## Shapiro-Wilk normality test
##
## data: Evans$sbp
## W = 0.91819, p-value < 2.2e-16
Evans %>%
group_by(chd) %>%
summarise(
p25 = quantile(sbp, probs = 0.25, na.rm=T),
p50 = quantile(sbp, probs = 0.5, na.rm=T),
p75 = quantile(sbp, probs = 0.75, na.rm=T)
)
## # A tibble: 2 Ă— 4
## chd p25 p50 p75
## <chr> <dbl> <dbl> <dbl>
## 1 n 124 140 158
## 2 y 136. 152 164
wilcox.test(sbp ~ chd, data = Evans)
##
## Wilcoxon rank sum test with continuity correction
##
## data: sbp by chd
## W = 14260, p-value = 0.0005143
## alternative hypothesis: true location shift is not equal to 0
Evans %>%
group_by(chd) %>%
summarise(
p25 = quantile(dbp, probs = 0.25, na.rm=T),
p50 = quantile(dbp, probs = 0.5, na.rm=T),
p75 = quantile(dbp, probs = 0.75, na.rm=T)
)
## # A tibble: 2 Ă— 4
## chd p25 p50 p75
## <chr> <dbl> <dbl> <dbl>
## 1 n 80 90 98
## 2 y 85 94 104.
wilcox.test(dbp ~ chd, data = Evans)
##
## Wilcoxon rank sum test with continuity correction
##
## data: dbp by chd
## W = 15172, p-value = 0.004786
## alternative hypothesis: true location shift is not equal to 0
shapiro.test(Evans$chl)
##
## Shapiro-Wilk normality test
##
## data: Evans$chl
## W = 0.98575, p-value = 1.153e-05
kruskal.test(age ~chd, Evans)
##
## Kruskal-Wallis rank sum test
##
## data: age by chd
## Kruskal-Wallis chi-squared = 10.096, df = 1, p-value = 0.001486
kruskal.test(sbp ~chd, Evans)
##
## Kruskal-Wallis rank sum test
##
## data: sbp by chd
## Kruskal-Wallis chi-squared = 12.065, df = 1, p-value = 0.0005136
kruskal.test(dbp ~chd, Evans)
##
## Kruskal-Wallis rank sum test
##
## data: dbp by chd
## Kruskal-Wallis chi-squared = 7.9606, df = 1, p-value = 0.004781
kruskal.test(chl ~chd, Evans)
##
## Kruskal-Wallis rank sum test
##
## data: chl by chd
## Kruskal-Wallis chi-squared = 5.4504, df = 1, p-value = 0.01956
fisher.test(Evans$cat, Evans$chd)
##
## Fisher's Exact Test for Count Data
##
## data: Evans$cat and Evans$chd
## p-value = 0.0002049
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
## 1.614783 4.985252
## sample estimates:
## odds ratio
## 2.85516
chisq.test(Evans$smk, Evans$chd)
##
## Pearson's Chi-squared test with Yates' continuity correction
##
## data: Evans$smk and Evans$chd
## X-squared = 4.8353, df = 1, p-value = 0.02788
fisher.test(Evans$ecg, Evans$chd)
##
## Fisher's Exact Test for Count Data
##
## data: Evans$ecg and Evans$chd
## p-value = 0.01012
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
## 1.164222 3.463796
## sample estimates:
## odds ratio
## 2.018467
chisq.test(Evans$sescat3, Evans$chd)
##
## Pearson's Chi-squared test
##
## data: Evans$sescat3 and Evans$chd
## X-squared = 1.7422, df = 2, p-value = 0.4185
infarto = cs(Evans$chd, Evans$cat)
##
## Exposure
## Outcome Non-exposed Exposed Total
## Negative 443 95 538
## Positive 44 27 71
## Total 487 122 609
##
## Rne Re Rt
## Risk 0.09 0.22 0.12
##
## Estimate Lower95ci Upper95ci
## Risk difference (attributable risk) 0.13 0.06 0.19
## Risk ratio 2.45 1.56 3.86
## Attr. frac. exp. -- (Re-Rne)/Re 0.59
## Attr. frac. pop. -- (Rt-Rne)/Rt*100 % 22.5
## Number needed to harm (NNH) 7.64 5.37 17.21
## or 1/(risk difference)
print(infarto)
## NULL
infarto2 = cs(Evans$chd, Evans$smk)
##
## Exposure
## Outcome Non-exposed Exposed Total
## Negative 205 333 538
## Positive 17 54 71
## Total 222 387 609
##
## Rne Re Rt
## Risk 0.08 0.14 0.12
##
## Estimate Lower95ci Upper95ci
## Risk difference (attributable risk) 0.06 0.01 0.12
## Risk ratio 1.82 1.07 3.1
## Attr. frac. exp. -- (Re-Rne)/Re 0.45
## Attr. frac. pop. -- (Rt-Rne)/Rt*100 % 34.32
## Number needed to harm (NNH) 15.88 8.38 77.77
## or 1/(risk difference)
print(infarto2)
## NULL
infarto3 = cs(Evans$chd, Evans$ecg)
##
## Exposure
## Outcome Non-exposed Exposed Total
## Negative 401 137 538
## Positive 42 29 71
## Total 443 166 609
##
## Rne Re Rt
## Risk 0.09 0.17 0.12
##
## Estimate Lower95ci Upper95ci
## Risk difference (attributable risk) 0.08 0.02 0.13
## Risk ratio 1.84 1.16 2.92
## Attr. frac. exp. -- (Re-Rne)/Re 0.46
## Attr. frac. pop. -- (Rt-Rne)/Rt*100 % 18.68
## Number needed to harm (NNH) 12.52 7.56 59.83
## or 1/(risk difference)
print(infarto3)
## NULL
wilcox.test(sbp ~ chd, data = Evans)
##
## Wilcoxon rank sum test with continuity correction
##
## data: sbp by chd
## W = 14260, p-value = 0.0005143
## alternative hypothesis: true location shift is not equal to 0
`
wilcox.test(dbp ~ chd, data = Evans)
##
## Wilcoxon rank sum test with continuity correction
##
## data: dbp by chd
## W = 15172, p-value = 0.004786
## alternative hypothesis: true location shift is not equal to 0
infarto2 = mhor(Evans$chd, Evans$smk, Evans$ecg)
##
## Stratified analysis by Var3
## OR lower lim. upper lim. P value
## Var3 0 3.65 1.478 10.86 0.00203
## Var3 1 1.03 0.423 2.62 1.00000
## M-H combined 2.02 1.133 3.62 0.01595
##
## M-H Chi2(1) = 5.81 , P value = 0.016
## Homogeneity test, chi-squared 1 d.f. = 4.26 , P value = 0.039
## Ho: El infarto es independiente del nivel de catecolaminas cuando
ajusto por electrocardiograma anormal
infarto3 = mhor(Evans$chd, Evans$cat, Evans$ecg)
##
## Stratified analysis by Var3
## OR lower lim. upper lim. P value
## Var3 0 3.06 1.242 7.04 0.00749
## Var3 1 1.92 0.795 4.78 0.14999
## M-H combined 2.38 1.333 4.23 0.00228
##
## M-H Chi2(1) = 9.31 , P value = 0.002
## Homogeneity test, chi-squared 1 d.f. = 0.66 , P value = 0.416