R Markdown

Exercise 1. data~N($, \(\sigma\)) \(H_0:\mu=\mu_0\)

daily.intake <- c(5260, 5470, 5640, 6180, 6390, 6515, 6805, 7515, 7515, 8230, 8770)
mean(daily.intake)
## [1] 6753.636
sd(daily.intake)
## [1] 1142.123
quantile(daily.intake)
##   0%  25%  50%  75% 100% 
## 5260 5910 6515 7515 8770

Given that \(\mu_0=7725\) KJ.

t.test(daily.intake, mu=7725)
## 
##  One Sample t-test
## 
## data:  daily.intake
## t = -2.8208, df = 10, p-value = 0.01814
## alternative hypothesis: true mean is not equal to 7725
## 95 percent confidence interval:
##  5986.348 7520.925
## sample estimates:
## mean of x 
##  6753.636

4.

A. t=-2.8208 B) p<.05 That means the data deviates significantly from the mean 7725.

Exercise 2

American<- c(3,5,2,1,4,4,6,3,5,4)
European<- c(6,5,7,7,6,3,4,6,5,4)

Create the data frame

bp.survey<- data.frame("bp"=c(American, European), "group"= rep(c("American", 
  "European"), each =10), stringsAsFactors = FALSE)
library(yarrr)
yarrr::pirateplot(bp~group, data=bp.survey, ylab= "Number of Body Piercings", xlab= "Group", main="Body Piercing Survey", theme=2, point.o=.8, cap.beans=TRUE)

bp.test<-t.test(x=American, y=European, alternative = "two.sided")
bp.test
## 
##  Welch Two Sample t-test
## 
## data:  American and European
## t = -2.5228, df = 17.783, p-value = 0.0214
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -2.9335927 -0.2664073
## sample estimates:
## mean of x mean of y 
##       3.7       5.3

Independent Exercise

old <- c(45,38,52,48,25,39,51, 46,55,46)
young<- c(34,22,15,27,37,41,24,19,26,36)
data.frame(old, young)
##    old young
## 1   45    34
## 2   38    22
## 3   52    15
## 4   48    27
## 5   25    37
## 6   39    41
## 7   51    24
## 8   46    19
## 9   55    26
## 10  46    36
bp.test<- t.test(x=old, y=young, alternative= "two.sided")
bp.test
## 
##  Welch Two Sample t-test
## 
## data:  old and young
## t = 4.2575, df = 17.995, p-value = 0.0004739
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##   8.307131 24.492869
## sample estimates:
## mean of x mean of y 
##      44.5      28.1
plot(old,young, xlab="old and young", ylab="age", title= "Life Satisfaction Survey")
## Warning in plot.window(...): "title" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "title" is not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "title" is not
## a graphical parameter

## Warning in axis(side = side, at = at, labels = labels, ...): "title" is not
## a graphical parameter
## Warning in box(...): "title" is not a graphical parameter
## Warning in title(...): "title" is not a graphical parameter