Code Monkey home page Code Monkey logo

metaaidr's Introduction

Build Status codecov

metaAidR

Table of contents

  1. Description
  2. Installation
  3. Datasets
  4. Functions
  5. References

Description

metaAidR contains a set of functions that allows users to make use of both simple (i.e. calculation of effect size statistics) along with more advanced (i.e. generate correlation/(co)variance matrices for non-independence, calculate I2 & R2 statistics) formal meta-analytic procedures. In addition, it contains a number of datasets that are used to demonstrate the use of functions and statistical concepts. This package will accompany a 'how-to' paper and is under active development.

Installation

metaAidR is not currently on CRAN. For testing purposes only it can be downloaded through devtools as follows:

install.packages("devtools")
library(devtools)
install_github("daniel1noble/metaAidR")

devtools will install all the relevant documentation and data associated with the package.

NOTE: While functions exist, they are still not completely functional. Additionally, not all functions have been effectively tested and so should not be used or used with extreme caution!

Datasets

metaAidR comes with a suite of different datasets which accompany the examples in the 'how-to' paper. These example datasets are used to demonstrate the functionality of metaAidR along with more advanced meta-analytic topics that maybe of interest to practitioners. Datasets can be queried and loaded as with normal R packages. Currently, the datasets that exist are as follows:

Dataset Reference Description
agg_epp_wpp & multi_epp_wpp Cleasby & Nakagawa (2012) Extra-pair and within pair multiple paternity
birdegg_ssd.5 & birdegg_ssd.8 Rutkowski et al. (2014) Egg sexual size dimorphism
heatshock Lagisz et al. (2013) Heatshock protein meta-analysis
matdiet Besson et al. (2016) Maternal diet and soping styles meta-analysis
moNumtradeoff & moSizetradeoff Lim et al. (2014) Mother offspring size and number tradeoff
ooAdjtradeoff & ooUnAdjtradeoff Lim et al. (2014) Offspring size and number tradeoff meta-analysis
mtor Garratt et al. (2016) Meta-analysis of mtor
parasites Poulin (2000) Parasites impacting behaviour meta-analysis
plumage Santos et al. (2011) Meta-analysis on dominance and plumage traits
sparrows Nakagawa et al. (2007) Sparrow meta-analysis and bib size

For more details on each specific meta-analysis use ? in combination with the specific dataset (e.g. ?heatshock). This will provide meta-data details for each dataset along with its reference and a description.

Functions

Currently, there are five main functions: es_stat, es_ratio, make_VCV_matrix, I2, foldnorm. While es_stat and es_ratio are functions that can be found in other meta-analytic packages (e.g. metafor), we have separated out two different families of effect size statistics and have expanded these functions to include more recently developed effect size statistics. For example, es_stat will implement commonly used effect size statistics (i.e. Cohen's / Hedges' d; Hedges' g, Fisher's z-transformed correlation coefficient and log odds ratio). While these are common effect size measures, they also have the important property that these measurements can be converted among each other. Hence, the plan is to provide arguments that the user can specify the type of data they would like so that calculations can be done with multiple data types to the relevant effect size statistic and then re-calculated into a common type for analysis. es_ratio contains the ratio family effect size statistics (e.g. log response ratio), along with newly developed or less commonly applied effects sizes including those for comparing variances (i.e. log coefficient of variation ratio and log variance ratio) and log hazards ratios.

In addition to functions for calculating effect size statistics, metaAidR also will calculate flexible heterogeneity statistics (I2), from common meta-analytic models from metafor and MCMCglmm model objects. These are not yet implemented but are forthcoming.

Meta-analytic models also often exhibit unique (and common) forms of non-independence. To provide users with useful functions to calculate correlation / (co)variance matrices metaAidR also provides a make_VCV_matrix function that allows the user to generate covariance matrices based on shared control measurements, phylogenetic correlation matrices (not yet active)or within-study/shared trait measurements matrices that can be used as input matrices for common meta-analytic models implemented in both metafor and MCMCglmm.

