Check these directories Windows: C:\Program Files\R\R-3.5.2\bin\x64\Rgui.exe
Mac: /Library/Frameworks/R.framework/Resources/library
First, install R for Windows or for Mac
I strongly recommend downloading RStudio. RStudio is an integrated development environment (IDE), which is mumbo-jumbo for a friendly user interface for R. Think of R as the internal components of a car, which makes everything run. RStudio is the beautiful interior and sleek body of the car.
psychmetaOpen RStudio and in the console run the command
install.packages("psychmeta", dependencies = T)
by adding the argument dependencies = T you also have installed metafor
Now, download the Chapter38 Example.csv file (from Blackboard)
# You may have to set your directory otherwise R will not find your file
# In windows and mac you can use the hotkey: Ctrl + Shift + H
setwd("C:/Users/17404/Downloads")
# Import data.frame
Chapter38_Example <- read.csv("Chapter38 Example.csv", stringsAsFactors = F)
psychmetapsychmeta#load the package
library(psychmeta)
# Example of an individual correction ("ic") method
ma_obj <- ma_r(ma_method = "ic",
rxyi = r, n = N,
rxx = rxx,
ryy = ryy,
clean_artifacts = FALSE,
impute_artifacts = FALSE,
data = Chapter38_Example)
ma_r is the cornerstone function of psychmeta so you will be using it a lot, take some time to understand it by running ?ma_r in your console.
The creators of psychmeta are using an object-oriented approach meaning you can think of ma_obj as a house (i.e., object) that is storing everything you need. This may cause some discomfort but with time you’ll get use to it. You can use the $ function to ‘search’ through the house for things. The creators of psychmeta also created the get_ function to make it a little easier.
# for example
ma_obj$meta_tables
# is equivilent to
get_metatab(ma_obj)
# but you can go a little deeper into a 'room'
ma_obj$meta_tables$`analysis_id: 1`
# and sometimes ... even deeper
ma_obj$meta_tables$`analysis_id: 1`$individual_correction
To see the results:
#psychmeta uses the methods prefix get_ so get_ can be used to extract different types of information from your meta-analysis object
ma_results <- get_metatab(ma_obj)
# To get the barebones analysis
ma_results[["barebones"]]
# To get the corrections
ma_results[["individual_correction"]]
#Then we can turn it in to something we are more familiar with (I admit it's not super user friendly)
ma_results_df <- do.call("rbind", ma_results[["individual_correction"]])
#You can now save this to a csv file and share it with your friends
write.csv(ma_results_df, "meta_analysis_corrected_data.csv", row.names = F)
To check how robust your meta-analytic results are, we can run additional analyses using the sensitivity function on our object ma_obj.
# this conduct three post-hoc analyses using your results:
# ... leave1out analysis, bootstrap, and cumulative meta-analysis
ma_obj <- sensitivity(ma_obj)
# you can see the results by doing the following
get_leave1out(ma_obj)[[1]]
# or assign it to an object for easy access to plots etc
ma_results_l1o <- get_leave1out(ma_obj)[[1]]
# to see plot for the barebones analysis:
ma_results_l1o[["barebones"]]$plots
# for additional analyses use get_`name of analysis` for example
get_cumulative(ma_obj)
get_bootstrap(ma_obj)
psychmeta uses metafor to allow you to perform meta-regression
# create a fake categorical moderator
Chapter38_Example$study_type <- gsub(" [0-9]$", "", Chapter38_Example$StudyCitation)
# Example of an individual correction ("ic") method with moderators
ma_obj_mc <- ma_r(ma_method = "ic",
rxyi = r, n = N,
rxx = rxx,
ryy = ryy,
moderators = c("study_type", "AverageAge"),
cat_moderators = c(TRUE, FALSE),
data = Chapter38_Example)
# Run the metareg (similar to metafor::rma)
ma_obj_mc <- metareg(ma_obj_mc, formula_list = list("study_type + AverageAge" = yi ~ study_type + AverageAge))
# Extract results
ma_metareg_results <- get_metareg(ma_obj_mc)
# add the plots to your object
ma_obj <- plot_funnel(ma_obj = ma_obj)
ma_obj <- plot_forest(ma_obj = ma_obj)
#Look at them
get_plots(ma_obj)[["funnel"]]
get_plots(ma_obj)[["forest"]]
You can output an apa-style table of your results.
# Write meta-analysis tables to a Word file called "Meta-analysis table.docx"
metabulate(ma_obj, file = "Meta-analysis table.docx",
output_format = "word", output_dir = getwd())
psychmeta can automatically generate a formatted reference list using a BibTeX or Zotero library. More to come.