library("meta.now"); library("RefManageR") library("metaSEM") library("ggplot2") library("ggthemes") library("cowplot"); # ggplot enhancer me = "GxSES" genbib = RefManageR::ReadBib(system.file("extdata", "general.bib", package = "meta.now")) # Assumes mn_update_data() has been run # Read in the overall file df = gdata::read.xls(paste0(path, "/", "data_GxSES.xlsx"), stringsAsFactors = FALSE) str(df) # 2. open the bib for this project bib = ReadBib(system.file(paste0("extdata/", me), paste0("bib_", me, ".bib"), package = "meta.now"), check = FALSE) BibOptions(check.entries = FALSE, style = "markdown", cite.style = "authoryear", bib.style = "numeric")
r AutoCite(bib, "Bates2013", before = "e.g., ")
hist(df$a1) mean(df$a1) weighted.mean(df$a1 , 1/(df$k * df$a1_SE^2) , na.rm = TRUE) weighted.mean(dfUS$a1, 1/(dfUS$k * dfUS$a1_SE^2), na.rm = TRUE)) weighted.mean(dfEU$a1, 1/(dfEU$k * dfEU$a1_SE^2), na.rm = TRUE)) # Two level unconditional (Random Effects meta analysis) rmeta = meta(y = a1,v = a1_SE^2, data = df) summary(rmeta) # Three level unconditional (intercept only) Model0 = meta3(y = a1, v = a1_SE^2, cluster = DataID, data = df, model.name = "3 level model") summary(Model0) # Three level US vs. Other Model1 = meta3(y = a1, v = a1_SE^2, x = US, cluster = DataID, data = df, model.name = "3 level model") summary(Model1) # Weighted histogram p = ggplot(df, aes(x = a1, weight = 1/(k * a1_SE^2))) + geom_histogram(col="black", fill = "light grey", bins = 15) p = p + labs(x = "Effect size", y = "Weighted count") + xlim(c(-.2, .2)) p = p + theme_base() + theme(plot.background = element_rect( color = "white")) # p + theme_bw() # Weighted histogram US and not US (weight = reciprocal sampling variance) plotUS = ggplot(dfUS, aes(x = a1, weight = 1/(a1_SE^2))) + geom_histogram(col = "black", fill = "light grey", binwidth = .025) # plotUS = plotUS + ggtitle("United States") plotUS = plotUS + labs(x = "Effect size", y = "Weighted count") plotUS = plotUS + xlim(c(-.3, .3)) # plotUS = plotUS + theme_bw() plotUS = plotUS + theme_base() + theme(plot.background = element_rect( color= "white")) plotUS = plotUS + theme(plot.title = element_text(hjust = 0.5)) plotEU = ggplot(dfEU, aes(x = a1, weight = 1/(a1_SE^2))) + geom_histogram(col = "black",fill = "light grey", binwidth = .025) # plotEU = plotEU + ggtitle("Europe and Australia") plotEU = plotEU + labs(x = "Effect size", y= "Weighted count") plotEU = plotEU + xlim(c(-.3, .3)) # plotEU = plotEU + theme_bw() plotEU = plotEU + theme_base() + theme(plot.background = element_rect(color = "white")) plotEU = plotEU + theme(plot.title = element_text(hjust = 0.5)) # both p = ggplot(df, aes(x = a1, weight = 1/(a1_SE^2), fill = factor(US))) + geom_histogram(alpha = 0.2, position = "identity", bins=15) p = p + labs(x = "Effect size", y= "Weighted count") p = p + xlim(c(-.3, .3)) p = p + theme_bw() p = p + theme_base() + theme(plot.background = element_rect(color = "white")) p = p + theme(plot.title = element_text(hjust = 0.5)) cowplot::plot_grid(plotUS, plotEU, labels = c("United States", "Europe and Australia"), align = "v") metafor::forest(rma(yi = a1, sei = a1_SE, data=df[df$US==1,])) metafor::forest(rma(yi = a1, sei = a1_SE, data=df[df$US==0,])) , annotate=TRUE, showweights=FALSE, xlim, alim, clim, ylim, at, steps=5, level=95, refline=0, digits=2L, width, xlab, slab, ilab, ilab.xpos, ilab.pos, subset, transf, atransf, targs, rows, efac=1, pch=15, psize, col, lty, cex, cex.lab, cex.axis, annosym, ...) # Weighted histogram US and not US (weights = reciprocal sampling variance and 1/k) plotUS = ggplot(dfUS, aes(x = a1, weight = 1/(k*a1_SE^2))) plotUS = plotUS + geom_histogram(col = "black",fill = "light grey") plotUS = plotUS + labs(x = "Effect size", y = "Weighted count") plotUS = plotUS + xlim(c(-.3, .3)) plotUS = plotUS + theme_base() plotUS = plotUS + theme(plot.background = element_rect( color= "white")) plotUS = plotUS + ggtitle("United States") plotUS = plotUS + theme(plot.title = element_text(hjust = 0.5)) plotEU = ggplot(dfEU,aes(x=a1,weight=1/(k*a1_SE^2))) plotEU = plotEU + geom_histogram(col="black",fill="light grey") plotEU = plotEU + labs(x="Effect size", y="Weighted count") plotEU = plotEU + xlim(c(-.3,.3)) plotEU = plotEU + theme_base() plotEU = plotEU + theme(plot.background = element_rect( color= "white")) plotEU = plotEU + ggtitle("Europe and Australia") plotEU = plotEU + theme(plot.title = element_text(hjust = 0.5)) multiplot(plotUS,plotEU)
Data References
PrintBibliography(bib, .opts = list(check.entries = FALSE, sorting = "ynt"))
References for packages and methods used
PrintBibliography(genbib)
r Citet(bib, "loh")
r AutoCite(bib, "baez/online", before = "e.g., ")
.r NoCite(bib = bib, title = "CTAN")
SearchBib()
1 by type r Citet(bib, bibtype = "Report", .opts = list(hyperlink = "to.doc"))
.r AutoCite(bib2, title = "binary longitudinal data")
.r TextCite(bib, author = "Aristotle")
. r TextCite(bib, eprinttype = "arxiv")
.BibOptions
.opts
argument to cite functions."authoyear"
and "numeric"
style.?open.BibEntry
). r AutoCite(bib, location = "Uppsala", .opts = list(hyperlink = FALSE))
.plot(cars)
plot(cars)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.