For many situations in ecology and evolution, the absolute or magnitude of effect size is of most interest, rather than effect size estimates containing directionality (see Morrissey 2016a & b). Absolute effect size estimates follow a folded normal distribution and need to be modeled correctly to avoid bias. As such, for users interested in effect magnitude we have developed a foldnorm function which can apply results from normal meta-analytic models (that assume Gaussian error distributions) to generate corrected effect magnitude and credible intervals using an 'anlayse then transform' approach suggested by Morrissey (2016a).

References

Besson, A. A., Lagisz, M., Senior, A.M., Hector, K.L. and Nakagawa, S. (2016). Effect of maternal diet on offspring coping styles in rodents: a systematic review and meta-analysis. Biological Reviews, 91:1065-1080

Cleasby, I.R. and Nakagawa, S. (2012) The influence of male age on within-pair and extra-pair paternity in passerines. Ibis, 154: 318-324.

Garratt, M., Nakagawa, S., Simons, M.J.P. (2016) Comparative idiosyncrasies in life extension by reduced mTOR signaling and its distinctiveness from dietary restriction. Aging Cell, 15: 737-743.

Lagisz, M., Hector, K.L. and Nakagawa, S. (2013) Life exstension after heat shock exposure: Assessing meta-analytic evidence for hormesis. Ageing Research Reviews, 12:653-660.

Lim, J. N., Senior, A. M. and Nakagawa, S. (2014) Heterogeneity in individual quality and reproductive trade-offs within species. Evolution, 68:2306-2318.

Morrisey, M.B. (2016)a. Meta-analysis of magnitudes, differences and variation in evolutionary parameters. Journal of Evolutionary Biology, 29:1882-1904

Morrisey, M.B. (2016)b. Rejoinder: Further considerations for meta-analysis of transformed quantities such as absolute values. Journal of Evolutionary Biology, 29:1922-1931.

Nakgawa, S., Ockendon, N., Gillespie, D.O.S., Hatchwell, B.J. and Burke, T. (2007) Assessing the function of house sparrows' bib size using a flexible meta-analysis method. Behavioural Ecology, 18:831-840.

Poulin, R. (2000) Manipulation of host behaviour by parasites: a weakening paradigm? Proceedings of the Royal Society B: Biological Sciences, 267: 1471-2954.

Rutkowska, J., Dubiec, A. and Nakgawa, S. (2014). All eggs are made equal: a meta-analysis of egg sexual size dimorphism. Journal of Evolutionary Biology, 27:153-160.

Santos, E.S.A., Scheck, D. and Nakagawa, S. (2011) Dominance and plumage traits: meta-analysis and meta-regression analysis. Animal Behaviour, 82: 3-19.

metaaidr's People

Contributors

daniel1noble avatar mlagisz avatar npmoran avatar thomased avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

metaaidr's Issues

foldnorm

Make sure that with MCMCglmm and use of mev argument that this is removed from the model$VCV matrix. Need to add a few things to take care of this

VlnCVR_es

We need to think about how to deal with the calculation of variance of lnCVR, if only a single valued vector is provided by user. I have written some if statements in, but assumed that if the user provides a single mean etc. that it assumes a correlation between mean and sd of 0.5, but the user can specify the correlation through a cor argument. ca0094a

I2 for MCMCglmm objects

Need to generalise I2 a bit more. TO DO: accomodate situations where ginverse is used for measurement error as opposed to “mev” for MCMCglmm. Issue came up when working with MCMCglmm objects where pr = TRUE and ginverse used. Should be simple fix, but something to do!

Covariance matrix

Bring this new dependency function BACK into the covariance matrix function

VmCovMat <- function(data, es_var, depend, cor = 0.5){
    	data$dep<-paste(data[,"study"], data[,depend], sep="_")

    	tmp <- reshape::expand.grid.df(data.frame(sd1 = sqrt(data[, es_var]), stdy1 = data[,"dep"]), data.frame(sd2 = sqrt(data[, es_var]), stdy2 = data[,"dep"]))

    	tmp$cor <- ifelse((tmp$stdy1 == tmp$stdy2) & (tmp$sd1 != tmp$sd2), cor, 0)
		tmp$cov <- tmp$cor * tmp$sd1 * tmp$sd2
	  	corMat <- matrix(tmp$cov , nrow = nrow(data), ncol = nrow(data))
	  	diag(corMat) <- data[,es_var]
  	
  	return(corMat)
}

