View source: R/normal1sdQlink.R
| normal1sdQlink | R Documentation |
Computes the normal1sdQlink transformation for the Univariate
Normal Distribution, its inverse and the first two derivatives.
normal1sdQlink(theta, mean = stop("Please, enter the fixed 'mean'."),
p = stop(" Please, enter argument 'p'."),
bvalue = NULL, inverse = FALSE, deriv = 0,
short = TRUE, tag = FALSE)
theta |
Numeric or character.
This is |
mean |
A numeric vector or a matrix. It is the (known) fixed mean of the Normal distribution of interest. See below for further details. |
p |
Numeric vector of |
bvalue, inverse, deriv, short, tag |
Details at |
This link function is necessarily required by
normal1sd if quantile regression
is to be performed. It computes the normal1sdQlink
transformation, defined as
{\tt{mean}} + \sqrt{2}\sigma \cdot
{\tt{erf^{-1}}}(2 {\tt{p}} - 1).
Here, {\tt{erf^{-1}}} denotes the inverse
of the error function erf, and
\sigma is the standard deviation (theta) as in
normal1sd.
Technically, normal1sdQlink can be used for quantile regression
over any vector of p–quantiles of Normally distributed data
with known mean.
See normal1sd for further details
about the latter.
Values of p out of the open interval (0, 1) or non–positive
values of theta will result in Inf, -Inf,
NA or NaN.
When deriv = 0, the normal1sdQlink transformation
of theta, if inverse = FALSE. Conversely, if
inverse = TRUE, theta becomes \eta and
the inverse transformation given by
(theta - mean)/\sqrt{2}
erf^{-1}(2p - 1)
is returned.
For deriv = 1, d eta / d theta
if inverse = FALSE. Else, this function returns
d theta / d eta as a function of theta.
For deriv = 2, the second order derivatives are accordingly
returned.
If p is a vector, then the recycling rule applies only
if theta is entered as a matrix. Else, only the first entry in
p is considered.
When inverse = TRUE, the reciprocal of the error function,
erf, evaluated at 2p- 1
is required. However, the result is Inf for p= 0.5.
Here, in consequence, the limit of erf when
p tends to 0.5 is returned to avoid numerical issues.
V. Miranda
normal1sd,
erf,
Links.
### Example 1 ###
theta <- seq(0, 3, by = 0.1)[-1] # This is sigma, then must be positive.
mean <- -2.5 # Intentionally, a negative value for mu.
p <- 0.25 # Modelling the first quartile.
eta <- normal1sdQlink(theta = theta, p = p, mean = mean)
inv.eta <- normal1sdQlink(theta = eta, p = p, mean = mean, inverse = TRUE)
summary(inv.eta - theta) ## Should be 0
### Example 2. Special values of theta, using argument 'bvalue'. ###
theta <- c(-Inf, -5, -2.5, 0, 2.5, 5, Inf, NA, NaN)
my.matrix <- rbind(theta, normal1sdQlink(theta = theta, p = p, mean = mean),
normal1sdQlink(theta = theta, p = p, mean = mean, bvalue = 1e-5))
rownames(my.matrix) <- c("theta", "No 'bvalue'", "With 'bvalue'")
colnames(my.matrix) <- rep("", 9)
my.matrix # Second row has NAs, whilst third row has NO NAs except for theta = NA
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.