\HeaderA{ci.balance}{Experimental Function to Correct Confidence Intervals At or Near
Boundaries of the Parameter Space by 'Sliding' the Interval on the
Quantile Scale.}{ci.balance}
\keyword{misc}{ci.balance}
\begin{Description}\relax
Experimental function to correct confidence intervals at or near
boundaries of the parameter space by 'sliding' the interval on the
quantile scale.
\end{Description}
\begin{Usage}
\begin{verbatim}
ci.balance(x, est, confidence=0.95, alpha=1-confidence, minval, maxval,
           na.rm=TRUE)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] Bootstrap parameter estimates.
\item[\code{est}] Observed value of the parameter.
\item[\code{confidence}] Confidence level for the interval. Defaults to
0.95.
\item[\code{alpha}] Type I error rate (size) for the interval. Defaults to
1-\code{confidence}.
\item[\code{minval}] A numeric value specifying the lower bound of the
parameter space. Leave unspecified (the default) if
there is no lower bound.
\item[\code{maxval}] A numeric value specifying the upper bound of the
parameter space. Leave unspecified (the default) if
there is no upper bound.
\item[\code{na.rm}] logical. Should missing values be removed?
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
EXPERIMENTAL FUNCTION:

This function attempts to compute a proper \code{conf}*100\%
confidence interval for parameters at or near the boundary of the
parameter space using bootstrapped parameter estimates by 'sliding'
the confidence interval on the quantile scale.

This is accomplished by attempting to place a \code{conf} *100\%
interval symmetrically *on the quantile scale* about the observed
value.  If a symmetric interval would exceed the observed data at the
upper (lower) end, a one-sided interval is computed with the upper
(lower) boundary fixed at the the upper (lower) boundary of the
parameter space.
\end{Details}
\begin{Value}
A list containing:
\begin{ldescription}
\item[\code{ci}] A 2-element vector containing the lower and upper confidence
limits.  The names of the elements of the vector give the actual
quantile values used for the interval or one of the character
strings "Upper Boundary" or "Lower Boundary".
\item[\code{overflow.upper, overflow.lower}] The number of elements beyond
those observed that would be needed to compute a symmetric (on the
quantile scale) confidence interval.
\item[\code{n.above, n.below}] The number of bootstrap values which are above
(below) the observed value.
\item[\code{lower.n, upper.n}] The index of the value used for the endpoint
of the confidence interval or the character string "Upper Boundary"
("Lower Boundary").
\end{ldescription}
\end{Value}
\begin{Author}\relax
Gregory R. Warnes \email{warnes@bst.rochester.edu }
\end{Author}
\begin{SeeAlso}\relax
\code{\LinkA{boot}{boot}},
\code{\LinkA{bootstrap}{bootstrap}},
Used by \code{\LinkA{diseq.ci}{diseq.ci}}.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
# These are nonsensical examples which simply exercise the
# computation. See the code to diseq.ci for a real example.
#
# FIXME: Add real example using boot or bootstrap.  

set.seed(7981357)
x <- abs(rnorm(100,1))
ci.balance(x,1, minval=0)
ci.balance(x,1)

x <- rnorm(100,1)
x <- ifelse(x>1, 1, x)
ci.balance(x,1, maxval=1)
ci.balance(x,1)
\end{ExampleCode}
\end{Examples}

