library(boot) library(tidyverse)
#——————–
sim_wit <- function(size=1000) {
wit <- rnorm(n=2000, mean=0.136, sd=0.163)
wit <- wit[wit >= 0]
wit <- wit[1:size]
return(wit)
}
#——————–
sim_fia <- function(size=1000) {
fia <- rnorm(n=3000, mean=0.175, sd=0.919)
fia <- fia[fia >= 0]
fia <- fia[fia <= 1]
fia <- fia[1:size]
return(fia)
}
#——————–
plot_sim <- function() {
par(mfrow=c(1,2))
p1 <- hist(wit)
p2 <- hist(fia)
}
#——————–
p_t_test <- function() {
test <- t.test(wit, fia, paired = TRUE, alternative = "two.sided")
return(test$p.value)
}
#———————————————-
size <- 1000
#———————————————-
wit <- sim_wit()
fia <- sim_fia()
plot <- plot_sim()
p_val <- p_t_test()
print(head(wit))
## [1] 0.1690042 0.1141015 0.1948066 0.1396346 0.3567820 0.3261598
print(head(fia))
## [1] 0.6543397 0.1661464 0.8553390 0.5093315 0.4628313 0.5785354
print(p_val)
## [1] 1.535248e-126
#——————–
sim_wit <- function(size=1000) {
wit <- rnorm(n=2000, mean=0.136, sd=0.163)
wit <- wit[wit >= 0]
wit <- wit[1:size]
return(wit)
}
#——————–
sim_fia <- function(size=1000) {
fia <- rnorm(n=3000, mean=0.175, sd=0.163)
fia <- fia[fia >= 0]
fia <- fia[fia <= 1]
fia <- fia[1:size]
return(fia)
}
#——————–
plot_sim <- function() {
par(mfrow=c(1,2))
p1 <- hist(wit)
p2 <- hist(fia)
}
#——————–
p_t_test <- function() {
test <- t.test(wit, fia, paired = TRUE, alternative = "two.sided")
return(test$p.value)
}
#——————–
new_df <- function() {
wit_fia <- merge(wit,fia)
return(wit_fia)
}
#———————————————-
size <- 1000
#———————————————-
wit <- sim_wit()
fia <- sim_fia()
plot <- plot_sim()
p_val <- p_t_test()
wit_fia <- new_df()
print(head(wit))
## [1] 0.1470471 0.1673131 0.1675279 0.1462790 0.1526739 0.1990632
print(head(fia))
## [1] 0.1491545 0.3143144 0.2180868 0.3339975 0.1017658 0.2879255
print(head(wit_fia))
## x y
## 1 0.1470471 0.1491545
## 2 0.1673131 0.1491545
## 3 0.1675279 0.1491545
## 4 0.1462790 0.1491545
## 5 0.1526739 0.1491545
## 6 0.1990632 0.1491545
print(p_val)
## [1] 8.168173e-08