Type: | Package |
Title: | Confidence Intervals Utilizing Uncertain Prior Information |
Version: | 1.2.3 |
Author: | Paul Kabaila [aut, cre], Rheanna Mainzer [aut], Ayesha Perera [ctb] |
Maintainer: | Paul Kabaila <P.Kabaila@latrobe.edu.au> |
Depends: | R (≥ 2.10) |
Description: | Computes a confidence interval for a specified linear combination of the regression parameters in a linear regression model with iid normal errors with known variance when there is uncertain prior information that a distinct specified linear combination of the regression parameters takes a given value. This confidence interval, found by numerical nonlinear constrained optimization, has the required minimum coverage and utilizes this uncertain prior information through desirable expected length properties. This confidence interval has the following three practical applications. Firstly, if the error variance has been accurately estimated from previous data then it may be treated as being effectively known. Secondly, for sufficiently large (dimension of the response vector) minus (dimension of regression parameter vector), greater than or equal to 30 (say), if we replace the assumed known value of the error variance by its usual estimator in the formula for the confidence interval then the resulting interval has, to a very good approximation, the same coverage probability and expected length properties as when the error variance is known. Thirdly, some more complicated models can be approximated by the linear regression model with error variance known when certain unknown parameters are replaced by estimates. This confidence interval is described in Mainzer, R. and Kabaila, P. (2019) <doi:10.32614/RJ-2019-026>, and is a member of the family of confidence intervals proposed by Kabaila, P. and Giri, K. (2009) <doi:10.1016/j.jspi.2009.03.018>. |
License: | GPL-2 |
Encoding: | UTF-8 |
LazyData: | true |
Imports: | nloptr, statmod, functional, pracma, stats, graphics |
RoxygenNote: | 7.3.1 |
Suggests: | knitr, rmarkdown |
VignetteBuilder: | knitr |
NeedsCompilation: | no |
Packaged: | 2024-06-18 06:40:21 UTC; Kabaila |
Repository: | CRAN |
Date/Publication: | 2024-06-18 15:30:02 UTC |
Computes the known correlation \rho
between \widehat{\theta}
and \widehat{\tau}
from the
p
-vectors
a
and c
and the
design matrix X
Description
Computes the known correlation \rho
between \widehat{\theta}
and \widehat{\tau}
. This correlation is computed from the
p
-vectors
a
and c
and the n \times p
design matrix X
, with linearly independent columns, using the formula
\rho=a^{\top}(X^{\top} X)^{-1} c
/(v_{\theta} \, v_{\tau})^{1/2}
, where
v_{\theta}
=a^{\top}(X^{\top} X)^{-1}a
and
v_{\tau}
=c^{\top}(X^{\top} X)^{-1}c
.
Usage
acX_to_rho(a, c, X)
Arguments
a |
The |
c |
The |
X |
The |
Value
The known correlation \rho
between \widehat{\theta}
and \widehat{\tau}
.
Examples
a <- c(0, 2, 0, -2)
c <- c(0, 0, 0, 1)
x1 <- c(-1, 1, -1, 1)
x2 <- c(-1, -1, 1, 1)
X <- cbind(rep(1, 4), x1, x2, x1*x2)
rho <- acX_to_rho(a, c, X)
print(rho)
The list that specifies the CIUUPI for the example
Description
In this example, the dataset described in Table 7.5 of Box et al. (1963) is used.
The design matrix X is
specified by the command
X <- cbind(rep(1,4), c(-1, 1, -1, 1), c(-1, -1, 1, 1), c(1, -1, -1, 1))
.
A description of the parameter of interest is given in Discussion 5.8, p.3426 of
Kabaila and Giri (2009).
The parameter of interest is \theta = a^{\top} \beta
,
where the column vector a
is specified by the command
a <- c(0, 2, 0, -2)
.
For this example, we have uncertain prior information that
\tau = c^{\top} \beta = 0
, where the column vector c
is specified by the command
c <- c(0, 0, 0, 1)
.
The known correlation \rho
between \widehat{\theta}
and \widehat{\tau}
is
computed using the command
rho <- acX_to_rho(a, c, X)
.
The desired minimum coverage probability of the CIUUPI is 1 - \alpha
, where
\alpha = 0.05
, which is specified by the command
alpha <- 0.05
.
The CIUUPI is determined by \alpha
and \rho
and is found using the
command
bs.list.example <- bs_ciuupi(alpha, rho)
,
which takes about 5 minutes to run.
Usage
bs.list.example
Format
An object of class list
of length 8.
References
Box, G.E.P., Connor, L.R., Cousins, W.R., Davies, O.L., Hinsworth, F.R., Sillitto, G.P. (1963) The Design and Analysis of Industrial Experiments, 2nd edition, reprinted. Oliver and Boyd, London.
Kabaila, P. and Giri, K. (2009) Confidence intervals in regression utilizing prior information. Journal of Statistical Planning and Inference, 139, 3419 - 3429.
Computes the the functions b
and s
that specify the CIUUPI for all possible
values of \sigma
and the observed response vector
Description
Chooses the positive number d
and the positive integer q
, sets
h=d/q
, and then computes the
(2q-1)
-vector
\big(b(h),...,b((q-1)h),
s(0),s(h)...,s((q-1)h)\big)
that determines, via cubic spline interpolation, the functions
b
and s
which specify
the confidence interval for \theta
that utilizes the uncertain prior information (CIUUPI),
for all possible values of \sigma
and the observed response vector.
To an excellent approximation, this confidence interval
has minimum coverage probability
1-\alpha
.
Usage
bs_ciuupi(alpha, rho, natural = 1)
Arguments
alpha |
The desired minimum coverage probability
is |
rho |
The known correlation |
natural |
Equal to 1 (default) if the functions |
Details
Suppose that
y = X \beta + \varepsilon
where y
is a random n
-vector of
responses, X
is a known n
by p
matrix
with linearly
independent columns, \beta
is an unknown parameter
p
-vector and
\varepsilon
is the random error with components that are iid normally distributed
with zero mean and known variance \sigma^2
.
The parameter of interest is
\theta = a^{\top} \beta
.
Also let \tau = c^{\top}\beta -t
, where a
and c
are specified linearly independent
vectors and t
is a specified number.
The uncertain prior information is that \tau = 0
.
Let rho
denote the known
correlation between the \widehat{\theta}
and \widehat{\tau}
.
We can compute rho
from given values of a
, c
and X
using the function acX_to_rho
.
The confidence interval for \theta
,
with minimum coverage probability
1-
alpha
, that utilizes the uncertain prior
information that
\tau =
0 belongs to a class of confidence
intervals indexed
by the functions b
and s
.
The function b
is an odd continuous function and
the function s
is an even
continuous function. In addition, b(x)=0
and
s(x)
is equal to the
1-
alpha
/2
quantile of the
standard normal distribution for all |x| \ge d
, where
d
is a given positive number.
Extensive numerical explorations
have been used to find a formula (in terms of
alpha
and rho
) for a 'goldilocks'
value of d
that is neither too large nor too small.
Then let q
=ceiling(d
/0.75) and h=d/q
.
The values of the functions b
and s
in
the interval [-d,d]
are specified by the (2q-1)
-vector
\big(b(h),...,b((q-1)h), s(0),s(h)...,s((q-1)h) \big)
.
The values of b(kh)
and s(kh)
for k=-q,...,q
are
deduced from this vector using the assumptions made about
the functions b
and s
.
The values of b(x)
and s(x)
for any x
in the interval
[-d, d]
are then found using cube spline interpolation using the
values of b(kh)
and s(kh)
for k=-q,...,q
.
For natural
=1 (default) this is 'natural' cubic
spline interpolation and for natural
=0 this is
'clamped' cubic spline interpolation.
The vector \big(b(h),...,b((q-1)h), s(0),s(h)...,s((q-1)h)\big)
is found by numerical nonlinear constrained optimization
so that the confidence interval has minimum
coverage probability 1-
alpha
and utilizes
the uncertain prior information
through its desirable expected length properties.
This optimization is performed using the
slsqp
function
in the nloptr
package.
Value
A list with the following components.
alpha, rho, natural: the inputs
d: a 'goldilocks' value of d
that is not too large
and not too small
n.ints: number of equal-length consecutive
intervals whose union is [0,d]
,
this is the same as q
lambda.star: the computed value of \lambda^*
bsvec: the vector
\big(b(h),...,b((q-1)h), s(0),s(h)...,s((q-1)h) \big)
that determines
the functions b
and s
that specify the CIUUPI for all possible
values of \sigma
and observed response vector
comp.time: the computation time in seconds
Examples
alpha <- 0.05
rho <- - 1 / sqrt(2)
bs.list <- bs_ciuupi(alpha, rho)
Evaluate the functions b
and s
at x
Description
Evaluate the functions b
and s
, as specified by
bsvec
,
alpha
, d
, n.ints
and natural
, at x
.
Usage
bsspline(x, bsvec, alpha, d, n.ints, natural)
Arguments
x |
A value or vector of values at which the functions |
bsvec |
The
where |
alpha |
The desired minimum coverage probability is |
d |
The functions |
n.ints |
The number of equal-length intervals in |
natural |
Equal to 1 (default) if the |
Value
A data frame containing x
and the corresponding values of the
functions b
and s
.
Examples
x <- seq(0, 8, by = 1)
alpha <- bs.list.example$alpha
natural <- bs.list.example$natural
d <- bs.list.example$d
n.ints <- bs.list.example$n.ints
bsvec <- bs.list.example$bsvec
bs <- bsspline(x, bsvec, alpha, d, n.ints, natural)
For given observed response vector y
, compute
the standard 1 - \alpha
confidence interval
Description
If \sigma
is provided then compute the standard 1 - \alpha
confidence interval for \theta
. If \sigma
is not provided
then, as long as n-p \ge 30
, replace \sigma
by its estimate
to compute an approximate 1 - \alpha
confidence interval for \theta
.
Usage
ci_standard(a, X, y, alpha, sig = NULL)
Arguments
a |
The vector used to specify the parameter of interest
|
X |
The known |
y |
The |
alpha |
|
sig |
Standard deviation of the random error.
If a value is not specified then, provided that |
Details
Suppose that
y = X \beta + \varepsilon,
where y
is a random n
-vector of responses, X
is a known n \times p
matrix with linearly independent columns,
\beta
is an unknown parameter p
-vector, and
\varepsilon \sim N(0, \, \sigma^2 \, I)
, with \sigma^2
assumed known.
Suppose that the parameter of interest is \theta = a^{\top} \beta
.
The R function ci_standard
computes the standard 1 - \alpha
confidence interval for \theta
.
The example below is described in Discussion 5.8 on
p.3426 of Kabaila and Giri (2009). This example is obtained
by extracting a 2 \times 2
factorial data set from the
2^3
factorial data set described in Table 7.5
of Box et al. (1963).
Value
If \sigma
is provided then a data frame of the lower and upper
endpoints of the standard 1 - \alpha
confidence interval
for \theta
. If \sigma
is not provided then, as long as n-p \ge 30
, a data frame of the
lower and upper endpoints of
an approximation to this confidence interval.
References
Box, G.E.P., Connor, L.R., Cousins, W.R., Davies, O.L., Hinsworth, F.R., Sillitto, G.P. (1963) The Design and Analysis of Industrial Experiments, 2nd edition, reprinted. Oliver and Boyd, London.
Kabaila, P. and Giri, K. (2009) Confidence intervals in regression utilizing prior information. Journal of Statistical Planning and Inference, 139, 3419 - 3429.
Examples
y <- c(87.2, 88.4, 86.7, 89.2)
x1 <- c(-1, 1, -1, 1)
x2 <- c(-1, -1, 1, 1)
X <- cbind(rep(1, 4), x1, x2, x1*x2)
a <- c(0, 2, 0, -2)
ci_standard(a, X, y, 0.05, sig = 0.8)
For given observed response vector y
,
compute the confidence interval that utilizes the
uncertain prior information (CIUUPI)
Description
If \sigma
is provided then, for given observed response
vector y
,
compute the confidence interval, with minimum coverage
probability 1-\alpha
, for the parameter
\theta =a^{\top}\beta
that
utilizes the uncertain prior information that the parameter
\tau=c^{\top} \beta-t
(specified by the vector c
and the number
t
) takes the value 0. If \sigma
is not provided
then, as long as n-p \ge 30
, replace \sigma
by its estimate
to compute an approximation to the CIUUPI for \theta
.
Usage
ciuupi_observed_value(a, c, X, alpha, bs.list, t, y, sig = NULL)
Arguments
a |
The |
c |
The |
X |
The |
alpha |
|
bs.list |
A list that includes the following components: natural, d, q and the vector bsvec (b(h),...,b((q-1)h), s(0),s(h)...,s((q-1)h)), where h=d/q, that specifies the CIUUPI for all possible values of the random error variance and the observed response vector |
t |
The number |
y |
The |
sig |
Standard deviation of the random error.
If a value is not specified then, provided that |
Details
Suppose that
y = X \beta + \varepsilon
where y
is a random n
-vector of
responses, X
is a known n \times p
matrix with linearly
independent columns, \beta
is an unknown parameter
p
-vector and
\varepsilon
has components that are iid normally distributed
with zero mean and known variance.
Suppose that
\theta=
a
^{\top}
\beta
is the
parameter of interest, where a
is a specified
vector. Let
\tau=
c
^{\top} \beta -
t
,
where c
is a specified vector,
t
is a specified number and
a
and c
are
linearly independent vectors. Also suppose that we have
uncertain prior information that \tau = 0
.
For given observed response
vector y
and a design matrix X
,
ciuupi_observed_value
computes the
confidence interval, with minimum coverage probability
1-
alpha
, for \theta
that utilizes the uncertain prior information that
\tau = 0
.
The example below is described in Discussion 5.8 on
p.3426 of Kabaila and Giri (2009). This example is obtained
by extracting a 2 \times 2
factorial data set from the
2^3
factorial data set described in Table 7.5
of Box et al. (1963).
Value
If \sigma
is provided then a data frame of the lower and upper
endpoints of
the confidence interval, with minimum coverage
probability 1-\alpha
, for the parameter
\theta
that utilizes the
uncertain prior information that \tau = 0
.
If \sigma
is not provided then, as long as n-p \ge 30
, a data frame of the
lower and upper endpoints of
an approximation to this confidence interval.
References
Box, G.E.P., Connor, L.R., Cousins, W.R., Davies, O.L., Hinsworth, F.R., Sillitto, G.P. (1963) The Design and Analysis of Industrial Experiments, 2nd edition, reprinted. Oliver and Boyd, London.
Kabaila, P. and Giri, K. (2009) Confidence intervals in regression utilizing prior information. Journal of Statistical Planning and Inference, 139, 3419 - 3429.
Examples
a <- c(0, 2, 0, -2)
c <- c(0, 0, 0, 1)
x1 <- c(-1, 1, -1, 1)
x2 <- c(-1, -1, 1, 1)
X <- cbind(rep(1, 4), x1, x2, x1*x2)
alpha <- 0.05
t <- 0
y <- c(87.2, 88.4, 86.7, 89.2)
sig <- 0.8
ciuupi_observed_value(a, c, X, alpha, bs.list.example, t, y, sig=sig)
Compute the coverage probability of the CIUUPI
Description
Evaluate the coverage probability of the confidence interval that
utilizes uncertain prior information (CIUUPI) at gam
.
The input bs.list
determines the functions b
and s
that specify the confidence interval that utilizes the uncertain
prior information (CIUUPI), for all possible values of \sigma
and observed response vector.
Usage
cpciuupi(gam, n.nodes, bs.list)
Arguments
gam |
A value of |
n.nodes |
The number of nodes for the Gauss Legendre quadrature used for the evaluation of the coverage probability |
bs.list |
A list that includes the following components.
where |
Value
The value(s) of the coverage probability of the CIUUPI at gam
.
Examples
gam <- seq(0, 10, by = 0.2)
n.nodes <- 10
cp <- cpciuupi(gam, n.nodes, bs.list.example)
Plot the graph of the odd function b
used in the specification of the CIUUPI
Description
The input bs.list
determines the functions b
and s
that specify the confidence interval that utilizes the uncertain
prior information (CIUUPI), for all possible values of \sigma
and observed response vector. The R function plot_b
plots the graph of the odd function b
.
Usage
plot_b(bs.list)
Arguments
bs.list |
A list that includes the following components.
where |
Value
A plot of the graph of the odd function b
used in the
specification of the CIUUPI.
Examples
plot_b(bs.list.example)
Plot the graph of the coverage probability of the CIUUPI
Description
The input bs.list
determines the functions b
and s
that specify the confidence interval that utilizes the uncertain
prior information (CIUUPI), for all possible values of \sigma
and observed response vector.
The coverage probability of the CIUUPI is an even function of
the unknown parameter
\gamma = \tau \big/ \big(\sigma \, v_{\tau}^{1/2} \big)
.
The R function plot_cp
plots the graph of the coverage probability
of the CIUUPI, as a function of |\gamma|
.
To provide a stringent
assessment of this coverage probability, we use a fine equally-spaced grid
seq(0, (d+4), by = 0.01)
of values of
\gamma
and Gauss Legendre quadrature
using 10 nodes in the relevant integrals. By contrast,
for the computation
of the CIUUPI, implemented in bs_ciuupi
, we
require that the coverage probability of this confidence
interval is greater than or equal to 1-\alpha
for the equally-spaced grid seq(0, (d+2), by = 0.05)
of values of
\gamma
and we use Gauss Legendre quadrature
with 5 nodes in the relevant integrals.
Usage
plot_cp(bs.list)
Arguments
bs.list |
A list that includes the following components.
where |
Value
A plot of the graph of the coverage probability of the
CIUUPI as a function of |\gamma|
, where
\gamma
denotes the unknown parameter
\tau \big/ \big(\sigma \, v_{\tau}^{1/2} \big)
.
Examples
plot_cp(bs.list.example)
Plot the graph of the even function s
used in the specification of the CIUUPI
Description
The input bs.list
determines the functions b
and s
that specify the confidence interval that utilizes the uncertain
prior information (CIUUPI), for all possible values of \sigma
and observed response vector. The R function plot_s
plots the graph of the odd function s
.
Usage
plot_s(bs.list)
Arguments
bs.list |
A list that includes the following components.
where |
Value
A plot of the graph of the even function s
used in the
specification of the CIUUPI.
Examples
plot_s(bs.list.example)
Plot the graph of the squared scaled expected length of the CIUUPI
Description
The input bs.list
determines the functions b
and s
that specify the confidence interval that utilizes the uncertain
prior information (CIUUPI), for all possible values of \sigma
and observed response vector.
The scaled expected length of the CIUUPI is an even function of
the unknown parameter
\gamma = \tau \big/ \big(\sigma \, v_{\tau}^{1/2} \big)
.
The R function plot_squared_sel
plots the graph of the squared scaled
expected length (i.e. squared SEL)
of the CIUUPI, as a function of |\gamma|
.
To provide a stringent
assessment of this squared SEL, we use a grid
seq(0, (d+4), by = 0.01)
of values of
\gamma
and Gauss Legendre quadrature
with 10 nodes in the relevant integrals. By contrast,
for the computation
of the CIUUPI, implemented in bs_ciuupi
, we
use Gauss Legendre quadrature
with 5 nodes in the relevant integrals.
Usage
plot_squared_sel(bs.list)
Arguments
bs.list |
A list that includes the following components.
where |
Value
A plot of the graph of the squared scaled
expected length (i.e. squared SEL)
of the CIUUPI as a function of |\gamma|
, where
\gamma
denotes the unknown parameter
\tau \big/ \big(\sigma \, v_{\tau}^{1/2} \big)
.
Examples
plot_squared_sel(bs.list.example)
Compute the scaled expected length of the CIUUPI
Description
Evaluate the scaled expected length of the confidence interval that
utilizes uncertain prior information (CIUUPI) at gam
.
This scaled expected length is defined to be the expected length of the
CIUUPI divided
by the expected length of the standard 1 - \alpha
confidence interval.
The input bs.list
determines the functions b
and s
that specify the confidence interval that utilizes the uncertain
prior information (CIUUPI), for all possible values of \sigma
and observed response vector.
Usage
selciuupi(gam, n.nodes, bs.list)
Arguments
gam |
A value of |
n.nodes |
The number of nodes for the Gauss Legendre quadrature used for the evaluation of the scaled expected length |
bs.list |
A list that includes the following components.
where |
Value
The value(s) of the scaled expected length at gam
.
Examples
gam <- seq(0, 10, by = 0.2)
n.nodes <- 10
sel <- selciuupi(gam, n.nodes, bs.list.example)