Skip to content

Instantly share code, notes, and snippets.

View Yefeng0920's full-sized avatar

Yefeng Yefeng0920

View GitHub Profile
@wviechtb
wviechtb / boot_rma_mv_parallel.r
Last active February 10, 2023 14:06
Bootstrapping rma.mv() model to get CI for pseudo R^2 statistic
############################################################################
library(metafor)
library(boot)
dat <- dat.crede2010
dat <- escalc(measure="ZCOR", ri=ri, ni=ni, data=dat, subset=criterion=="grade")
############################################################################
@jepusto
jepusto / simulation-in-R-2016
Created September 28, 2016 18:16
Rmd for my presentation on simulation studies in R, Quant Methods brownbag colloquium 2016/09/28
---
title: "Designing simulation studies in R"
author: "James E. Pustejovsky"
date: "September 28, 2016"
output:
ioslides_presentation:
css: custom.css
widescreen: true
transition: faster
---
@Lakens
Lakens / MetaAnalyticThinking.R
Last active April 23, 2021 02:38
People find it difficult to think about random variation. Our mind is more strongly geared towards recognizing patterns than randomness. In this blogpost, you can practice with getting used to what random variation looks like, how to reduce it by running well-powered studies, and how to meta-analyze multiple small studies.
# # # # # # # # # # #
#Initial settings----
# # # # # # # # # # #
if(!require(ggplot2)){install.packages('ggplot2')}
library(ggplot2)
if(!require(MBESS)){install.packages('MBESS')}
library(MBESS)
if(!require(pwr)){install.packages('pwr')}
library(pwr)
if(!require(meta)){install.packages('meta')}
@timflutre
timflutre / animal-model-basic.R
Last active May 20, 2024 17:33
compare lme4 and rrBLUP to fit an "animal model" (LMM) in R
## Model: a specific kind of linear mixed model known as "animal model" by geneticists
## y = mu 1_N + X b + Z u + e = W a + Z u + e
## y is N x 1; X is N x P; Z is N x Q; W is N x (P+1)
## u ~ Norm_Q(0, sigma_u^2 A); e ~ Norm_N(0, sigma^2 I_N)
## Goal of this document: estimate the variance components sigma_u^2 and sigma^2
## 1) simulate some data
## 2) fit the model above using the package rrBLUP (v4.3, on CRAN)
## 3) fit the model above using lme4 (v1.7, on CRAN)
## Author: Timothée Flutre (INRA)
@jepusto
jepusto / metafor-BRL.R
Created April 25, 2014 20:33
Bias-reduced linearization covariance estimator and degrees of freedom for multi-variate meta-analysis models
require(Formula)
require(metafor)
require(sandwich)
require(zoo)
require(lmtest)
#-----------------------------------------------
# Identify outer-most clustering variable
#-----------------------------------------------