Construct a 95% confidence interval for the population mean birthweight (you can do it by hand, by code, or by calculator). Interpret this interval in the context of the problem.

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

Suppose we have samples of 5 infants born to nonsmokers and 4 infants born to smokers. Distributions are not normal, and because it is such a small sample size, we choose to conduct a randomization permutation test to compare infants of smokers versus nonsmokers with the variable Y = birthweight. We find that 3 out of 126 possible outcomes had difference in means at least as large as the difference in the two observed sample means. Does this test provide evidence that the birthweights differ between infants of smokers or nonsmokers? Briefly justify your answer.

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

Use your graphing calculator (or R code) to report the t-test statistic and p-value of this t-test. Then write an appropriate test conclusion based on the context of the problem.

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)

Suppose that as part of a program for counseling patients with many risk factors for heart disease, 100 smokers are identified. From this group, 18 gave up smoking for at least 1 month. After one year, 11 out of those 18 patients are found to have taken up smoking again. (4 pts) Calculate and (round to three decimal places) for the proportion of ex-smokers who took up smoking again.

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

(5 pts) Perform a test:State the null an alternative hypotheses. Then report the statistic as well as the p-value.

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