Gelman and Carlin introduced a command in R (retrodesign()) to calculate Type M and Type S errors in their 2014 paper, entitled "Beyond Power Calculations: Assessing Type S (Sign) and Type M (Magnitude) Errors" (link here: http://www.stat.columbia.edu/~gelman...ower_final.pdf ). The command itself only takes a few inputs:

A is the hypothesized true effect size, s is the standard error of the estimate, alpha is the significance threshold, and df is the degrees of freedom. qt is the quantile function in R, and pt is the distribution function. Unfortunately, I lack the programming chops to translate their code to Stata. If anyone has suggestions (aside from simply using R), I'd certainly be interested.

Code:

retrodesign <- function(A, s, alpha=.05, df=Inf, n.sims=10000){ z <- qt(1-alpha/2, df) p.hi <- 1 - pt(z-A/s, df) p.lo <- pt(-z-A/s, df) power <- p.hi + p.lo typeS <- p.lo/power estimate <- A + s*rt(n.sims,df) significant <- abs(estimate) > s*z exaggeration <- mean(abs(estimate)[significant])/A return(list(power=power, typeS=typeS, exaggeration=exaggeration)) }

## Comment