Last data update: 2014.03.03

R: Explained Variance
r2R Documentation

Explained Variance

Description

Compares tau-squared from empty model (omnibus or overall weighted mean) to model with moderators and provides percentage of explained variance.

Usage

r2(x)

Arguments

x

Will take either a mareg (meta-regression), or macat (single predictor categorical moderator analysis) object and evaluate.

Author(s)

AC Del Re & William T. Hoyt

Maintainer: AC Del Re acdelre@gmail.com

Examples

# Sample data
id<-c(1:20)
n.1<-c(10,20,13,22,28,12,12,36,19,12,36,75,33,121,37,14,40,16,14,20)
n.2 <- c(11,22,10,20,25,12,12,36,19,11,34,75,33,120,37,14,40,16,10,21)
g <- c(.68,.56,.23,.64,.49,-.04,1.49,1.33,.58,1.18,-.11,1.27,.26,.40,.49,
.51,.40,.34,.42,1.16)
var.g <- c(.08,.06,.03,.04,.09,.04,.009,.033,.0058,.018,.011,.027,.026,.0040,
.049,.0051,.040,.034,.0042,.016)
mod<-factor(c(rep(c(1,1,2,3),5)))
mods2<-c(rep(1:5,4))
df<-data.frame(id, n.1,n.2, g, var.g,mod, mods2)


# Examples

# mareg fuction
temp <- mareg(g~ mod + mods2, var = var.g, method = "REML", data = df)

r2(temp)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(MAd)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/MAd/r2.rd_%03d_medium.png", width=480, height=480)
> ### Name: r2
> ### Title: Explained Variance
> ### Aliases: r2
> ### Keywords: word
> 
> ### ** Examples
> 
> # Sample data
> id<-c(1:20)
> n.1<-c(10,20,13,22,28,12,12,36,19,12,36,75,33,121,37,14,40,16,14,20)
> n.2 <- c(11,22,10,20,25,12,12,36,19,11,34,75,33,120,37,14,40,16,10,21)
> g <- c(.68,.56,.23,.64,.49,-.04,1.49,1.33,.58,1.18,-.11,1.27,.26,.40,.49,
+ .51,.40,.34,.42,1.16)
> var.g <- c(.08,.06,.03,.04,.09,.04,.009,.033,.0058,.018,.011,.027,.026,.0040,
+ .049,.0051,.040,.034,.0042,.016)
> mod<-factor(c(rep(c(1,1,2,3),5)))
> mods2<-c(rep(1:5,4))
> df<-data.frame(id, n.1,n.2, g, var.g,mod, mods2)
> 
> 
> # Examples
> 
> # mareg fuction
> temp <- mareg(g~ mod + mods2, var = var.g, method = "REML", data = df)
Loading 'metafor' package (version 1.9-8). For an overview 
and introduction to the package please type: help(metafor).
> 
> r2(temp)

 Explained Variance:  

 Tau^2      (total): 0.1869
 Tau^2      (model): 0.1591
 R^2 (% expl. var.): 0.15 
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>