schools_ipd <- data.frame()
N <- c(rep(10, 4), rep(20, 4))
for(i in 1:8){
bsl <- rnorm(1, 0, 5)
x <- rnorm(N[i])
x <- (x-mean(x))/sd(x)
x <- x*schools$se[i]*sqrt(N[i])/1.41 + schools$tau[i]
y <- rnorm(N[i])
y <- (y-mean(y))/sd(y)
y <- y*schools$se[i]*sqrt(N[i])/1.41
schools_ipd <- rbind(schools_ipd,
data.frame(group = schools$group[i], outcome = bsl + x, treatment = 1),
# This is just so that we don't trip off prepare_ma:
data.frame(group = schools$group[i], outcome = bsl + y, treatment = 0))
}
library(tidyverse)
prepare_ma(schools_ipd) #similar SEs, different means, obvs
summ <- prepare_ma(schools_ipd)
schools_ipd %>% group_by(treatment, group) %>% summarise(sd(outcome))
summ$se <- summ$se.tau; summ$mu <- NULL; summ$se.mu <- NULL; summ$se.tau <- NULL
baggr(summ[1:8,], iter = 5e03, refresh=0, model = "rubin")
gives a stupid error:
> baggr(summ[1:8,], iter = 5e03, refresh=0, model = "rubin")
Error in convert_inputs(data, model, covariates = covariates, quantiles = quantiles, :
Data provided is of type Aggregate (control and effects) and the model requires Aggregate (effects only)
There is code in convert_inputs.R that does this, but it may mess things up downstream, if other functions re-use $data from the resulting baggr object
gives a stupid error: