# Graphing the expected magnitude of an estimate $\hat{\theta}$, given statistical significance, as a function of the true $\theta$ [closed]

I'm looking to start with an assumed true parameter $\theta$, and taking the normal distribution of the estimate $\hat{\theta}$ with mean $\theta$ and a known standard deviation (suppose it's $0.10$), and compute $E ( |\hat{\theta}|$, given $|\hat{\theta}| > 0.20)$, i.e. the expected magnitude of the estimate when selected for statistical significance. The goal is, using R, to plot this $E ( |\hat{\theta}|$, given $|\hat{\theta}| > 0.20)$ as a function of the true $\theta$.

See page 3 and the top of page 4 of the following for an example: http://www.stat.columbia.edu/~gelman/research/published/incrementalism_3.pdf

## closed as unclear what you're asking by Juho Kokkala, kjetil b halvorsen, Peter Flom♦Dec 4 '17 at 12:50

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• You don't seem to ask any questions here. What do you want to know? – Glen_b Dec 3 '17 at 21:23

Here is the R function that calculates the bias (adapted from here):

bias <- function(m, sem) {

func <- function(x, ...) {x * dnorm(x, ...)}

((abs(integrate(func, -Inf, -2*sem, mean=m, sd = sem)$value) + integrate(func, 2*sem, Inf, mean=m, sd = sem)$value)/
((pnorm(-2*sem, mean=m, sd=sem) - pnorm(-Inf, mean=m, sd=sem)) + (pnorm(Inf, mean=m, sd=sem) - pnorm(2*sem, mean=m, sd=sem)))) - m

}


Let's test it with the examples from Gelman:

sapply(c(0, 0.1, 0.25), bias, sem = 0.12)
[1] 0.28478586 0.19877756 0.08946908


Seems correct. Now let's reproduce their Figure 1:

theta <- seq(0, 0.6, length.out = 100)

b <- sapply(theta, bias, sem = 0.12)

plot(b~theta, type = "l", las = 1, ylab = "Bias", lwd = 2)
abline(h = 0)


theta <- seq(0, 0.6, length.out = 100)