library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
## ✔ ggplot2 3.3.6 ✔ purrr 0.3.4
## ✔ tibble 3.1.8 ✔ dplyr 1.0.10
## ✔ tidyr 1.2.1 ✔ stringr 1.4.1
## ✔ readr 2.1.2 ✔ forcats 0.5.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
library(BSDA)
## Warning: package 'BSDA' was built under R version 4.2.2
## Loading required package: lattice
##
## Attaching package: 'BSDA'
##
## The following object is masked from 'package:datasets':
##
## Orange
p.adjust = (69+2)/(339+4)
SE = sqrt(p.adjust*(1 - p.adjust)/343)
p.adjust - 1.96*SE
## [1] 0.1641197
p.adjust + 1.96*SE
## [1] 0.2498745
null.probs <-c(716/932)
Weekends <-c(216/932)
df <- data.frame(Weekends,null.probs)
chisq.test(df)
## Warning in chisq.test(df): Chi-squared approximation may be incorrect
##
## Chi-squared test for given probabilities
##
## data: df
## X-squared = 0.28781, df = 1, p-value = 0.5916
It revea;s that is it very strong evidence to support that the births are by chance
null.probs = c(9/16,3/16,3/16,1/16)
ChickOffspring = c(111,37,34,8)
chisq.test(ChickOffspring, p=null.probs)
##
## Chi-squared test for given probabilities
##
## data: ChickOffspring
## X-squared = 1.5509, df = 3, p-value = 0.6706
null.probs = c(14/20,11/17)
SeizureFree = c(6/20,6/17)
df = data.frame(SeizureFree,null.probs)
chisq.test(df)
## Warning in chisq.test(df): Chi-squared approximation may be incorrect
##
## Pearson's Chi-squared test with Yates' continuity correction
##
## data: df
## X-squared = 9.3811e-32, df = 1, p-value = 1
Died = c(89/347)
Survived = c(189/347)
df = data.frame(Died,Survived)
chisq.test(df)
## Warning in chisq.test(df): Chi-squared approximation may be incorrect
##
## Chi-squared test for given probabilities
##
## data: df
## X-squared = 0.10366, df = 1, p-value = 0.7475
Died = c(106/348)
WW = c(242/348)
df = data.frame(Died,WW)
chisq.test(df)
## Warning in chisq.test(df): Chi-squared approximation may be incorrect
##
## Chi-squared test for given probabilities
##
## data: df
## X-squared = 0.15273, df = 1, p-value = 0.6959
25/492
## [1] 0.05081301
23/614
## [1] 0.03745928
(25/492)/(23/614)
## [1] 1.356486
(25*614)/(23*492)
## [1] 1.356486
12/93
## [1] 0.1290323
8/84
## [1] 0.0952381
(12/93)/(8/84)
## [1] 1.354839
(12*84)/(8*93)
## [1] 1.354839
3995/46941
## [1] 0.08510684
221/5228
## [1] 0.04227238
(3995/46941)/(221/5228)
## [1] 2.013297
(3995*5007)/(221*42946)
## [1] 2.107557