Question: Using R Provide the code that parallelizes the following: library ( MKinfer ) # Load package used for permutation t - test # Create a

Using R Provide the code that parallelizes the following:
library(MKinfer) # Load package used for permutation t-test
# Create a function for running the simulation:
simulate_type_I <- function(n1, n2, distr, level =0.05, B =999,alternative = "two.sided", ...)
{
# Create a data frame to store the results in:
p_values <- data.frame(p_t_test = rep(NA, B),p_perm_t_test = rep(NA, B),p_wilcoxon = rep(NA, B))
for(i in 1:B)
{
# Generate data:
x <- distr(n1,...)
y <- distr(n2,...)
# Compute p-values:
p_values[i,1]<- t.test(x, y,
alternative = alternative)$p.value
p_values[i,2]<- perm.t.test(x, y,alternative = alternative,R =999)$perm.p.value
p_values[i,3]<- wilcox.test(x, y,alternative = alternative)$p.value
}
# Return the type I error rates:
return(colMeans(p_values < level))
}
Provide the code that runs the following code in parallel with 4 workers (with mclapply):
lapply(airquality, function(x){(x-mean(x))/sd(x)})

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!