y<-114
s<-24
n<-100
alpha<-.05
alpha2t<-alpha/2
SE<-s/sqrt(n)
cv<-qt(1-alpha2t, n-1)
upper<-y+cv*SE
lower<-y-cv*SE
CI<-c(lower,upper);CI
## [1] 109.2379 118.7621
p<-3/126;p
## [1] 0.02380952
##(4 pts) A medical researcher proposes to estimate the mean serum cholesterol level of a certain population of middle-aged men, based on a random sample of the population within a 95% confidence interval, where the standard error of the mean should be within 3 mg/dl. From past studies, the researcher believes the standard deviation is about 40 mg/dl. How large a sample does the researcher need to take? Show work.
s<-40
des_SE<-3
n<-(s/des_SE)^2;n
## [1] 177.7778
y1<-107.7
y2<-115.3
s1<-9.5
s2<-14.9
n1<-195
n2<-96
library(BSDA)
## Loading required package: lattice
##
## Attaching package: 'BSDA'
## The following object is masked from 'package:datasets':
##
## Orange
tsum.test(y1,s1,n1,y2,s2,n2, conf.level = .95)
##
## Welch Modified Two-Sample t-Test
##
## data: Summarized x and y
## t = -4.5619, df = 134.2, p-value = 1.131e-05
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -10.894936 -4.305064
## sample estimates:
## mean of x mean of y
## 107.7 115.3
##(4 pts) Using the effect size formula, (where s is from the African American group) what is the effect size and interpret your result as to whether this is an important effect. Compare the effect size to the results of your hypothesis test, and briefly comment.
effect_size<- (y1-y2)/s2; effect_size
## [1] -0.5100671
##(4 pts) Why might you want to use a Wilcoxon-Mann-Whitney test in this example rather than a t-test?
hospital1 <- c(21, 10, 32, 60, 8, 44, 29, 5, 13, 26, 33)
hospital2 <- c(86, 27, 10, 68, 87, 76, 125, 60, 35, 73, 96, 44)
length(hospital1)
## [1] 11
length(hospital2)
## [1] 12
hist(hospital1)
hist(hospital2)
n<-18
o<-11
p_tilde<-((o+2)/(n+4)); p_tilde
## [1] 0.5909091
'Assumptions'
## [1] "Assumptions"
n*p_tilde
## [1] 10.63636
n*(1-p_tilde)
## [1] 7.363636
SE_adj<-sqrt(((p_tilde*(1-p_tilde))/(n+4)))
CV_95<-1.96
upper<-p_tilde + CV_95*SE_adj
lower<-p_tilde - CV_95*SE_adj
CI<-c(lower,upper);CI
## [1] 0.3854549 0.7963633
tumors<-c(20,8)
no_tumors<-c(11,32)
test<-data.frame(tumors,no_tumors)
chisq.test(test)
##
## Pearson's Chi-squared test with Yates' continuity correction
##
## data: test
## X-squared = 12.687, df = 1, p-value = 0.0003683
##Calculate the Odds Ratio (OR) of having a tumor, given the two conditions of germ free versus E. Coli environments.
p1<-20/31
p2<-8/40
odds_ratio<-((p1/(1-p1))/(p2/(1-p2)));odds_ratio
## [1] 7.272727