library(snpar)
library(DescTools)
library(boot)
#3.1
penguins.before<-rnorm(200, 50, 23)
penguins.after<-rnorm(250, 50, 23) -rpois(200,5)
## Warning in rnorm(250, 50, 23) - rpois(200, 5): longitud de objeto mayor no es
## múltiplo de la longitud de uno menor
runs.test(penguins.before)
##
## Approximate runs rest
##
## data: penguins.before
## Runs = 99, p-value = 0.7768
## alternative hypothesis: two.sided
runs.test(penguins.after)
##
## Approximate runs rest
##
## data: penguins.after
## Runs = 135, p-value = 0.254
## alternative hypothesis: two.sided
shapiro.test(penguins.before)
##
## Shapiro-Wilk normality test
##
## data: penguins.before
## W = 0.9898, p-value = 0.167
shapiro.test(penguins.after)
##
## Shapiro-Wilk normality test
##
## data: penguins.after
## W = 0.99625, p-value = 0.8148
#3.2
t.test(penguins.after)
##
## One Sample t-test
##
## data: penguins.after
## t = 30.891, df = 249, p-value < 2.2e-16
## alternative hypothesis: true mean is not equal to 0
## 95 percent confidence interval:
## 40.57240 46.09824
## sample estimates:
## mean of x
## 43.33532
penguins.after2 <- boot(data = penguins.after, statistic = function(penguins.after,i) median(penguins.after[i]),R = 1000)
boot.ci(penguins.after2)
## Warning in boot.ci(penguins.after2): bootstrap variances needed for studentized
## intervals
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
##
## CALL :
## boot.ci(boot.out = penguins.after2)
##
## Intervals :
## Level Normal Basic
## 95% (41.49, 46.71 ) (41.47, 46.93 )
##
## Level Percentile BCa
## 95% (40.39, 45.86 ) (40.31, 45.72 )
## Calculations and Intervals on Original Scale