##9.2.5
n<-339
ar<-69
p<-ar/n;p
## [1] 0.2035398
'P Wilson- adjusted'
## [1] "P Wilson- adjusted"
p_adj<-(ar+2)/(n+4);p_adj
## [1] 0.2069971
'Assumptions'
## [1] "Assumptions"
n*p_adj
## [1] 70.17201
n*(1-p_adj)
## [1] 268.828
SE_adj<-sqrt(((p_adj*(1-p_adj))/(n+4)))
CI<-c((p_adj-1.96*SE_adj),(p_adj+1.96*SE_adj)); CI
## [1] 0.1641197 0.2498745
##9.4.4 a) Chi-squared = 13.294
n<-932
o_weekday<-(n-216)/n
o_weekend<-216/n
e_weekday<-5/7
e_weekend<-2/7
birthmatrix<-matrix(c(o_weekend,e_weekend,o_weekday,e_weekday), ncol=2, byrow=TRUE)
rownames(birthmatrix)<-c("weekend", "weekday")
colnames(birthmatrix)<-c("observed", "expected")
birthmatrix<-as.table(birthmatrix); birthmatrix
## observed expected
## weekend 0.2317597 0.2857143
## weekday 0.7682403 0.7142857
null.probs = c(e_weekend, e_weekday)
birthnum =c(n*o_weekend, n*o_weekday)
chisq.test(birthnum, p=null.probs)
##
## Chi-squared test for given probabilities
##
## data: birthnum
## X-squared = 13.294, df = 1, p-value = 0.0002662
##9.4.5 A chi square test gives a value of chi square = 1.551 and a p-value of 0.6706 (>alpha =.10) meaning that we would fail to reject the null: the ratio of offspring (observed phenotypes) reflect the mendilian genetic (expected genotypes) ratios. There is no significant eidence that the data is inconsitent with the Mendilian model.
null.probs= c(9/16, 3/16, 3/16, 1/16)
WS<-111
Ws<-37
wS<-34
ws<-8
offspringdist = c(WS,Ws,wS,ws)
chisq.test(offspringdist, p=null.probs)
##
## Chi-squared test for given probabilities
##
## data: offspringdist
## X-squared = 1.5509, df = 3, p-value = 0.6706