How to find confidence interval for theta in this case? My question is following:
 Suppose that $X\sim N(\theta,1)$. and $\theta \geq 0$. When $X=-2$ is observed, how can I construct a 95% confidence interval for $\theta$? This case is not usual for me because of the condition that $\theta\geq 0$. I've tried to find proper pivot variables but it was not easy. 
Is there any proper pivot variable or other ways to construct a 95% confidence interval in this case?   
 A: Let's think about this from first principles.  A confidence interval (in this context) is given by a pair of functions $l$ and $u.$ Setting $\alpha=95/100,$ their defining properties are


*

*For all numbers $x,$ $l(x) \le u(x).$  This means the interval $[l(x),u(x)]$ is well-defined and non-empty.

*No matter what $\theta\in [0,\infty)$ might be, $$\alpha \le \Pr(l(X) \le \theta \le u(X))\tag{1}$$ and there exists at least one such $\theta$ for which this is an equality.
This probability obviously is determined by $\theta$--there's no getting around that--but maybe we can make progress by computing it explicitly. 
This task is simplified by adopting the intuitively natural idea that both $l$ and $u$ ought to increase monotonically with $x,$ since larger values of $X$ are more likely to be drawn from distributions with larger $\theta.$  It's also clear we may assume $l$ and $u$ are continuous functions of $x.$  Consequently $l$ and $u$ are invertible and the probability in $(1)$ can be re-expressed in terms of the standard Normal distribution function $\Phi$ as
$$\eqalign{
\alpha&\le \Pr(l(X) \le \theta \le u(X)) \\&=  \Pr(X \in [u^{-1}(\theta), l^{-1}(\theta)]) \\&= \Phi(l^{-1}(\theta)-\theta) - \Phi(u^{-1}(\theta)-\theta).\tag{2}}$$

The left plot graphs the confidence limits against $X$ and compares them to $\theta.$  Any given $\theta$ will tend to produce values of $X$ near $\theta$ itself.  Provided the interval from $u^{-1}(\theta)$ up to $l^{-1}(\theta)$ (shown as the horizontal blue line segment) has at least $95\%$ chance of containing $X,$ no matter what the value of $\theta$ might be, the functions $(l,u)$ will satisfy defining inequality $(1).$  Having observed $X,$ the confidence interval is the vertical red segment.  The right plot shows how these limits are changed to accommodate the restriction $\theta\ge 0.$
Forgetting momentarily that $\theta\ge 0,$ it is easy--via inspection--not only to find a pair of such functions $l_0,u_0,$ but even a pair that (a) makes the confidence intervals as narrow as possible and (b) makes the confidence level always equal to $\alpha:$ namely, set
$$l_0^{-1}(\theta) - \theta = \Phi^{-1}((1 - \alpha)/2)$$
and
$$u_0^{-1}(\theta) - \theta = \Phi^{-1}(1 - (1 - \alpha)/2).$$
The unique solutions are
$$l_0(x) = x - \Phi^{-1}((1 - \alpha)/2);\ u_0(x) = x - \Phi^{-1}(1 - (1 - \alpha)/2) = x + \Phi^{-1}((1 - \alpha)/2).$$
How should this solution be modified given $\theta\ge 0$?  The obvious thing to try is to "clamp" the confidence interval to this range.  In other words, take the confidence interval to be the intersection of the interval $[l_0(X),u_0(X)]$ with $[0,\infty).$  That is,
$$l(x) = \max(0, x - \Phi^{-1}((1 - \alpha)/2));\ u(x) = \max(0, x + \Phi^{-1}((1 - \alpha)/2)).$$
Because this does not modify either $l^{-1}$ or $u^{-1}$ for $\theta \gt 0$ (see the right hand figure above), the inequality $(2)$ continues to hold.  Thus, $(l,u)$ is a confidence interval for $\theta.$
