{{ message }}

Instantly share code, notes, and snippets.

# James E. Pustejovskyjepusto

Created Sep 28, 2016
Rmd for my presentation on simulation studies in R, Quant Methods brownbag colloquium 2016/09/28
View simulation-in-R-2016
 --- title: "Designing simulation studies in R" author: "James E. Pustejovsky" date: "September 28, 2016" output: ioslides_presentation: css: custom.css widescreen: true transition: faster ---
Last active Aug 11, 2016
View bug-in-nlme::getVarCov.R
 # Demonstrate the problem with gls model library(nlme) data(Ovary) gls_raw <- gls(follicles ~ sin(2*pi*Time) + cos(2*pi*Time), data = Ovary, correlation = corAR1(form = ~ 1 | Mare), weights = varPower())
Last active Dec 31, 2015
An adaptation of the Welch t-test simulation, for running in parallel on the Stampede server of the Texas Advanced Computing Cluster.
View Simulate Welch t-test in parallel
 #---------------------------------------------- # data-generating model #---------------------------------------------- two_group_data <- function(iterations, n, p, var_ratio, delta) { Group <- c(rep("C", n * p), rep("T", n * (1 - p))) Y_C <- matrix(rnorm(iterations * n * p, mean = 0, sd = 1), n * p, iterations) Y_T <- matrix(rnorm(iterations * n * (1 - p), mean = delta, sd = sqrt(var_ratio)), n * (1 - p), iterations) dat <- data.frame(Group, rbind(Y_C, Y_T)) return(dat)
Last active Dec 29, 2015
A simulation evaluating the confidence interval coverage for a difference in means, allowing for unequal variances, based on Welch's approximation for the degrees of freedom. The code demonstrates the basic structure of a simulation study in R.
View Simulate Welch t-test
 #---------------------------------------------- # data-generating model #---------------------------------------------- two_group_data <- function(iterations, n, p, var_ratio, delta) { Group <- c(rep("C", n * p), rep("T", n * (1 - p))) Y_C <- matrix(rnorm(iterations * n * p, mean = 0, sd = 1), n * p, iterations) Y_T <- matrix(rnorm(iterations * n * (1 - p), mean = delta, sd = sqrt(var_ratio)), n * (1 - p), iterations) dat <- data.frame(Group, rbind(Y_C, Y_T)) return(dat)
Created Aug 24, 2015
View Fatal crashes by city, 2006-2015
 library(tidyr) library(dplyr) library(stringr) library(ggplot2) cities_select <- c("HOUSTON","SAN ANTONIO","DALLAS","AUSTIN","FORT WORTH","EL PASO") #---------------------------------------- # get population estimates #----------------------------------------
Last active Aug 29, 2015
Code for figures displaying annual number of fatal automobile crashes, fatalities, etc. in Austin and Travis County, 2003-2015
View Austin crashes - annual data figures
 library(tidyr) library(dplyr) library(stringr) library(ggplot2) #-------------------------------- # format the data for graphing #-------------------------------- crash_dat <- read.csv("http://blogs.edb.utexas.edu/pusto/files/2015/08/Yearly_crash_data_Austin_and_Travis_County.csv")
Created Apr 25, 2014
Bias-reduced linearization covariance estimator and degrees of freedom for multi-variate meta-analysis models
View metafor-BRL.R
 require(Formula) require(metafor) require(sandwich) require(zoo) require(lmtest) #----------------------------------------------- # Identify outer-most clustering variable #-----------------------------------------------
Created Apr 21, 2014
Correlated effects example from Tanner-Smith & Tipton (2013)
View RVE-correlated.R
 # robumeta calculations library(grid) library(robumeta) data(corrdat) rho <- 0.8 HTJ <- robu(effectsize ~ males + college + binge, data = corrdat, modelweights = "CORR", rho = rho, studynum = studyid,
Created Apr 21, 2014
Calculate sandwich covariance estimators for multi-variate meta-analysis models
View metafor-sandwich.R
 require(Formula) require(metafor) require(sandwich) require(zoo) require(lmtest) #----------------------------------------------- # Functions for making sandwich standard errors #-----------------------------------------------
Last active Aug 29, 2015
Hierarchical effects example from Tanner-Smith & Tipton (2013)
View RVE-hierarchical.R
 # robumeta calculations library(grid) library(robumeta) data(hierdat) HTJ <- robu(effectsize ~ males + binge, data = hierdat, modelweights = "HIER", studynum = studyid, var.eff.size = var, small = FALSE)