Making 3 new functions

  • a function to do shared control and shared measurements at the same time
  • a function to do pooling for multiple rma objects - rma_pool
  • a function to do marginalised mean from the models with more than one categorical moderators: rma_average

I2 column name bug needs fixing - should be easy

if(phylo == FALSE){
## FIXED PROBLEM WITH COLUMN NAMES in I2
tmpMatrix <- Matrix::cBind(I2_re[,-match("obs", colnames(I2_re))], I2_total)
colnames(tmpMatrix) <- c(colnames(I2_re)[-match("obs", colnames(I2_re))], "total")

Problem arises when fewer random effects in model (i.e. just single random effect) which turns I2_re into a vector without column header. Which creates issues. Also, some additional problems when only one random effect is included that needs more carful exploration. Maybe that model fit changes with only one level.

installation error

MacOS - R version 4.0.3

> install_github("daniel1noble/metaAidR")
Downloading GitHub repo daniel1noble/metaAidR@HEAD
Skipping 1 packages ahead of CRAN: forcats
   Warning in grepl(e, files, perl = TRUE, ignore.case = TRUE) :87xtzc0000gn/T/RtmpB3Ugl9/remotes11d494c70ff10/daniel1noble-metaAidR-5784af1/DESCRIPTION’ ...
     PCRE pattern compilation error
   	'unrecognized character follows \'
   	at 'yml$'
   Error in grepl(e, files, perl = TRUE, ignore.case = TRUE) : 
     invalid regular expression '^\.travis.\yml$'
   Execution halted
Error: Failed to install 'metaAidR' from GitHub:
  System command 'R' failed, exit status: 1, stdout + stderr:
E> * checking for file ‘/private/var/folders/k_/8zdkq3113d975dvt0187xtzc0000gn/T/RtmpB3Ugl9/remotes11d494c70ff10/daniel1noble-metaAidR-5784af1/DESCRIPTION’ ... OK
E> * preparing ‘metaAidR’:
E> * checking DESCRIPTION meta-information ... OK
E> Warning in grepl(e, files, perl = TRUE, ignore.case = TRUE) :
E>   PCRE pattern compilation error
E> 	'unrecognized character follows \'
E> 	at 'yml$'
E> Error in grepl(e, files, perl = TRUE, ignore.case = TRUE) : 
E>   invalid regular expression '^\.travis.\yml$'
E> Execution halted

Dealing with variable RE structures for I2

Need to sort out some checks with the I2 function to calculate I2 based on variable random effect structures (i.e. phylogeny, spp, study) or only species and study. This is a bit more complicated than anticipated because equations change as the random effect structure changes. There are a few easy roads, but must be an easier more general way to do this. d3f3a48

I2 for metafor objects

MC sampling technique implemented for metafor objects and validated (to some extent) with simulations. However, metafor does not estimate a residual variances as far as I can see and so this will need to be solved for calculations of I2. This is all still work in progress but will need to sort our residual variance estimates. Will dig into metafor manual for these details. 9ca9b12

I2 - Add

Observation level heterogeneity added to table. We can relax "obs" as the label for observation-level variance and grab the random effect that has the same dimension as the data. We can grab this name and use it for I2_obs.

I2 uncertainty estiamtion

Currently, use Monte Carlos simulations to get SE (probably should use n -1 rather than n; n being the number of levels). It would be good to compare ones from MCMCglmm and also, compare with ones obtained from parametric bootstrapping. I shall look into this soon while I work on something else (e.g. GrptR).

es_stat lnCVR

metafor's escalc() let you calculate lnCVR's sampling variance without covariance components. We have a reason to have this covariance but we should have an option not to have this covariance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.