This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(cobalt) | |
| library(WeightIt) | |
| library(marginaleffects) | |
| data("lalonde") | |
| lalonde_trt <- subset(lalonde, treat == 1) | |
| # ATT weighting with entropy-balancing | |
| w_ebal <- weightit( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| title: "Designing simulation studies in R" | |
| author: "James E. Pustejovsky" | |
| date: "September 28, 2016" | |
| output: | |
| ioslides_presentation: | |
| css: custom.css | |
| widescreen: true | |
| transition: faster | |
| --- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(tidyr) | |
| library(dplyr) | |
| library(stringr) | |
| library(ggplot2) | |
| cities_select <- c("HOUSTON","SAN ANTONIO","DALLAS","AUSTIN","FORT WORTH","EL PASO") | |
| #---------------------------------------- | |
| # get population estimates | |
| #---------------------------------------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require(Formula) | |
| require(metafor) | |
| require(sandwich) | |
| require(zoo) | |
| require(lmtest) | |
| #----------------------------------------------- | |
| # Identify outer-most clustering variable | |
| #----------------------------------------------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require(Formula) | |
| require(metafor) | |
| require(sandwich) | |
| require(zoo) | |
| require(lmtest) | |
| #----------------------------------------------- | |
| # Functions for making sandwich standard errors | |
| #----------------------------------------------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #---------------------------------------------- | |
| # 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) |
NewerOlder