knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
knitr::opts_chunk$set(echo = TRUE, tidy = FALSE) options(width = 80) library(knitr) library(rmarkdown) library(rmcorr) library(corrplot)
#Install corrplot install.packages("corrplot") require(corrplot)
The output from rmcorr_mat can be used be used to plot a correlation matrix.
dist_rmc_mat <- rmcorr_mat(participant = Subject, variables = c("Blindwalk Away", "Blindwalk Toward", "Triangulated BW", "Verbal", "Visual matching"), dataset = twedt_dist_measures, CI.level = 0.95) corrplot(dist_rmc_mat$matrix)
The output can also be used to plot multiple models side-by-side.
#Number of models being plotted n.models <- length(dist_rmc_mat$models) #Change graphing parameters to plot side-by-side #with narrower margins par(mfrow = c(3,4), mar = c(2.75, 2.4, 2.4, 1.4)) for (i in 1:n.models) { plot(dist_rmc_mat$models[[i]]) } #Reset graphing parameters #dev.off()
The third component of the output from rmcorr_mat() contains a summary of results. Using the summary component, we demonstrate adjusting for multiple comparisons using two methods: the Bonferroni correction and the False Discovery Rate (FDR).
This example also compares the unadjusted p-values to both adjustment methods. Because most of the unadjusted p-values are quite small, many of the adjusted p-values tend to be similar to the unadjusted ones and the two adjustment methods also tend to produce similar p-values.
#Third component: Summary dist_rmc_mat$summary #p-values only dist_rmc_mat$summary$p.vals #Vector of original, unadjusted p-values for all 10 comparisons p.vals <- dist_rmc_mat$summary$p.vals p.vals.bonferroni <- p.adjust(p.vals, method = "bonferroni", n = length(p.vals)) p.vals.fdr <- p.adjust(p.vals, method = "fdr", n = length(p.vals)) #All p-values together all.pvals <- cbind(p.vals, p.vals.bonferroni, p.vals.fdr) colnames(all.pvals) <- c("Unadjusted", "Bonferroni", "fdr") round(all.pvals, digits = 5)
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.