Analysis <- function(x_list, permutations = 5000, intercept = TRUE, directed = "undirected",
diagonal = FALSE, test.statistic = "beta", tol = 1e-07, randomisations = 5000){
if(length(x_list) == 2){ #For the 2 object list, run the mantel test and MRQAP
mantel_test_results <- mantel(x_list[[1]], x_list[[2]], permutations=permutations)
MRQAP_results <- mrqap.dsp(x_list[[2]]~x_list[[1]], intercept=intercept, directed=directed,
diagonal=diagonal, test.statistic=test.statistic, tol=tol,
randomisations=randomisations)
#Store results in a new list
results <- list(mantel_test_results, MRQAP_results)
return(results)
}
if(length(x_list) == 3){ #For the 3 object list, run the mantel test 3 times, with each matrix pair
mantel_test_results_1 <- mantel(x_list[[1]], x_list[[2]], permutations=permutations)
mantel_test_results_2 <- mantel(x_list[[3]], x_list[[2]], permutations=permutations)
mantel_test_results_3 <- mantel(x_list[[1]], x_list[[3]], permutations=permutations)
#Then MRQAP, treating the second matrix as dependent when possible, or third matrix for the last test
MRQAP_results_1 <- mrqap.dsp(x_list[[2]]~x_list[[1]], intercept=intercept, directed=directed,
diagonal=diagonal, test.statistic=test.statistic, tol=tol,
randomisations=randomisations)
MRQAP_results_2 <- mrqap.dsp(x_list[[2]]~x_list[[3]], intercept=intercept, directed=directed,
diagonal=diagonal, test.statistic=test.statistic, tol=tol,
randomisations=randomisations)
MRQAP_results_3 <- mrqap.dsp(x_list[[3]]~x_list[[1]], intercept=intercept, directed=directed,
diagonal=diagonal, test.statistic=test.statistic, tol=tol,
randomisations=randomisations)
mantel_ptest_results <- mantel.partial(x_list[[2]], x_list[[3]], x_list[[1]], permutations=permutations)
#Store results in a new list
results <- list(mantel_test_results_1, mantel_test_results_2, mantel_test_results_3,
MRQAP_results_1, MRQAP_results_2, MRQAP_results_3, mantel_ptest_results)
return(results)
}else{
#Exception for lists of incorrect length
stop("Data input not valid for this analysis")
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.