Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

# Meta-Analysis Function --------------------------------------------------
## Summary Effect Size and its Standard Error using DL method (Eqs. 1-3)
mw_est <- function(yi,
vi,
data,
lab,
method = c("DL", "DL2"),
ci = .95,
Q.profile = FALSE,
pi = FALSE,
SDadjP.lm <- function(model, B = 10000, seed = 1, rob = FALSE) {
# Stop if model not 'lm' object
stopifnot(class(model)[1] == "lm")
# Set seed for reproducibility
set.seed(seed)
# Set robust estimator
est <- ifelse(rob == TRUE, "HC3", "const")
# Set covariance matrix
covMat <- vcovHC(model, est)
# Get observed t-values
@smancuso
smancuso / Power.R
Created November 5, 2018 00:15
Shiny App code for linear mixed model sample size calculations
# Load the shiny and longpower packages
library(shiny)
library(longpower)
# UI ----------------------------------------------------------------------
ui <- fluidPage(
# Add title
titlePanel("Linear Mixed Model Sample Size Calculations"),
@smancuso
smancuso / Model1_Ex10.2_Data.R
Last active June 8, 2018 09:41
Example 10.2 RePROCESS Model 1 Data Import
# Import 'protest' data and convert 'protest' to 'labelled'
protest <- read.csv("protest.csv", header = TRUE) %>%
mutate(
protest = labelled(
protest,
c(
"No protest" = 0,
"Individual protest" = 1,
"Collective protest" = 2
)
# -------------------------------------------------------------------------
# Project: SF-12 v2.0 Scoring using Australian Population Weights
#
# Coded by: Sam Mancuso
# Web: sammancuso.com
#
# Date: 9 November 2017
# Version: 2.00
# Notes: Updated to use dplyr
# -------------------------------------------------------------------------
# Load required packages --------------------------------------------------
if (!require(pacman)) {
install.packages("pacman")
}
pacman::p_load(car, boot)
# Function ----------------------------------------------------------------
nullboot.Anova <- function(null.model, full.model,
B = 1000, scaled = TRUE, seed = 1234,
ci = TRUE, cent = .95, dec = 5,
@smancuso
smancuso / Bootstrap ANOVA with Post Hocs.R
Last active January 26, 2024 11:38
Bootstrap AN(C)OVA with Pairwise Post Hoc Comparisons
# -------------------------------------------------------------------------
# Project: Bootstrap AN(C)OVA with Posthoc Pairwise Comparisons
# Coded by: Sam Mancuso
# Mail: sammancuso.wordpress.com
# Date: 27 May 2015
# Version: 2.0
# Revision Date: 2 June 2015
# -------------------------------------------------------------------------
# Load Libraries ----------------------------------------------------------
@smancuso
smancuso / Bootstrap ANCOVA.R
Last active July 27, 2023 14:16
Bootstrapped AN(C)OVA
# -------------------------------------------------------------------------
# Project: Bootstrap AN(C)OVA
# Coded by: Sam Mancuso
# Mail: sammancuso.wordpress.com
# Date: 18 May 2015
# Version: 1.0
# Revision Date: NA
# -------------------------------------------------------------------------
# Load Libraries ----------------------------------------------------------
**********************************************************************
* Project: Classification of Eating Disorders using EDE-Q
* Coded by: Sam Mancuso
* Version: 1.0
* Date: 22 July 2014
***********************************************************************
** NB
* bmi_at_assessment = Clinician assessed BMI
* menstrual_status_on_admission = Clinician assessed menstrual status
@smancuso
smancuso / ExpSample.R
Last active June 7, 2018 18:08
Sample Size Estimation for Comparisons between Two Groups
# -------------------------------------------------------------------------
# Sample Size Estimation for Comparisons between Two Groups
# in Experimental Designs
# Coded by: Sam Mancuso
# Date: 03 March 2015
# Version: 2.0
# Revision Date: 05 March 2015
# Blog: sammancuso.wordpress.com
# -------------------------------------------------------------------------