suppressPackageStartupMessages({library(metafor);library(jsonlite)})
e<-read.csv('/job/evidence/fresh-effects.csv')
early<-subset(e,outcome=='depression' & window=='early')
ids<-c('T040','T093')
prior<-subset(early,parent %in% ids)
stopifnot(all(!prior$registered),all(!prior$retrospective),all(!prior$notice),all(!prior$design_conflict),all(!prior$registration_shared),all(prior$grim_fails<2),all(!prior$implausible))
# Conditional correction of two documented registration omissions only. This is
# not a complete recoding of every original trial or every risk-of-bias domain.
early$registered[early$parent %in% ids]<-TRUE
early$trustworthy[early$parent %in% ids]<-TRUE
d<-subset(early,group=='masked' & trustworthy)
m<-rma(yi=d$yi,vi=d$vi,method='REML',test='knha')
cat(toJSON(list(corrected_ids=ids,remaining_without_registration=length(unique(early$parent[!early$registered])),remaining_failed=length(unique(early$parent[!early$trustworthy])),masked_restricted=list(k=m$k,g=unname(coef(m)[1]),lower=m$ci.lb,upper=m$ci.ub,p=m$pval)),auto_unbox=TRUE,pretty=TRUE,digits=8),'\n')
