# How to extract standard deviation from normal distribution in R

If I have some point forecast and an 80% confidence interval, with the forecast assumed to be normally distributed with a constant variance, how do I extract the actual variance?

Let us work with the following data:

• Point Forecast: 6511

• Lower 80%: 6476

• Upper 80%: 6547

By definition, we thus know that:

$$$$\int_{6476}^{6547} \frac{1}{\sqrt{2 \pi \sigma^2}}exp \bigg(\frac{x-6511}{2 \sigma^2} \bigg) dx = 0.8$$$$

Can you provide some R-Code to find $$\sigma$$?

Thank you very much.

• For an 80% confidence interval you need 10% in the lower tail, 80% in the confidence region and 10% in the upper tail. Using the R function qnorm(0.9,0,1) we get that the upper limit (or half width) is at 1.28 standard deviations. The half width is also 6547-6511= 36. So if $1.28 \sigma = 36$ then $\sigma = 28.125$ Commented Feb 18, 2020 at 15:55
• So the R code (which I have not tested) is sigma:=((upper-lower)/2.0)/qnorm(1.0-(1.0-ci)/2.0,0,1) where in this case ci is equal to 0.80, upper is 6547 and lower is 6476. Commented Feb 18, 2020 at 16:35
• I understand. I have tried it myself and apparently: $$\frac{90th quantile-10th quantile}{\sigma}=constant$$ for any $\sigma$, for the normal distribution. But could you prove this rigorously? Commented Feb 19, 2020 at 12:00

So first lets consider a standard normal distribution $$X_0$$. This means that $$X_0$$ has mean zero ($$\mu = 0$$) and standard deviation 1 ($$\sigma = 1$$). Let's write $$\Phi^{-1}(\alpha)$$ for the $$\alpha$$ quantile of $$X_0$$. In R you can compute $$\Phi^ {-1}(\alpha)$$ using qnorm, i.g. $$\Phi^{-1}(0.1)$$ = qnorm(0.1).

Now consider $$X \sim \mathcal{N}(\mu, \sigma)$$. Then we have that $$X \stackrel{\text{d}}{=} \mu + \sigma \cdot X_0.$$ As a consequence the quantiles of $$X$$ can be written as $$\Phi^{-1}(\alpha) \cdot \sigma + \mu$$. You can easily verify this in R:

mu <- 3
sigma <- 1.2
alpha <- 0.45

qnorm(0.45) * sigma + mu
[1] 2.849206
qnorm(0.45, mean = mu, sd = sigma)
[1] 2.849206


Therefore

$$\frac{90th quantilie - 10th quantile}{\sigma} = \frac{\Phi^{-1}(0.9) \cdot \sigma + \mu - \Bigl(\Phi^{-1}(0.1) \cdot \sigma + \mu \Bigr)}{\sigma} =\\ \Phi^{-1}(0.9) - \Phi^{-1}(0.1).$$ I hope this answers your question from the comments.